Revision 79a5c431 snf-tools/synnefo_tools/burnin/common.py
b/snf-tools/synnefo_tools/burnin/common.py | ||
---|---|---|
49 | 49 |
|
50 | 50 |
from kamaki.clients.astakos import AstakosClient |
51 | 51 |
from kamaki.clients.compute import ComputeClient |
52 |
from kamaki.clients.pithos import PithosClient |
|
52 | 53 |
|
53 | 54 |
from synnefo_tools.burnin.logger import Log |
54 | 55 |
|
... | ... | |
78 | 79 |
# Method could be a function. pylint: disable-msg=R0201 |
79 | 80 |
def _test_failed(self, test, err): |
80 | 81 |
"""Test failed""" |
82 |
# Get class name |
|
83 |
if test.__class__.__name__ == "_ErrorHolder": |
|
84 |
class_name = test.id().split('.')[-1].rstrip(')') |
|
85 |
else: |
|
86 |
class_name = test.__class__.__name__ |
|
81 | 87 |
err_msg = str(test) + "... failed (%s)." |
82 | 88 |
timestamp = datetime.datetime.strftime( |
83 | 89 |
datetime.datetime.now(), "%a %b %d %Y %H:%M:%S") |
84 |
logger.error(test.__class__.__name__, err_msg, timestamp)
|
|
90 |
logger.error(class_name, err_msg, timestamp)
|
|
85 | 91 |
(err_type, err_value, err_trace) = err |
86 | 92 |
trcback = traceback.format_exception(err_type, err_value, err_trace) |
87 |
logger.info(test.__class__.__name__, trcback)
|
|
93 |
logger.info(class_name, trcback)
|
|
88 | 94 |
|
89 | 95 |
def addError(self, test, err): # noqa |
90 | 96 |
"""Called when the test case test raises an unexpected exception""" |
... | ... | |
104 | 110 |
"""Our kamaki clients""" |
105 | 111 |
auth_url = None |
106 | 112 |
token = None |
107 |
|
|
113 |
# Astakos |
|
108 | 114 |
astakos = None |
109 | 115 |
retry = CONNECTION_RETRY_LIMIT |
110 |
|
|
116 |
# Compute |
|
111 | 117 |
compute = None |
112 | 118 |
compute_url = None |
119 |
# Cyclades |
|
120 |
cyclades = None |
|
121 |
# Pithos |
|
122 |
pithos = None |
|
123 |
pithos_url = None |
|
113 | 124 |
|
114 | 125 |
|
115 | 126 |
# Too many public methods (45/20). pylint: disable-msg=R0904 |
116 | 127 |
class BurninTests(unittest.TestCase): |
117 | 128 |
"""Common class that all burnin tests should implement""" |
118 | 129 |
clients = Clients() |
119 |
opts = None |
|
120 | 130 |
run_id = None |
131 |
use_ipv6 = None |
|
132 |
action_timeout = None |
|
133 |
action_warning = None |
|
134 |
query_interval = None |
|
121 | 135 |
|
122 | 136 |
@classmethod |
123 | 137 |
def setUpClass(cls): # noqa |
... | ... | |
154 | 168 |
self.clients.compute_url, self.clients.token) |
155 | 169 |
self.clients.compute.CONNECTION_RETRY_LIMIT = self.clients.retry |
156 | 170 |
|
171 |
self.clients.pithos_url = self.clients.astakos.\ |
|
172 |
get_service_endpoints('object-store')['publicURL'] |
|
173 |
self.info("Pithos url is %s", self.clients.pithos_url) |
|
174 |
self.clients.pithos = PithosClient( |
|
175 |
self.clients.pithos_url, self.clients.token) |
|
176 |
self.clients.pithos.CONNECTION_RETRY_LIMIT = self.clients.retry |
|
177 |
|
|
157 | 178 |
# ---------------------------------- |
158 | 179 |
# Loggers helper functions |
159 | 180 |
def log(self, msg, *args): |
... | ... | |
201 | 222 |
flavors = self.clients.compute.list_flavors(detail=detail) |
202 | 223 |
return flavors |
203 | 224 |
|
225 |
def _set_pithos_account(self, account): |
|
226 |
"""Set the pithos account""" |
|
227 |
assert account, "No pithos account was given" |
|
228 |
|
|
229 |
self.info("Setting pithos account to %s", account) |
|
230 |
self.clients.pithos.account = account |
|
231 |
|
|
232 |
def _get_list_of_containers(self, account=None): |
|
233 |
"""Get list of containers""" |
|
234 |
if account is not None: |
|
235 |
self._set_pithos_account(account) |
|
236 |
self.info("Getting list of containers") |
|
237 |
return self.clients.pithos.list_containers() |
|
238 |
|
|
239 |
def _create_pithos_container(self, container): |
|
240 |
"""Create a pithos container |
|
241 |
|
|
242 |
If the container exists, nothing will happen |
|
243 |
|
|
244 |
""" |
|
245 |
assert container, "No pithos container was given" |
|
246 |
|
|
247 |
self.info("Creating pithos container %s", container) |
|
248 |
self.clients.pithos.container = container |
|
249 |
self.clients.pithos.container_put() |
|
250 |
|
|
204 | 251 |
|
205 | 252 |
# -------------------------------------------------------------------- |
206 | 253 |
# Initialize Burnin |
... | ... | |
221 | 268 |
Clients.token = opts.token |
222 | 269 |
|
223 | 270 |
# Pass the rest options to BurninTests |
224 |
BurninTests.opts = opts |
|
225 |
BurninTests.run_id = datetime.datetime.strftime( |
|
226 |
datetime.datetime.now(), "%Y%m%d%H%M%S") |
|
271 |
BurninTests.use_ipv6 = opts.use_ipv6 |
|
272 |
BurninTests.action_timeout = opts.action_timeout |
|
273 |
BurninTests.action_warning = opts.action_warning |
|
274 |
BurninTests.query_interval = opts.query_interval |
|
275 |
BurninTests.run_id = SNF_TEST_PREFIX + \ |
|
276 |
datetime.datetime.strftime(datetime.datetime.now(), "%Y%m%d%H%M%S") |
|
227 | 277 |
|
228 | 278 |
# Choose tests to run |
229 | 279 |
if opts.tests != "all": |
Also available in: Unified diff