Commit 86ca098d authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis
Browse files

Merge pull request #58 from saxtouri/feature-burnin-extentions

Extend burnin with more Pithos tests

Some of these tests are time consuming and are used to stress
test both Pithos and kamaki.
parents a5d6bb05 8c18fad4
......@@ -21,12 +21,14 @@ This is the burnin class that tests the Astakos functionality
from kamaki.clients.compute import ComputeClient
from kamaki.clients import ClientError
from synnefo_tools.burnin import common
from synnefo_tools.burnin.common import BurninTests, Proper
# pylint: disable=too-many-public-methods
class AstakosTestSuite(common.BurninTests):
class AstakosTestSuite(BurninTests):
"""Test Astakos functionality"""
details = Proper(value=None)
def test_001_unauthorized_access(self):
"""Test that access without a valid token fails"""
false_token = "12345"
......@@ -51,3 +53,36 @@ class AstakosTestSuite(common.BurninTests):
self.assertIn(given_name[our_uuid], given_uuid)
self.assertEqual(given_uuid[given_name[our_uuid]], our_uuid)
def test_005_authenticate(self):
"""Test astakos.authenticate"""
astakos = self.clients.astakos
self.details = astakos.authenticate()'Check result integrity')
self.assertIn('access', self.details)
access = self.details['access']
self.assertEqual(set(('user', 'token', 'serviceCatalog')), set(access))'Top-level keys are correct')
self.assertEqual(self.clients.token, access['token']['id'])'Token is correct')
set(['roles', 'name', 'id', 'roles_links']),
set(astakos.user_info))'User section is correct')
def test_010_get_service_endpoints(self):
"""Test endpoints integrity"""
scat = self.details['access']['serviceCatalog']
types = (
'compute', 'object-store', 'identity', 'account',
'image', 'volume', 'network', 'astakos_weblogin',
'admin', 'vmapi', 'astakos_auth')
self.assertEqual(set(types), set([s['type'] for s in scat]))'All expected endpoint types (and only them) found')
astakos = self.clients.astakos
for etype in types:
endpoint = [s for s in scat
if s['type'] == etype][0]['endpoints'][0]
self.assertEqual(endpoint, astakos.get_service_endpoints(etype))'Endpoint call results match original results')
......@@ -24,6 +24,9 @@ import unittest
import datetime
import tempfile
import traceback
from tempfile import NamedTemporaryFile
from os import urandom
from string import ascii_letters
from kamaki.clients.cyclades import CycladesClient, CycladesNetworkClient
from kamaki.clients.astakos import AstakosClient, parse_endpoints
......@@ -70,7 +73,9 @@ class BurninTestResult(unittest.TestResult):
def startTest(self, test): # noqa
"""Called when the test case test is about to be run"""
super(BurninTestResult, self).startTest(test)
logger.log(test.__class__.__name__, test.shortDescription())
test.shortDescription() or 'Test %s' % test.__class__.__name__)
# pylint: disable=no-self-use
def _test_failed(self, test, err):
......@@ -208,6 +213,7 @@ class BurninTests(unittest.TestCase):
delete_stale = False
temp_directory = None
failfast = None
temp_containers = []
quotas = Proper(value=None)
uuid = Proper(value=None)
......@@ -314,6 +320,42 @@ class BurninTests(unittest.TestCase):
except OSError:
def _create_large_file(self, size):
"""Create a large file at fs"""
named_file = NamedTemporaryFile()
seg = size / 8
self.debug('Create file %s ',
for sbytes in [b * seg for b in range(size / seg)]:
return named_file
def _create_boring_file(self, num_of_blocks):
"""Create a file with some blocks being the same"""
def chargen():
"""10 + 2 * 26 + 26 = 88"""
while True:
for char in xrange(10):
yield '%s' % char
for char in ascii_letters:
yield char
for char in '~!@#$%^&*()_+`-=:";|<>?,./':
yield char
tmp_file = NamedTemporaryFile()
self.debug('\tCreate file %s ' %
block_size = 4 * 1024 * 1024
chars = chargen()
while num_of_blocks:
fslice = 3 if num_of_blocks > 3 else num_of_blocks
tmp_file.write(fslice * block_size *
num_of_blocks -= fslice
return tmp_file
def _get_uuid_of_system_user(self):
"""Get the uuid of the system user
......@@ -516,8 +558,8 @@ class BurninTests(unittest.TestCase):
assert container, "No pithos container was given""Creating pithos container %s", container)
self.clients.pithos.container = container
# ----------------------------------
# Quotas
......@@ -534,6 +576,17 @@ class BurninTests(unittest.TestCase):
@param changes: A dict of the changes that have been made in quotas
def dicts_are_equal(d1, d2):
"""Helper function to check dict equality"""
self.assertEqual(set(d1), set(d2))
for key, val in d1.items():
if isinstance(val, (list, tuple)):
self.assertEqual(set(val), set(d2[key]))
elif isinstance(val, dict):
dicts_are_equal(val, d2[key])
self.assertEqual(val, d2[key])
if not changes:
......@@ -557,7 +610,7 @@ class BurninTests(unittest.TestCase):
old_quotas[prj][q_name]['usage'] += q_value
old_quotas[prj][q_name]['project_usage'] += q_value
self.assertEqual(old_quotas, new_quotas)
dicts_are_equal(old_quotas, new_quotas)
# ----------------------------------
# Projects
......@@ -149,6 +149,7 @@ class ImagesTestSuite(BurninTests):
"""Upload the image to Pithos"""
file_size = os.path.getsize(self.temp_image_file)
with open(self.temp_image_file, "r+b") as fin:
self.clients.pithos.upload_object(self.temp_image_name, fin)
......@@ -176,10 +177,22 @@ class ImagesTestSuite(BurninTests):
self.assertEqual(len(images), 1)"Image registered with id %s", images[0]['id'])"Registering with unicode name")
uni_str = u'\u03b5\u03b9\u03ba\u03cc\u03bd\u03b1'
uni_name = u'%s, or %s in Greek' % (self.temp_image_name, uni_str)
img = self.clients.image.register(
uni_name, location, params, properties)'Checking if image with unicode name exists')
found_img = self.clients.image.get_meta(img['id'])
self.assertEqual(found_img['name'], uni_name)"Image registered with id %s", found_img['id'])
def test_010_cleanup_image(self):
"""Remove uploaded image from Pithos"""
# Remove uploaded image"Deleting uploaded image %s", self.temp_image_name)
# Verify quotas
file_size = os.path.getsize(self.temp_image_file)
......@@ -197,6 +210,7 @@ class ImagesTestSuite(BurninTests):
"""Clean up"""
if cls.temp_image_name is not None:
cls.clients.pithos.container = "burnin-images"
except ClientError:
......@@ -134,7 +134,7 @@ def _locate_input(contents, section):
# We will add our message in this location
for (index, obj) in enumerate(sect_locs):
if section in contents[obj]:
return sect_locs[index+1] - 3
return sect_locs[index + 1] - 3
# We didn't find our section??
sys.stderr.write("Section %s could not be found in logging file\n"
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