Commit 89cf47aa authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis
Browse files

burnin: Add FlavorsTestSuite

parent eac6d07c
...@@ -42,12 +42,14 @@ import optparse ...@@ -42,12 +42,14 @@ import optparse
from synnefo_tools import version from synnefo_tools import version
from synnefo_tools.burnin import common from synnefo_tools.burnin import common
from synnefo_tools.burnin.astakos_tests import AstakosTestSuite from synnefo_tools.burnin.astakos_tests import AstakosTestSuite
from synnefo_tools.burnin.cyclades_tests import FlavorsTestSuite
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# Define our TestSuites # Define our TestSuites
TESTSUITES = [ TESTSUITES = [
AstakosTestSuite AstakosTestSuite,
FlavorsTestSuite
] ]
TSUITES_NAMES = [tsuite.__name__ for tsuite in TESTSUITES] TSUITES_NAMES = [tsuite.__name__ for tsuite in TESTSUITES]
......
...@@ -42,10 +42,10 @@ from kamaki.clients import ClientError ...@@ -42,10 +42,10 @@ from kamaki.clients import ClientError
from synnefo_tools.burnin import common from synnefo_tools.burnin import common
# Too many public methods (47/20). pylint: disable-msg=R0904 # Too many public methods. pylint: disable-msg=R0904
class AstakosTestSuite(common.BurninTests): class AstakosTestSuite(common.BurninTests):
"""Test Astakos functionality""" """Test Astakos functionality"""
def test_unauthorized_access(self): def test_001_unauthorized_access(self):
"""Test that access without a valid token fails""" """Test that access without a valid token fails"""
false_token = "12345" false_token = "12345"
self.info("Will use token %s", false_token) self.info("Will use token %s", false_token)
...@@ -56,7 +56,7 @@ class AstakosTestSuite(common.BurninTests): ...@@ -56,7 +56,7 @@ class AstakosTestSuite(common.BurninTests):
client.list_servers() client.list_servers()
self.assertEqual(cl_error.exception.status, 401) self.assertEqual(cl_error.exception.status, 401)
def test_name2uuid(self): def test_002_name2uuid(self):
"""Test that usernames2uuids and uuids2usernames are complementary""" """Test that usernames2uuids and uuids2usernames are complementary"""
our_uuid = self._get_uuid() our_uuid = self._get_uuid()
......
...@@ -73,14 +73,12 @@ class BurninTestResult(unittest.TestResult): ...@@ -73,14 +73,12 @@ class BurninTestResult(unittest.TestResult):
def startTest(self, test): # noqa def startTest(self, test): # noqa
"""Called when the test case test is about to be run""" """Called when the test case test is about to be run"""
super(BurninTestResult, self).startTest(test) super(BurninTestResult, self).startTest(test)
# Access to a protected member. pylint: disable-msg=W0212 logger.log(test.__class__.__name__, test.shortDescription())
logger.log(test.__class__.__name__, test._testMethodDoc)
# Method could be a function. pylint: disable-msg=R0201 # Method could be a function. pylint: disable-msg=R0201
def _test_failed(self, test, err): def _test_failed(self, test, err):
"""Test failed""" """Test failed"""
# Access to a protected member. pylint: disable-msg=W0212 err_msg = str(test) + "... failed (%s)."
err_msg = test._testMethodDoc + "... failed (%s)."
timestamp = datetime.datetime.strftime( timestamp = datetime.datetime.strftime(
datetime.datetime.now(), "%a %b %d %Y %H:%M:%S") datetime.datetime.now(), "%a %b %d %Y %H:%M:%S")
logger.error(test.__class__.__name__, err_msg, timestamp) logger.error(test.__class__.__name__, err_msg, timestamp)
...@@ -130,7 +128,18 @@ class BurninTests(unittest.TestCase): ...@@ -130,7 +128,18 @@ class BurninTests(unittest.TestCase):
# Set test parameters # Set test parameters
cls.longMessage = True cls.longMessage = True
def test_clients_setup(self): def _setattr(self, attr, value):
"""Used by tests to set an attribute to TestCase
Since each instance of the TestCase will only be used to run a single
test method (a new fixture is created for each test) the attributes can
not be saved in the class instance. Instead the class itself should be
used.
"""
setattr(self.__class__, attr, value)
def test_000_clients_setup(self):
"""Initializing astakos/cyclades/pithos clients""" """Initializing astakos/cyclades/pithos clients"""
# Update class attributes # Update class attributes
self.info("Astakos auth url is %s", self.clients.auth_url) self.info("Astakos auth url is %s", self.clients.auth_url)
...@@ -183,6 +192,15 @@ class BurninTests(unittest.TestCase): ...@@ -183,6 +192,15 @@ class BurninTests(unittest.TestCase):
self.info("User's name is %s", username) self.info("User's name is %s", username)
return username return username
def _get_list_of_flavors(self, detail=False):
"""Get (detailed) list of flavors"""
if detail:
self.info("Getting detailed list of flavors")
else:
self.info("Getting simple list of flavors")
flavors = self.clients.compute.list_flavors(detail=detail)
return flavors
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# Initialize Burnin # Initialize Burnin
...@@ -227,8 +245,9 @@ def run(testsuites, failfast=False, final_report=False): ...@@ -227,8 +245,9 @@ def run(testsuites, failfast=False, final_report=False):
for tcase in testsuites: for tcase in testsuites:
tsuite = unittest.TestLoader().loadTestsFromTestCase(tcase) tsuite = unittest.TestLoader().loadTestsFromTestCase(tcase)
results = tsuite.run(BurninTestResult()) results = tsuite.run(BurninTestResult())
success = success and \
was_successful(tcase.__name__, results.wasSuccessful()) was_success = was_successful(tcase.__name__, results.wasSuccessful())
success = success and was_success
if failfast and not success: if failfast and not success:
break break
......
# Copyright 2013 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
"""
This is the burnin class that tests the Cyclades functionality
"""
from synnefo_tools.burnin import common
# Too many public methods. pylint: disable-msg=R0904
class FlavorsTestSuite(common.BurninTests):
"""Test flavor lists for consistency"""
simple_flavors = None
detailed_flavors = None
simple_names = None
def test_001_simple_flavors(self):
"""Test flavor list actually returns flavors"""
simple_flavors = self._get_list_of_flavors(detail=False)
self._setattr("simple_flavors", simple_flavors)
self.assertGreater(len(self.simple_flavors), 0)
def test_002_get_detailed_flavors(self):
"""Test detailed flavor list is the same length as list"""
detailed_flavors = self._get_list_of_flavors(detail=True)
self._setattr("detailed_flavors", detailed_flavors)
self.assertEquals(len(self.simple_flavors), len(self.detailed_flavors))
def test_003_same_flavor_names(self):
"""Test detailed and simple flavor list contain same names"""
simple_names = sorted([flv['name'] for flv in self.simple_flavors])
self._setattr("simple_names", simple_names)
detailed_names = sorted([flv['name'] for flv in self.detailed_flavors])
self.assertEqual(simple_names, detailed_names)
def test_004_unique_flavor_names(self):
"""Test flavors have unique names"""
self.assertEqual(sorted(list(set(self.simple_names))),
self.simple_names)
def test_005_well_formed_names(self):
"""Test flavors have well formed names
Test flavors have names of the form CxxRyyDzz, where xx is vCPU count,
yy is RAM in MiB, zz is Disk in GiB
"""
for flv in self.detailed_flavors:
flavor = (flv['vcpus'], flv['ram'], flv['disk'],
flv['SNF:disk_template'])
self.assertEqual("C%dR%dD%d%s" % flavor, flv['name'],
"Flavor %s doesn't match its specs" % flv['name'])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment