blob: d7e803ad97a571b25d9abb33f1e83d869ddc9ed5 [file] [log] [blame]
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +03001from __future__ import print_function
2
gstepanov023c1e42015-04-08 15:50:19 +03003import os
koder aka kdanilovbc2c8982015-06-13 02:50:43 +03004import re
koder aka kdanilov7acd6bd2015-02-12 14:28:30 -08005import sys
koder aka kdanilov57ce4db2015-04-25 21:25:51 +03006import time
koder aka kdanilov7acd6bd2015-02-12 14:28:30 -08007import pprint
koder aka kdanilov416b87a2015-05-12 00:26:04 +03008import signal
koder aka kdanilove21d7472015-02-14 19:02:04 -08009import logging
koder aka kdanilov7acd6bd2015-02-12 14:28:30 -080010import argparse
koder aka kdanilov168f6092015-04-19 02:33:38 +030011import functools
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +030012import contextlib
koder aka kdanilov2c473092015-03-29 17:12:13 +030013import collections
koder aka kdanilov7acd6bd2015-02-12 14:28:30 -080014
koder aka kdanilov88407ff2015-05-26 15:35:57 +030015from yaml import load as _yaml_load
16
17try:
18 from yaml import CLoader
19 yaml_load = functools.partial(_yaml_load, Loader=CLoader)
20except ImportError:
21 yaml_load = _yaml_load
22
23
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +030024import texttable
koder aka kdanilovbb5fe072015-05-21 02:50:23 +030025
26try:
27 import faulthandler
28except ImportError:
29 faulthandler = None
30
koder aka kdanilov2c473092015-03-29 17:12:13 +030031from concurrent.futures import ThreadPoolExecutor
koder aka kdanilov6c491062015-04-09 22:33:13 +030032
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +030033from wally import pretty_yaml
koder aka kdanilovf86d7af2015-05-06 04:01:54 +030034from wally.hw_info import get_hw_info
35from wally.discover import discover, Node
koder aka kdanilov63ad2062015-04-27 13:11:40 +030036from wally.timeseries import SensorDatastore
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +030037from wally import utils, report, ssh_utils, start_vms
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +030038from wally.config import (cfg_dict, load_config, setup_loggers,
koder aka kdanilov88407ff2015-05-26 15:35:57 +030039 get_test_files, save_run_params, load_run_params)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +030040from wally.sensors_utils import with_sensors_util, sensors_info_util
41
koder aka kdanilovbc2c8982015-06-13 02:50:43 +030042from wally.suits.mysql import MysqlTest
43from wally.suits.itest import TestConfig
44from wally.suits.io.fio import IOPerfTest
45from wally.suits.postgres import PgBenchTest
46
47
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +030048TOOL_TYPE_MAPPER = {
49 "io": IOPerfTest,
50 "pgbench": PgBenchTest,
51 "mysql": MysqlTest,
52}
koder aka kdanilov63ad2062015-04-27 13:11:40 +030053
koder aka kdanilov57ce4db2015-04-25 21:25:51 +030054
55try:
56 from wally import webui
57except ImportError:
58 webui = None
koder aka kdanilov2c473092015-03-29 17:12:13 +030059
60
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +030061logger = logging.getLogger("wally")
koder aka kdanilovcee43342015-04-14 22:52:53 +030062
koder aka kdanilov7acd6bd2015-02-12 14:28:30 -080063
Yulia Portnova7ddfa732015-02-24 17:32:58 +020064def format_result(res, formatter):
koder aka kdanilove21d7472015-02-14 19:02:04 -080065 data = "\n{0}\n".format("=" * 80)
66 data += pprint.pformat(res) + "\n"
67 data += "{0}\n".format("=" * 80)
koder aka kdanilovfe056622015-02-19 08:46:15 -080068 templ = "{0}\n\n====> {1}\n\n{2}\n\n"
Yulia Portnova7ddfa732015-02-24 17:32:58 +020069 return templ.format(data, formatter(res), "=" * 80)
koder aka kdanilove21d7472015-02-14 19:02:04 -080070
71
koder aka kdanilov1c2b5112015-04-10 16:53:51 +030072class Context(object):
73 def __init__(self):
74 self.build_meta = {}
75 self.nodes = []
76 self.clear_calls_stack = []
77 self.openstack_nodes_ids = []
koder aka kdanilov168f6092015-04-19 02:33:38 +030078 self.sensors_mon_q = None
koder aka kdanilovf86d7af2015-05-06 04:01:54 +030079 self.hw_info = []
koder aka kdanilov1c2b5112015-04-10 16:53:51 +030080
81
koder aka kdanilov168f6092015-04-19 02:33:38 +030082def connect_one(node, vm=False):
koder aka kdanilov0c598a12015-04-21 03:01:40 +030083 if node.conn_url == 'local':
84 node.connection = ssh_utils.connect(node.conn_url)
85 return
86
koder aka kdanilov5d589b42015-03-26 12:25:51 +020087 try:
koder aka kdanilov2c473092015-03-29 17:12:13 +030088 ssh_pref = "ssh://"
89 if node.conn_url.startswith(ssh_pref):
90 url = node.conn_url[len(ssh_pref):]
koder aka kdanilov168f6092015-04-19 02:33:38 +030091
92 if vm:
koder aka kdanilov6b1341a2015-04-21 22:44:21 +030093 conn_timeout = 240
koder aka kdanilov168f6092015-04-19 02:33:38 +030094 else:
koder aka kdanilov6b1341a2015-04-21 22:44:21 +030095 conn_timeout = 30
koder aka kdanilov168f6092015-04-19 02:33:38 +030096
97 node.connection = ssh_utils.connect(url,
koder aka kdanilov6b1341a2015-04-21 22:44:21 +030098 conn_timeout=conn_timeout)
koder aka kdanilov2c473092015-03-29 17:12:13 +030099 else:
100 raise ValueError("Unknown url type {0}".format(node.conn_url))
koder aka kdanilove87ae652015-04-20 02:14:35 +0300101 except Exception as exc:
102 # logger.exception("During connect to " + node.get_conn_id())
koder aka kdanilovec1b9732015-04-23 20:43:29 +0300103 msg = "During connect to {0}: {1!s}".format(node.get_conn_id(),
104 exc)
koder aka kdanilove87ae652015-04-20 02:14:35 +0300105 logger.error(msg)
koder aka kdanilov168f6092015-04-19 02:33:38 +0300106 node.connection = None
koder aka kdanilov5d589b42015-03-26 12:25:51 +0200107
108
koder aka kdanilov168f6092015-04-19 02:33:38 +0300109def connect_all(nodes, vm=False):
koder aka kdanilov2c473092015-03-29 17:12:13 +0300110 logger.info("Connecting to nodes")
111 with ThreadPoolExecutor(32) as pool:
koder aka kdanilov168f6092015-04-19 02:33:38 +0300112 connect_one_f = functools.partial(connect_one, vm=vm)
113 list(pool.map(connect_one_f, nodes))
koder aka kdanilov2c473092015-03-29 17:12:13 +0300114
115
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300116def collect_hw_info_stage(cfg, ctx):
117 if os.path.exists(cfg['hwreport_fname']):
118 msg = "{0} already exists. Skip hw info"
119 logger.info(msg.format(cfg['hwreport_fname']))
120 return
121
122 with ThreadPoolExecutor(32) as pool:
123 connections = (node.connection for node in ctx.nodes)
124 ctx.hw_info.extend(pool.map(get_hw_info, connections))
125
126 with open(cfg['hwreport_fname'], 'w') as hwfd:
127 for node, info in zip(ctx.nodes, ctx.hw_info):
128 hwfd.write("-" * 60 + "\n")
129 hwfd.write("Roles : " + ", ".join(node.roles) + "\n")
130 hwfd.write(str(info) + "\n")
131 hwfd.write("-" * 60 + "\n\n")
132
133 if info.hostname is not None:
134 fname = os.path.join(
135 cfg_dict['hwinfo_directory'],
136 info.hostname + "_lshw.xml")
137
138 with open(fname, "w") as fd:
139 fd.write(info.raw)
140 logger.info("Hardware report stored in " + cfg['hwreport_fname'])
141 logger.debug("Raw hardware info in " + cfg['hwinfo_directory'] + " folder")
142
143
koder aka kdanilovbc2c8982015-06-13 02:50:43 +0300144def run_single_test(test_nodes, name, params, log_directory,
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300145 test_local_folder, run_uuid):
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300146
koder aka kdanilovbc2c8982015-06-13 02:50:43 +0300147 test_cls = TOOL_TYPE_MAPPER[name]
148 test_cfg = TestConfig(test_cls.__name__,
149 params=params,
150 test_uuid=run_uuid,
151 nodes=test_nodes,
152 log_directory=log_directory,
153 remote_dir=test_local_folder.format(name=name))
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300154
koder aka kdanilovbc2c8982015-06-13 02:50:43 +0300155 test = test_cls(test_cfg)
156 return test.run()
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300157
158
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300159def suspend_vm_nodes(unused_nodes):
160 pausable_nodes_ids = [node.os_vm_id for node in unused_nodes
161 if node.os_vm_id is not None]
162 non_pausable = len(unused_nodes) - len(pausable_nodes_ids)
koder aka kdanilov2c473092015-03-29 17:12:13 +0300163
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300164 if 0 != non_pausable:
165 logger.warning("Can't pause {0} nodes".format(
166 non_pausable))
167
168 if len(pausable_nodes_ids) != 0:
169 logger.debug("Try to pause {0} unused nodes".format(
170 len(pausable_nodes_ids)))
171 start_vms.pause(pausable_nodes_ids)
172
173 return pausable_nodes_ids
174
175
176def run_tests(cfg, test_block, nodes):
koder aka kdanilov2c473092015-03-29 17:12:13 +0300177 test_nodes = [node for node in nodes
178 if 'testnode' in node.roles]
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300179
180 not_test_nodes = [node for node in nodes
181 if 'testnode' not in node.roles]
182
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300183 if len(test_nodes) == 0:
184 logger.error("No test nodes found")
185 return
186
koder aka kdanilovcee43342015-04-14 22:52:53 +0300187 for name, params in test_block.items():
koder aka kdanilovcee43342015-04-14 22:52:53 +0300188 results = []
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300189 limit = params.get('node_limit')
190 if isinstance(limit, (int, long)):
191 vm_limits = [limit]
192 elif limit is None:
193 vm_limits = [len(test_nodes)]
194 else:
195 vm_limits = limit
koder aka kdanilov652cd802015-04-13 12:21:07 +0300196
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300197 for vm_count in vm_limits:
198 if vm_count == 'all':
199 curr_test_nodes = test_nodes
200 unused_nodes = []
201 else:
202 curr_test_nodes = test_nodes[:vm_count]
203 unused_nodes = test_nodes[vm_count:]
koder aka kdanilove87ae652015-04-20 02:14:35 +0300204
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300205 if 0 == len(curr_test_nodes):
206 continue
koder aka kdanilov652cd802015-04-13 12:21:07 +0300207
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300208 # make a directory for results
209 all_tests_dirs = os.listdir(cfg_dict['results'])
210
211 if 'name' in params:
212 dir_name = "{0}_{1}".format(name, params['name'])
213 else:
214 for idx in range(len(all_tests_dirs) + 1):
215 dir_name = "{0}_{1}".format(name, idx)
216 if dir_name not in all_tests_dirs:
217 break
218 else:
219 raise utils.StopTestError(
220 "Can't select directory for test results")
221
222 dir_path = os.path.join(cfg_dict['results'], dir_name)
223 if not os.path.exists(dir_path):
224 os.mkdir(dir_path)
225
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300226 if cfg.get('suspend_unused_vms', True):
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300227 pausable_nodes_ids = suspend_vm_nodes(unused_nodes)
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300228
229 resumable_nodes_ids = [node.os_vm_id for node in curr_test_nodes
230 if node.os_vm_id is not None]
231
232 if len(resumable_nodes_ids) != 0:
233 logger.debug("Check and unpause {0} nodes".format(
234 len(resumable_nodes_ids)))
235 start_vms.unpause(resumable_nodes_ids)
236
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300237 try:
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300238 sens_nodes = curr_test_nodes + not_test_nodes
239 with sensors_info_util(cfg, sens_nodes) as sensor_data:
240 t_start = time.time()
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300241 res = run_single_test(curr_test_nodes,
242 name,
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300243 params,
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300244 dir_path,
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300245 cfg['default_test_local_folder'],
246 cfg['run_uuid'])
247 t_end = time.time()
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300248 finally:
249 if cfg.get('suspend_unused_vms', True):
250 if len(pausable_nodes_ids) != 0:
251 logger.debug("Unpausing {0} nodes".format(
252 len(pausable_nodes_ids)))
253 start_vms.unpause(pausable_nodes_ids)
254
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300255 if sensor_data is not None:
256 fname = "{0}_{1}.csv".format(int(t_start), int(t_end))
257 fpath = os.path.join(cfg['sensor_storage'], fname)
258
259 with open(fpath, "w") as fd:
260 fd.write("\n\n".join(sensor_data))
261
262 results.extend(res)
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300263
264 yield name, results
koder aka kdanilov2c473092015-03-29 17:12:13 +0300265
266
koder aka kdanilovda45e882015-04-06 02:24:42 +0300267def log_nodes_statistic(_, ctx):
268 nodes = ctx.nodes
koder aka kdanilov2c473092015-03-29 17:12:13 +0300269 logger.info("Found {0} nodes total".format(len(nodes)))
270 per_role = collections.defaultdict(lambda: 0)
271 for node in nodes:
272 for role in node.roles:
273 per_role[role] += 1
274
275 for role, count in sorted(per_role.items()):
276 logger.debug("Found {0} nodes with role {1}".format(count, role))
277
278
koder aka kdanilovda45e882015-04-06 02:24:42 +0300279def connect_stage(cfg, ctx):
280 ctx.clear_calls_stack.append(disconnect_stage)
281 connect_all(ctx.nodes)
282
koder aka kdanilov168f6092015-04-19 02:33:38 +0300283 all_ok = True
koder aka kdanilovda45e882015-04-06 02:24:42 +0300284
koder aka kdanilov168f6092015-04-19 02:33:38 +0300285 for node in ctx.nodes:
286 if node.connection is None:
287 if 'testnode' in node.roles:
288 msg = "Can't connect to testnode {0}"
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300289 msg = msg.format(node.get_conn_id())
290 logger.error(msg)
291 raise utils.StopTestError(msg)
koder aka kdanilov168f6092015-04-19 02:33:38 +0300292 else:
293 msg = "Node {0} would be excluded - can't connect"
294 logger.warning(msg.format(node.get_conn_id()))
295 all_ok = False
296
297 if all_ok:
298 logger.info("All nodes connected successfully")
299
300 ctx.nodes = [node for node in ctx.nodes
301 if node.connection is not None]
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +0300302
303
koder aka kdanilovda45e882015-04-06 02:24:42 +0300304def discover_stage(cfg, ctx):
koder aka kdanilov652cd802015-04-13 12:21:07 +0300305 if cfg.get('discover') is not None:
koder aka kdanilovda45e882015-04-06 02:24:42 +0300306 discover_objs = [i.strip() for i in cfg['discover'].strip().split(",")]
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +0300307
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300308 nodes = discover(ctx,
309 discover_objs,
310 cfg['clouds'],
311 cfg['var_dir'],
312 not cfg['dont_discover_nodes'])
koder aka kdanilov168f6092015-04-19 02:33:38 +0300313
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +0300314 ctx.nodes.extend(nodes)
koder aka kdanilovda45e882015-04-06 02:24:42 +0300315
316 for url, roles in cfg.get('explicit_nodes', {}).items():
317 ctx.nodes.append(Node(url, roles.split(",")))
318
319
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300320def save_nodes_stage(cfg, ctx):
321 cluster = {}
322 for node in ctx.nodes:
323 roles = node.roles[:]
324 if 'testnode' in roles:
325 roles.remove('testnode')
326
327 if len(roles) != 0:
328 cluster[node.conn_url] = roles
329
330 with open(cfg['nodes_report_file'], "w") as fd:
331 fd.write(pretty_yaml.dumps(cluster))
332
333
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300334def reuse_vms_stage(cfg, ctx):
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300335 p = cfg.get('clouds', {}).get('openstack', {}).get('vms', [])
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300336
337 for creds in p:
338 vm_name_pattern, conn_pattern = creds.split(",")
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300339 msg = "Vm like {0} lookup failed".format(vm_name_pattern)
340 with utils.log_error(msg):
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300341 msg = "Looking for vm with name like {0}".format(vm_name_pattern)
342 logger.debug(msg)
343
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300344 if not start_vms.is_connected():
345 os_creds = get_OS_credentials(cfg, ctx)
346 else:
347 os_creds = {}
348
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300349 conn = start_vms.nova_connect(**os_creds)
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300350 for ip, vm_id in start_vms.find_vms(conn, vm_name_pattern):
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300351 node = Node(conn_pattern.format(ip=ip), ['testnode'])
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300352 node.os_vm_id = vm_id
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300353 ctx.nodes.append(node)
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300354
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300355
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300356def get_OS_credentials(cfg, ctx):
koder aka kdanilovcee43342015-04-14 22:52:53 +0300357 creds = None
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300358 tenant = None
359
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300360 if 'openstack' in cfg['clouds']:
361 os_cfg = cfg['clouds']['openstack']
362 if 'OPENRC' in os_cfg:
363 logger.info("Using OS credentials from " + os_cfg['OPENRC'])
koder aka kdanilovbc2c8982015-06-13 02:50:43 +0300364 user, passwd, tenant, auth_url = utils.get_creds_openrc(os_cfg['OPENRC'])
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300365 elif 'ENV' in os_cfg:
366 logger.info("Using OS credentials from shell environment")
367 user, passwd, tenant, auth_url = start_vms.ostack_get_creds()
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300368 elif 'OS_TENANT_NAME' in os_cfg:
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300369 logger.info("Using predefined credentials")
koder aka kdanilov1c2b5112015-04-10 16:53:51 +0300370 tenant = os_cfg['OS_TENANT_NAME'].strip()
371 user = os_cfg['OS_USERNAME'].strip()
372 passwd = os_cfg['OS_PASSWORD'].strip()
373 auth_url = os_cfg['OS_AUTH_URL'].strip()
374
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300375 if tenant is None and 'fuel' in cfg['clouds'] and \
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300376 'openstack_env' in cfg['clouds']['fuel'] and \
377 ctx.fuel_openstack_creds is not None:
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300378 logger.info("Using fuel creds")
379 creds = ctx.fuel_openstack_creds
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300380 elif tenant is None:
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300381 logger.error("Can't found OS credentials")
382 raise utils.StopTestError("Can't found OS credentials", None)
koder aka kdanilov1c2b5112015-04-10 16:53:51 +0300383
koder aka kdanilovcee43342015-04-14 22:52:53 +0300384 if creds is None:
385 creds = {'name': user,
386 'passwd': passwd,
387 'tenant': tenant,
388 'auth_url': auth_url}
koder aka kdanilov1c2b5112015-04-10 16:53:51 +0300389
koder aka kdanilovbc2c8982015-06-13 02:50:43 +0300390 logger.debug("OS_CREDS: user={name} tenant={tenant} auth_url={auth_url}".format(**creds))
koder aka kdanilovcee43342015-04-14 22:52:53 +0300391 return creds
koder aka kdanilov4e9f3ed2015-04-14 11:26:12 +0300392
koder aka kdanilov1c2b5112015-04-10 16:53:51 +0300393
koder aka kdanilov168f6092015-04-19 02:33:38 +0300394@contextlib.contextmanager
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300395def create_vms_ctx(ctx, cfg, config, already_has_count=0):
koder aka kdanilovc368eb62015-04-28 18:22:01 +0300396 params = cfg['vm_configs'][config['cfg_name']].copy()
koder aka kdanilov168f6092015-04-19 02:33:38 +0300397 os_nodes_ids = []
398
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300399 if not start_vms.is_connected():
400 os_creds = get_OS_credentials(cfg, ctx)
401 else:
402 os_creds = {}
koder aka kdanilov168f6092015-04-19 02:33:38 +0300403 start_vms.nova_connect(**os_creds)
404
koder aka kdanilovc368eb62015-04-28 18:22:01 +0300405 params.update(config)
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300406 if 'keypair_file_private' not in params:
407 params['keypair_file_private'] = params['keypair_name'] + ".pem"
408
koder aka kdanilovc368eb62015-04-28 18:22:01 +0300409 params['group_name'] = cfg_dict['run_uuid']
410
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300411 if not config.get('skip_preparation', False):
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300412 logger.info("Preparing openstack")
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300413 start_vms.prepare_os_subpr(params=params, **os_creds)
koder aka kdanilov168f6092015-04-19 02:33:38 +0300414
415 new_nodes = []
416 try:
koder aka kdanilovbc2c8982015-06-13 02:50:43 +0300417 for new_node, node_id in start_vms.launch_vms(params, already_has_count):
koder aka kdanilov168f6092015-04-19 02:33:38 +0300418 new_node.roles.append('testnode')
419 ctx.nodes.append(new_node)
420 os_nodes_ids.append(node_id)
421 new_nodes.append(new_node)
422
423 store_nodes_in_log(cfg, os_nodes_ids)
424 ctx.openstack_nodes_ids = os_nodes_ids
425
426 yield new_nodes
427
428 finally:
429 if not cfg['keep_vm']:
430 shut_down_vms_stage(cfg, ctx)
431
432
koder aka kdanilovcee43342015-04-14 22:52:53 +0300433def run_tests_stage(cfg, ctx):
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300434 ctx.results = collections.defaultdict(lambda: [])
koder aka kdanilov1c2b5112015-04-10 16:53:51 +0300435
koder aka kdanilovcee43342015-04-14 22:52:53 +0300436 if 'tests' not in cfg:
437 return
gstepanov023c1e42015-04-08 15:50:19 +0300438
koder aka kdanilovcee43342015-04-14 22:52:53 +0300439 for group in cfg['tests']:
440
441 assert len(group.items()) == 1
442 key, config = group.items()[0]
443
444 if 'start_test_nodes' == key:
koder aka kdanilovc368eb62015-04-28 18:22:01 +0300445 if 'openstack' not in config:
446 msg = "No openstack block in config - can't spawn vm's"
447 logger.error(msg)
448 raise utils.StopTestError(msg)
449
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300450 num_test_nodes = sum(1 for node in ctx.nodes
451 if 'testnode' in node.roles)
452
453 vm_ctx = create_vms_ctx(ctx, cfg, config['openstack'],
454 num_test_nodes)
455 with vm_ctx as new_nodes:
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300456 if len(new_nodes) != 0:
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300457 logger.debug("Connecting to new nodes")
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300458 connect_all(new_nodes, True)
koder aka kdanilovcee43342015-04-14 22:52:53 +0300459
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300460 for node in new_nodes:
461 if node.connection is None:
462 msg = "Failed to connect to vm {0}"
463 raise RuntimeError(msg.format(node.get_conn_id()))
koder aka kdanilovcee43342015-04-14 22:52:53 +0300464
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300465 with with_sensors_util(cfg_dict, ctx.nodes):
466 for test_group in config.get('tests', []):
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300467 for tp, res in run_tests(cfg, test_group, ctx.nodes):
468 ctx.results[tp].extend(res)
koder aka kdanilov4500a5f2015-04-17 16:55:17 +0300469 else:
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300470 with with_sensors_util(cfg_dict, ctx.nodes):
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300471 for tp, res in run_tests(cfg, group, ctx.nodes):
472 ctx.results[tp].extend(res)
koder aka kdanilovda45e882015-04-06 02:24:42 +0300473
gstepanov023c1e42015-04-08 15:50:19 +0300474
koder aka kdanilov1c2b5112015-04-10 16:53:51 +0300475def shut_down_vms_stage(cfg, ctx):
koder aka kdanilov66839a92015-04-11 13:22:31 +0300476 vm_ids_fname = cfg_dict['vm_ids_fname']
koder aka kdanilov1c2b5112015-04-10 16:53:51 +0300477 if ctx.openstack_nodes_ids is None:
koder aka kdanilov66839a92015-04-11 13:22:31 +0300478 nodes_ids = open(vm_ids_fname).read().split()
koder aka kdanilov1c2b5112015-04-10 16:53:51 +0300479 else:
480 nodes_ids = ctx.openstack_nodes_ids
481
koder aka kdanilov652cd802015-04-13 12:21:07 +0300482 if len(nodes_ids) != 0:
483 logger.info("Removing nodes")
484 start_vms.clear_nodes(nodes_ids)
485 logger.info("Nodes has been removed")
gstepanov023c1e42015-04-08 15:50:19 +0300486
koder aka kdanilov66839a92015-04-11 13:22:31 +0300487 if os.path.exists(vm_ids_fname):
488 os.remove(vm_ids_fname)
gstepanov023c1e42015-04-08 15:50:19 +0300489
koder aka kdanilov66839a92015-04-11 13:22:31 +0300490
491def store_nodes_in_log(cfg, nodes_ids):
492 with open(cfg['vm_ids_fname'], 'w') as fd:
493 fd.write("\n".join(nodes_ids))
gstepanov023c1e42015-04-08 15:50:19 +0300494
495
496def clear_enviroment(cfg, ctx):
koder aka kdanilov66839a92015-04-11 13:22:31 +0300497 if os.path.exists(cfg_dict['vm_ids_fname']):
koder aka kdanilov1c2b5112015-04-10 16:53:51 +0300498 shut_down_vms_stage(cfg, ctx)
gstepanov023c1e42015-04-08 15:50:19 +0300499
500
koder aka kdanilovda45e882015-04-06 02:24:42 +0300501def disconnect_stage(cfg, ctx):
koder aka kdanilov652cd802015-04-13 12:21:07 +0300502 ssh_utils.close_all_sessions()
503
koder aka kdanilovda45e882015-04-06 02:24:42 +0300504 for node in ctx.nodes:
505 if node.connection is not None:
506 node.connection.close()
507
508
koder aka kdanilov66839a92015-04-11 13:22:31 +0300509def store_raw_results_stage(cfg, ctx):
510
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300511 raw_results = cfg_dict['raw_results']
koder aka kdanilov66839a92015-04-11 13:22:31 +0300512
513 if os.path.exists(raw_results):
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300514 cont = yaml_load(open(raw_results).read())
koder aka kdanilov66839a92015-04-11 13:22:31 +0300515 else:
516 cont = []
517
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300518 cont.extend(utils.yamable(ctx.results).items())
koder aka kdanilov66839a92015-04-11 13:22:31 +0300519 raw_data = pretty_yaml.dumps(cont)
520
521 with open(raw_results, "w") as fd:
522 fd.write(raw_data)
523
524
525def console_report_stage(cfg, ctx):
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300526 first_report = True
527 text_rep_fname = cfg['text_report_file']
528 with open(text_rep_fname, "w") as fd:
529 for tp, data in ctx.results.items():
530 if 'io' == tp and data is not None:
531 dinfo = report.process_disk_info(data)
532 rep = IOPerfTest.format_for_console(data, dinfo)
533 elif tp in ['mysql', 'pgbench'] and data is not None:
534 rep = MysqlTest.format_for_console(data)
535 else:
536 logger.warning("Can't generate text report for " + tp)
537 continue
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300538
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300539 fd.write(rep)
540 fd.write("\n")
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300541
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300542 if first_report:
543 logger.info("Text report were stored in " + text_rep_fname)
544 first_report = False
545
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300546 print("\n" + rep + "\n")
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300547
koder aka kdanilov66839a92015-04-11 13:22:31 +0300548
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300549def test_load_report_stage(cfg, ctx):
550 load_rep_fname = cfg['load_report_file']
551 found = False
552 for idx, (tp, data) in enumerate(ctx.results.items()):
553 if 'io' == tp and data is not None:
554 if found:
555 logger.error("Making reports for more than one " +
556 "io block isn't supported! All " +
557 "report, except first are skipped")
558 continue
559 found = True
560 report.make_load_report(idx, cfg['results'], load_rep_fname)
561
562
koder aka kdanilove87ae652015-04-20 02:14:35 +0300563def html_report_stage(cfg, ctx):
Yulia Portnova8ca20572015-04-14 14:09:39 +0300564 html_rep_fname = cfg['html_report_file']
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300565 found = False
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300566 for tp, data in ctx.results.items():
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300567 if 'io' == tp and data is not None:
568 if found:
569 logger.error("Making reports for more than one " +
570 "io block isn't supported! All " +
571 "report, except first are skipped")
572 continue
573 found = True
574 dinfo = report.process_disk_info(data)
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300575 report.make_io_report(dinfo,
576 cfg.get('comment', ''),
577 html_rep_fname,
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300578 lab_info=ctx.hw_info)
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +0300579
koder aka kdanilovda45e882015-04-06 02:24:42 +0300580
581def complete_log_nodes_statistic(cfg, ctx):
582 nodes = ctx.nodes
583 for node in nodes:
584 logger.debug(str(node))
585
586
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300587def load_data_from_file(var_dir, _, ctx):
588 raw_results = os.path.join(var_dir, 'raw_results.yaml')
589 ctx.results = {}
590 for tp, results in yaml_load(open(raw_results).read()):
591 cls = TOOL_TYPE_MAPPER[tp]
592 ctx.results[tp] = map(cls.load, results)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300593
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300594
koder aka kdanilovbc2c8982015-06-13 02:50:43 +0300595def load_data_from_path(var_dir, _, ctx):
596 ctx.results = {}
597 res_dir = os.path.join(var_dir, 'results')
598 for dir_name in os.listdir(res_dir):
599 dir_path = os.path.join(res_dir, dir_name)
600 if not os.path.isdir(dir_path):
601 continue
602 rr = re.match(r"(?P<type>[a-z]+)_\d+$", dir_name)
603 if rr is None:
604 continue
605 tp = rr.group('type')
606 arr = ctx.results.setdefault(tp, [])
607 arr.extend(TOOL_TYPE_MAPPER[tp].load(dir_path))
608
609
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300610def load_data_from(var_dir):
koder aka kdanilovbc2c8982015-06-13 02:50:43 +0300611 return functools.partial(load_data_from_path, var_dir)
koder aka kdanilov57ce4db2015-04-25 21:25:51 +0300612
613
koder aka kdanilovcee43342015-04-14 22:52:53 +0300614def parse_args(argv):
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +0300615 descr = "Disk io performance test suite"
616 parser = argparse.ArgumentParser(prog='wally', description=descr)
koder aka kdanilovcee43342015-04-14 22:52:53 +0300617
618 parser.add_argument("-l", dest='extra_logs',
619 action='store_true', default=False,
620 help="print some extra log info")
koder aka kdanilovcee43342015-04-14 22:52:53 +0300621 parser.add_argument("-b", '--build_description',
622 type=str, default="Build info")
623 parser.add_argument("-i", '--build_id', type=str, default="id")
624 parser.add_argument("-t", '--build_type', type=str, default="GA")
625 parser.add_argument("-u", '--username', type=str, default="admin")
koder aka kdanilove87ae652015-04-20 02:14:35 +0300626 parser.add_argument("-n", '--no-tests', action='store_true',
627 help="Don't run tests", default=False)
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +0300628 parser.add_argument("-p", '--post-process-only', metavar="VAR_DIR",
629 help="Only process data from previour run")
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300630 parser.add_argument("-x", '--xxx', action='store_true')
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +0300631 parser.add_argument("-k", '--keep-vm', action='store_true',
632 help="Don't remove test vm's", default=False)
koder aka kdanilove87ae652015-04-20 02:14:35 +0300633 parser.add_argument("-d", '--dont-discover-nodes', action='store_true',
634 help="Don't connect/discover fuel nodes",
635 default=False)
koder aka kdanilova047e1b2015-04-21 23:16:59 +0300636 parser.add_argument("-r", '--no-html-report', action='store_true',
637 help="Skip html report", default=False)
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300638 parser.add_argument("--params", metavar="testname.paramname",
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300639 help="Test params", default=[])
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300640 parser.add_argument("--ls", action='store_true', default=False)
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300641 parser.add_argument("-c", "--comment", default="")
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +0300642 parser.add_argument("config_file")
koder aka kdanilovcee43342015-04-14 22:52:53 +0300643
644 return parser.parse_args(argv[1:])
645
646
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300647def get_stage_name(func):
koder aka kdanilov7248c7b2015-05-31 22:53:03 +0300648 nm = get_func_name(func)
649 if nm.endswith("stage"):
650 return nm
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300651 else:
koder aka kdanilov7248c7b2015-05-31 22:53:03 +0300652 return nm + " stage"
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300653
654
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300655def get_test_names(raw_res):
656 res = set()
657 for tp, data in raw_res:
658 for block in data:
659 res.add("{0}({1})".format(tp, block.get('test_name', '-')))
660 return res
koder aka kdanilovbb5fe072015-05-21 02:50:23 +0300661
662
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300663def list_results(path):
664 results = []
665
666 for dname in os.listdir(path):
667
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300668 files_cfg = get_test_files(os.path.join(path, dname))
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300669
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300670 if not os.path.isfile(files_cfg['raw_results']):
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300671 continue
672
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300673 mt = os.path.getmtime(files_cfg['raw_results'])
674 res_mtime = time.ctime(mt)
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300675
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300676 raw_res = yaml_load(open(files_cfg['raw_results']).read())
677 test_names = ",".join(sorted(get_test_names(raw_res)))
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300678
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300679 params = load_run_params(files_cfg['run_params_file'])
koder aka kdanilovbb5fe072015-05-21 02:50:23 +0300680
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300681 comm = params.get('comment')
682 results.append((mt, dname, test_names, res_mtime,
683 '-' if comm is None else comm))
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300684
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300685 tab = texttable.Texttable(max_width=200)
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300686 tab.set_deco(tab.HEADER | tab.VLINES | tab.BORDER)
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300687 tab.set_cols_align(["l", "l", "l", "l"])
688 results.sort()
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300689
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300690 for data in results[::-1]:
691 tab.add_row(data[1:])
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300692
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300693 tab.header(["Name", "Tests", "etime", "Comment"])
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300694
695 print(tab.draw())
696
697
koder aka kdanilov7248c7b2015-05-31 22:53:03 +0300698def get_func_name(obj):
699 if hasattr(obj, '__name__'):
700 return obj.__name__
701 if hasattr(obj, 'func_name'):
702 return obj.func_name
703 return obj.func.func_name
704
705
706@contextlib.contextmanager
707def log_stage(func):
708 msg_templ = "Exception during {0}: {1!s}"
709 msg_templ_no_exc = "During {0}"
710
711 logger.info("Start " + get_stage_name(func))
712
713 try:
714 yield
715 except utils.StopTestError as exc:
716 logger.error(msg_templ.format(
717 get_func_name(func), exc))
718 except Exception:
719 logger.exception(msg_templ_no_exc.format(
720 get_func_name(func)))
721
722
koder aka kdanilov3f356262015-02-13 08:06:14 -0800723def main(argv):
koder aka kdanilovbb5fe072015-05-21 02:50:23 +0300724 if faulthandler is not None:
725 faulthandler.register(signal.SIGUSR1, all_threads=True)
726
koder aka kdanilove06762a2015-03-22 23:32:09 +0200727 opts = parse_args(argv)
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300728
729 if opts.ls:
730 list_results(opts.config_file)
731 exit(0)
732
733 data_dir = load_config(opts.config_file, opts.post_process_only)
734
735 if opts.post_process_only is None:
736 cfg_dict['comment'] = opts.comment
737 save_run_params()
koder aka kdanilov2c473092015-03-29 17:12:13 +0300738
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300739 if cfg_dict.get('logging', {}).get("extra_logs", False) or opts.extra_logs:
740 level = logging.DEBUG
741 else:
742 level = logging.WARNING
743
744 setup_loggers(level, cfg_dict['log_file'])
745
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300746 if not os.path.exists(cfg_dict['saved_config_file']):
747 with open(cfg_dict['saved_config_file'], 'w') as fd:
748 fd.write(open(opts.config_file).read())
749
koder aka kdanilov66839a92015-04-11 13:22:31 +0300750 if opts.post_process_only is not None:
751 stages = [
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300752 load_data_from(data_dir)
koder aka kdanilov66839a92015-04-11 13:22:31 +0300753 ]
754 else:
755 stages = [
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300756 discover_stage
757 ]
758
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300759 stages.extend([
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300760 reuse_vms_stage,
koder aka kdanilov66839a92015-04-11 13:22:31 +0300761 log_nodes_statistic,
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300762 save_nodes_stage,
763 connect_stage])
764
765 if cfg_dict.get('collect_info', True):
766 stages.append(collect_hw_info_stage)
767
768 stages.extend([
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300769 # deploy_sensors_stage,
koder aka kdanilov66839a92015-04-11 13:22:31 +0300770 run_tests_stage,
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300771 store_raw_results_stage,
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300772 # gather_sensors_stage
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300773 ])
koder aka kdanilov66839a92015-04-11 13:22:31 +0300774
koder aka kdanilove87ae652015-04-20 02:14:35 +0300775 report_stages = [
776 console_report_stage,
koder aka kdanilove87ae652015-04-20 02:14:35 +0300777 ]
778
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300779 if opts.xxx:
780 report_stages.append(test_load_report_stage)
781 elif not opts.no_html_report:
koder aka kdanilova047e1b2015-04-21 23:16:59 +0300782 report_stages.append(html_report_stage)
783
koder aka kdanilov652cd802015-04-13 12:21:07 +0300784 logger.info("All info would be stored into {0}".format(
785 cfg_dict['var_dir']))
gstepanovcd256d62015-04-07 17:47:32 +0300786
koder aka kdanilovda45e882015-04-06 02:24:42 +0300787 ctx = Context()
gstepanovaffcdb12015-04-07 17:18:29 +0300788 ctx.build_meta['build_id'] = opts.build_id
789 ctx.build_meta['build_descrption'] = opts.build_description
790 ctx.build_meta['build_type'] = opts.build_type
791 ctx.build_meta['username'] = opts.username
koder aka kdanilov57ce4db2015-04-25 21:25:51 +0300792 ctx.sensors_data = SensorDatastore()
koder aka kdanilove87ae652015-04-20 02:14:35 +0300793
koder aka kdanilov168f6092015-04-19 02:33:38 +0300794 cfg_dict['keep_vm'] = opts.keep_vm
koder aka kdanilove87ae652015-04-20 02:14:35 +0300795 cfg_dict['no_tests'] = opts.no_tests
796 cfg_dict['dont_discover_nodes'] = opts.dont_discover_nodes
koder aka kdanilov6c491062015-04-09 22:33:13 +0300797
koder aka kdanilov7248c7b2015-05-31 22:53:03 +0300798 for stage in stages:
799 ok = False
800 with log_stage(stage):
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300801 logger.info("Start " + get_stage_name(stage))
koder aka kdanilovda45e882015-04-06 02:24:42 +0300802 stage(cfg_dict, ctx)
koder aka kdanilov7248c7b2015-05-31 22:53:03 +0300803 ok = True
804 if not ok:
805 break
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300806
koder aka kdanilov7248c7b2015-05-31 22:53:03 +0300807 exc, cls, tb = sys.exc_info()
808 for stage in ctx.clear_calls_stack[::-1]:
809 with log_stage(stage):
810 stage(cfg_dict, ctx)
811
812 logger.debug("Start utils.cleanup")
813 for clean_func, args, kwargs in utils.iter_clean_func():
814 with log_stage(clean_func):
815 clean_func(*args, **kwargs)
koder aka kdanilov2c473092015-03-29 17:12:13 +0300816
koder aka kdanilove2de58c2015-04-24 22:59:36 +0300817 if exc is None:
818 for report_stage in report_stages:
koder aka kdanilov7248c7b2015-05-31 22:53:03 +0300819 with log_stage(report_stage):
820 report_stage(cfg_dict, ctx)
koder aka kdanilove87ae652015-04-20 02:14:35 +0300821
822 logger.info("All info stored in {0} folder".format(cfg_dict['var_dir']))
koder aka kdanilove2de58c2015-04-24 22:59:36 +0300823
824 if exc is None:
825 logger.info("Tests finished successfully")
826 return 0
827 else:
828 logger.error("Tests are failed. See detailed error above")
829 return 1