Revision fe15cd00

b/snf-tools/synnefo_tools/burnin/__init__.py
42 42
from synnefo_tools import version
43 43
from synnefo_tools.burnin import common
44 44
from synnefo_tools.burnin.astakos_tests import AstakosTestSuite
45
from synnefo_tools.burnin.cyclades_tests import FlavorsTestSuite
45 46

  
46 47

  
47 48
# --------------------------------------------------------------------
48 49
# Define our TestSuites
49 50
TESTSUITES = [
50
    AstakosTestSuite
51
    AstakosTestSuite,
52
    FlavorsTestSuite
51 53
    ]
52 54

  
53 55
TSUITES_NAMES = [tsuite.__name__ for tsuite in TESTSUITES]
b/snf-tools/synnefo_tools/burnin/astakos_tests.py
42 42
from synnefo_tools.burnin import common
43 43

  
44 44

  
45
# Too many public methods (47/20). pylint: disable-msg=R0904
45
# Too many public methods. pylint: disable-msg=R0904
46 46
class AstakosTestSuite(common.BurninTests):
47 47
    """Test Astakos functionality"""
48
    def test_unauthorized_access(self):
48
    def test_001_unauthorized_access(self):
49 49
        """Test that access without a valid token fails"""
50 50
        false_token = "12345"
51 51
        self.info("Will use token %s", false_token)
......
56 56
            client.list_servers()
57 57
            self.assertEqual(cl_error.exception.status, 401)
58 58

  
59
    def test_name2uuid(self):
59
    def test_002_name2uuid(self):
60 60
        """Test that usernames2uuids and uuids2usernames are complementary"""
61 61
        our_uuid = self._get_uuid()
62 62

  
b/snf-tools/synnefo_tools/burnin/common.py
73 73
    def startTest(self, test):  # noqa
74 74
        """Called when the test case test is about to be run"""
75 75
        super(BurninTestResult, self).startTest(test)
76
        # Access to a protected member. pylint: disable-msg=W0212
77
        logger.log(test.__class__.__name__, test._testMethodDoc)
76
        logger.log(test.__class__.__name__, test.shortDescription())
78 77

  
79 78
    # Method could be a function. pylint: disable-msg=R0201
80 79
    def _test_failed(self, test, err):
81 80
        """Test failed"""
82
        # Access to a protected member. pylint: disable-msg=W0212
83
        err_msg = test._testMethodDoc + "... failed (%s)."
81
        err_msg = str(test) + "... failed (%s)."
84 82
        timestamp = datetime.datetime.strftime(
85 83
            datetime.datetime.now(), "%a %b %d %Y %H:%M:%S")
86 84
        logger.error(test.__class__.__name__, err_msg, timestamp)
......
130 128
        # Set test parameters
131 129
        cls.longMessage = True
132 130

  
133
    def test_clients_setup(self):
131
    def _setattr(self, attr, value):
132
        """Used by tests to set an attribute to TestCase
133

  
134
        Since each instance of the TestCase will only be used to run a single
135
        test method (a new fixture is created for each test) the attributes can
136
        not be saved in the class instance. Instead the class itself should be
137
        used.
138

  
139
        """
140
        setattr(self.__class__, attr, value)
141

  
142
    def test_000_clients_setup(self):
134 143
        """Initializing astakos/cyclades/pithos clients"""
135 144
        # Update class attributes
136 145
        self.info("Astakos auth url is %s", self.clients.auth_url)
......
183 192
        self.info("User's name is %s", username)
184 193
        return username
185 194

  
195
    def _get_list_of_flavors(self, detail=False):
196
        """Get (detailed) list of flavors"""
197
        if detail:
198
            self.info("Getting detailed list of flavors")
199
        else:
200
            self.info("Getting simple list of flavors")
201
        flavors = self.clients.compute.list_flavors(detail=detail)
202
        return flavors
203

  
186 204

  
187 205
# --------------------------------------------------------------------
188 206
# Initialize Burnin
......
227 245
    for tcase in testsuites:
228 246
        tsuite = unittest.TestLoader().loadTestsFromTestCase(tcase)
229 247
        results = tsuite.run(BurninTestResult())
230
        success = success and \
231
            was_successful(tcase.__name__, results.wasSuccessful())
248

  
249
        was_success = was_successful(tcase.__name__, results.wasSuccessful())
250
        success = success and was_success
232 251
        if failfast and not success:
233 252
            break
234 253

  
b/snf-tools/synnefo_tools/burnin/cyclades_tests.py
1
# Copyright 2013 GRNET S.A. All rights reserved.
2
#
3
# Redistribution and use in source and binary forms, with or
4
# without modification, are permitted provided that the following
5
# conditions are met:
6
#
7
#   1. Redistributions of source code must retain the above
8
#      copyright notice, this list of conditions and the following
9
#      disclaimer.
10
#
11
#   2. Redistributions in binary form must reproduce the above
12
#      copyright notice, this list of conditions and the following
13
#      disclaimer in the documentation and/or other materials
14
#      provided with the distribution.
15
#
16
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
# POSSIBILITY OF SUCH DAMAGE.
28
#
29
# The views and conclusions contained in the software and
30
# documentation are those of the authors and should not be
31
# interpreted as representing official policies, either expressed
32
# or implied, of GRNET S.A.
33

  
34
"""
35
This is the burnin class that tests the Cyclades functionality
36

  
37
"""
38

  
39
from synnefo_tools.burnin import common
40

  
41

  
42
# Too many public methods. pylint: disable-msg=R0904
43
class FlavorsTestSuite(common.BurninTests):
44
    """Test flavor lists for consistency"""
45
    simple_flavors = None
46
    detailed_flavors = None
47
    simple_names = None
48

  
49
    def test_001_simple_flavors(self):
50
        """Test flavor list actually returns flavors"""
51
        simple_flavors = self._get_list_of_flavors(detail=False)
52
        self._setattr("simple_flavors", simple_flavors)
53
        self.assertGreater(len(self.simple_flavors), 0)
54

  
55
    def test_002_get_detailed_flavors(self):
56
        """Test detailed flavor list is the same length as list"""
57
        detailed_flavors = self._get_list_of_flavors(detail=True)
58
        self._setattr("detailed_flavors", detailed_flavors)
59
        self.assertEquals(len(self.simple_flavors), len(self.detailed_flavors))
60

  
61
    def test_003_same_flavor_names(self):
62
        """Test detailed and simple flavor list contain same names"""
63
        simple_names = sorted([flv['name'] for flv in self.simple_flavors])
64
        self._setattr("simple_names", simple_names)
65
        detailed_names = sorted([flv['name'] for flv in self.detailed_flavors])
66
        self.assertEqual(simple_names, detailed_names)
67

  
68
    def test_004_unique_flavor_names(self):
69
        """Test flavors have unique names"""
70
        self.assertEqual(sorted(list(set(self.simple_names))),
71
                         self.simple_names)
72

  
73
    def test_005_well_formed_names(self):
74
        """Test flavors have well formed names
75

  
76
        Test flavors have names of the form CxxRyyDzz, where xx is vCPU count,
77
        yy is RAM in MiB, zz is Disk in GiB
78

  
79
        """
80
        for flv in self.detailed_flavors:
81
            flavor = (flv['vcpus'], flv['ram'], flv['disk'],
82
                      flv['SNF:disk_template'])
83
            self.assertEqual("C%dR%dD%d%s" % flavor, flv['name'],
84
                             "Flavor %s doesn't match its specs" % flv['name'])

Also available in: Unified diff