Revision 70f14042
b/snf-tools/synnefo_tools/burnin/__init__.py | ||
---|---|---|
41 | 41 |
|
42 | 42 |
from synnefo_tools import version |
43 | 43 |
from synnefo_tools.burnin import common |
44 |
from synnefo_tools.burnin.astakos_tests import AstakosTestCase, AstakosFoo
|
|
44 |
from synnefo_tools.burnin.astakos_tests import AstakosTestSuite
|
|
45 | 45 |
|
46 | 46 |
|
47 | 47 |
# -------------------------------------------------------------------- |
48 | 48 |
# Define our TestSuites |
49 | 49 |
TESTSUITES = [ |
50 |
AstakosTestCase, AstakosFoo
|
|
50 |
AstakosTestSuite
|
|
51 | 51 |
] |
52 | 52 |
|
53 | 53 |
TSUITES_NAMES = [tsuite.__name__ for tsuite in TESTSUITES] |
b/snf-tools/synnefo_tools/burnin/astakos_tests.py | ||
---|---|---|
43 | 43 |
|
44 | 44 |
|
45 | 45 |
# Too many public methods (47/20). pylint: disable-msg=R0904 |
46 |
class AstakosTestCase(common.BurninTests):
|
|
46 |
class AstakosTestSuite(common.BurninTests):
|
|
47 | 47 |
"""Test Astakos functionality""" |
48 | 48 |
def test_unauthorized_access(self): |
49 |
"""Test access without a valid token fails""" |
|
49 |
"""Test that access without a valid token fails"""
|
|
50 | 50 |
false_token = "12345" |
51 |
self.info("Will use token %s", false_token) |
|
51 | 52 |
client = ComputeClient(self.clients.compute_url, false_token) |
52 | 53 |
client.CONNECTION_RETRY_LIMIT = self.clients.retry |
53 | 54 |
|
... | ... | |
55 | 56 |
client.list_servers() |
56 | 57 |
self.assertEqual(cl_error.exception.status, 401) |
57 | 58 |
|
59 |
def test_name2uuid(self): |
|
60 |
"""Test that usernames2uuids and uuids2usernames are complementary""" |
|
61 |
our_uuid = self._get_uuid() |
|
58 | 62 |
|
59 |
class AstakosFoo(common.BurninTests): |
|
60 |
"""Just Fail""" |
|
61 |
def test_just_foo(self): |
|
62 |
"""A test that just fails""" |
|
63 |
self.fail("just fail") |
|
63 |
given_name = self.clients.astakos.uuids2usernames([our_uuid]) |
|
64 |
self.info("uuids2usernames returned %s", given_name) |
|
65 |
self.assertIn(our_uuid, given_name) |
|
66 |
|
|
67 |
given_uuid = \ |
|
68 |
self.clients.astakos.usernames2uuids([given_name[our_uuid]]) |
|
69 |
self.info("usernames2uuids returned %s", given_uuid) |
|
70 |
self.assertIn(given_name[our_uuid], given_uuid) |
|
71 |
|
|
72 |
self.assertEqual(given_uuid[given_name[our_uuid]], our_uuid) |
b/snf-tools/synnefo_tools/burnin/common.py | ||
---|---|---|
37 | 37 |
""" |
38 | 38 |
|
39 | 39 |
import sys |
40 |
import datetime |
|
40 | 41 |
import traceback |
41 | 42 |
# Use backported unittest functionality if Python < 2.7 |
42 | 43 |
try: |
... | ... | |
79 | 80 |
def _test_failed(self, test, err): |
80 | 81 |
"""Test failed""" |
81 | 82 |
# Access to a protected member. pylint: disable-msg=W0212 |
82 |
err_msg = test._testMethodDoc + "... failed." |
|
83 |
logger.error(test.__class__.__name__, err_msg) |
|
83 |
err_msg = test._testMethodDoc + "... failed (%s)." |
|
84 |
timestamp = datetime.datetime.strftime( |
|
85 |
datetime.datetime.now(), "%a %b %d %Y %H:%M:%S") |
|
86 |
logger.error(test.__class__.__name__, err_msg, timestamp) |
|
84 | 87 |
(err_type, err_value, err_trace) = err |
85 | 88 |
trcback = traceback.format_exception(err_type, err_value, err_trace) |
86 | 89 |
logger.info(test.__class__.__name__, trcback) |
... | ... | |
116 | 119 |
"""Common class that all burnin tests should implement""" |
117 | 120 |
clients = Clients() |
118 | 121 |
opts = None |
122 |
run_id = None |
|
119 | 123 |
|
120 | 124 |
@classmethod |
121 | 125 |
def setUpClass(cls): # noqa |
... | ... | |
141 | 145 |
self.clients.compute_url, self.clients.token) |
142 | 146 |
self.clients.compute.CONNECTION_RETRY_LIMIT = self.clients.retry |
143 | 147 |
|
148 |
# ---------------------------------- |
|
149 |
# Loggers helper functions |
|
144 | 150 |
def log(self, msg, *args): |
145 | 151 |
"""Pass the section value to logger""" |
146 | 152 |
logger.log(self.suite_name, msg, *args) |
... | ... | |
161 | 167 |
"""Pass the section value to logger""" |
162 | 168 |
logger.error(self.suite_name, msg, *args) |
163 | 169 |
|
170 |
# ---------------------------------- |
|
171 |
# Helper functions that every testsuite may need |
|
172 |
def _get_uuid(self): |
|
173 |
"""Get our uuid""" |
|
174 |
authenticate = self.clients.astakos.authenticate() |
|
175 |
uuid = authenticate['access']['user']['id'] |
|
176 |
self.info("User's uuid is %s", uuid) |
|
177 |
return uuid |
|
178 |
|
|
179 |
def _get_username(self): |
|
180 |
"""Get our User Name""" |
|
181 |
authenticate = self.clients.astakos.authenticate() |
|
182 |
username = authenticate['access']['user']['name'] |
|
183 |
self.info("User's name is %s", username) |
|
184 |
return username |
|
185 |
|
|
164 | 186 |
|
165 | 187 |
# -------------------------------------------------------------------- |
166 | 188 |
# Initialize Burnin |
... | ... | |
182 | 204 |
|
183 | 205 |
# Pass the rest options to BurninTests |
184 | 206 |
BurninTests.opts = opts |
207 |
BurninTests.run_id = datetime.datetime.strftime( |
|
208 |
datetime.datetime.now(), "%Y%m%d%H%M%S") |
|
185 | 209 |
|
186 | 210 |
# Choose tests to run |
187 | 211 |
if opts.tests != "all": |
Also available in: Unified diff