koder aka kdanilov | 4643fd6 | 2015-02-10 16:20:13 -0800 | [diff] [blame] | 1 | import abc |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 2 | import time |
koder aka kdanilov | 783b454 | 2015-04-23 18:57:04 +0300 | [diff] [blame] | 3 | import socket |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 4 | import random |
koder aka kdanilov | 4643fd6 | 2015-02-10 16:20:13 -0800 | [diff] [blame] | 5 | import os.path |
koder aka kdanilov | e21d747 | 2015-02-14 19:02:04 -0800 | [diff] [blame] | 6 | import logging |
koder aka kdanilov | ea22c3d | 2015-04-21 03:42:22 +0300 | [diff] [blame] | 7 | import datetime |
koder aka kdanilov | e21d747 | 2015-02-14 19:02:04 -0800 | [diff] [blame] | 8 | |
koder aka kdanilov | a855f90 | 2015-04-26 14:31:45 +0300 | [diff] [blame] | 9 | from paramiko import SSHException, SFTPError |
Yulia Portnova | b1a1507 | 2015-05-06 14:59:25 +0300 | [diff] [blame] | 10 | import texttable |
koder aka kdanilov | 783b454 | 2015-04-23 18:57:04 +0300 | [diff] [blame] | 11 | |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 12 | from wally.utils import (ssize2b, open_for_append_or_create, |
koder aka kdanilov | e2de58c | 2015-04-24 22:59:36 +0300 | [diff] [blame] | 13 | sec_to_str, StopTestError) |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 14 | |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 15 | from wally.ssh_utils import (copy_paths, run_over_ssh, |
koder aka kdanilov | abd6ead | 2015-04-24 02:03:07 +0300 | [diff] [blame] | 16 | save_to_remote, |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 17 | # delete_file, |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 18 | connect, read_from_remote, Local, |
| 19 | exists) |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 20 | |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 21 | from . import postgres |
Yulia Portnova | b1a1507 | 2015-05-06 14:59:25 +0300 | [diff] [blame] | 22 | from . import mysql |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 23 | from .io import agent as io_agent |
| 24 | from .io import formatter as io_formatter |
| 25 | from .io.results_loader import parse_output |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 26 | |
koder aka kdanilov | 4643fd6 | 2015-02-10 16:20:13 -0800 | [diff] [blame] | 27 | |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 28 | logger = logging.getLogger("wally") |
koder aka kdanilov | e21d747 | 2015-02-14 19:02:04 -0800 | [diff] [blame] | 29 | |
| 30 | |
koder aka kdanilov | 4643fd6 | 2015-02-10 16:20:13 -0800 | [diff] [blame] | 31 | class IPerfTest(object): |
koder aka kdanilov | abd6ead | 2015-04-24 02:03:07 +0300 | [diff] [blame] | 32 | def __init__(self, options, is_primary, on_result_cb, test_uuid, node, |
koder aka kdanilov | 2066daf | 2015-04-23 21:05:41 +0300 | [diff] [blame] | 33 | log_directory=None, |
| 34 | coordination_queue=None, |
| 35 | remote_dir="/tmp/wally"): |
koder aka kdanilov | abd6ead | 2015-04-24 02:03:07 +0300 | [diff] [blame] | 36 | self.options = options |
koder aka kdanilov | 4643fd6 | 2015-02-10 16:20:13 -0800 | [diff] [blame] | 37 | self.on_result_cb = on_result_cb |
koder aka kdanilov | 4500a5f | 2015-04-17 16:55:17 +0300 | [diff] [blame] | 38 | self.log_directory = log_directory |
| 39 | self.node = node |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 40 | self.test_uuid = test_uuid |
koder aka kdanilov | ec1b973 | 2015-04-23 20:43:29 +0300 | [diff] [blame] | 41 | self.coordination_queue = coordination_queue |
koder aka kdanilov | 2066daf | 2015-04-23 21:05:41 +0300 | [diff] [blame] | 42 | self.remote_dir = remote_dir |
koder aka kdanilov | abd6ead | 2015-04-24 02:03:07 +0300 | [diff] [blame] | 43 | self.is_primary = is_primary |
koder aka kdanilov | e2de58c | 2015-04-24 22:59:36 +0300 | [diff] [blame] | 44 | self.stop_requested = False |
| 45 | |
| 46 | def request_stop(self): |
| 47 | self.stop_requested = True |
koder aka kdanilov | 2066daf | 2015-04-23 21:05:41 +0300 | [diff] [blame] | 48 | |
| 49 | def join_remote(self, path): |
| 50 | return os.path.join(self.remote_dir, path) |
koder aka kdanilov | ec1b973 | 2015-04-23 20:43:29 +0300 | [diff] [blame] | 51 | |
| 52 | def coordinate(self, data): |
| 53 | if self.coordination_queue is not None: |
koder aka kdanilov | e2de58c | 2015-04-24 22:59:36 +0300 | [diff] [blame] | 54 | self.coordination_queue.put((self.node.get_conn_id(), data)) |
koder aka kdanilov | 4643fd6 | 2015-02-10 16:20:13 -0800 | [diff] [blame] | 55 | |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 56 | def pre_run(self): |
koder aka kdanilov | 4643fd6 | 2015-02-10 16:20:13 -0800 | [diff] [blame] | 57 | pass |
| 58 | |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 59 | def cleanup(self): |
koder aka kdanilov | 4500a5f | 2015-04-17 16:55:17 +0300 | [diff] [blame] | 60 | pass |
| 61 | |
koder aka kdanilov | 4643fd6 | 2015-02-10 16:20:13 -0800 | [diff] [blame] | 62 | @abc.abstractmethod |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 63 | def run(self, barrier): |
koder aka kdanilov | 4643fd6 | 2015-02-10 16:20:13 -0800 | [diff] [blame] | 64 | pass |
| 65 | |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 66 | @classmethod |
| 67 | def format_for_console(cls, data): |
| 68 | msg = "{0}.format_for_console".format(cls.__name__) |
| 69 | raise NotImplementedError(msg) |
| 70 | |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 71 | def run_over_ssh(self, cmd, **kwargs): |
| 72 | return run_over_ssh(self.node.connection, cmd, |
| 73 | node=self.node.get_conn_id(), **kwargs) |
| 74 | |
koder aka kdanilov | ec1b973 | 2015-04-23 20:43:29 +0300 | [diff] [blame] | 75 | @classmethod |
| 76 | def coordination_th(cls, coord_q, barrier, num_threads): |
| 77 | pass |
| 78 | |
koder aka kdanilov | 4643fd6 | 2015-02-10 16:20:13 -0800 | [diff] [blame] | 79 | |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 80 | class TwoScriptTest(IPerfTest): |
koder aka kdanilov | abd6ead | 2015-04-24 02:03:07 +0300 | [diff] [blame] | 81 | def __init__(self, *dt, **mp): |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 82 | IPerfTest.__init__(self, *dt, **mp) |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 83 | |
Yulia Portnova | b1a1507 | 2015-05-06 14:59:25 +0300 | [diff] [blame] | 84 | if 'scripts_path' in self.options: |
| 85 | self.root = self.options['scripts_path'] |
koder aka kdanilov | abd6ead | 2015-04-24 02:03:07 +0300 | [diff] [blame] | 86 | self.run_script = self.options['run_script'] |
Yulia Portnova | b1a1507 | 2015-05-06 14:59:25 +0300 | [diff] [blame] | 87 | self.prerun_script = self.options['prerun_script'] |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 88 | |
| 89 | def get_remote_for_script(self, script): |
Yulia Portnova | b1a1507 | 2015-05-06 14:59:25 +0300 | [diff] [blame] | 90 | return os.path.join(self.remote_dir, script.rpartition('/')[2]) |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 91 | |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 92 | def pre_run(self): |
Yulia Portnova | b1a1507 | 2015-05-06 14:59:25 +0300 | [diff] [blame] | 93 | copy_paths(self.node.connection, {self.root: self.remote_dir}) |
| 94 | cmd = self.get_remote_for_script(self.pre_run_script) |
| 95 | self.run_over_ssh(cmd, timeout=2000) |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 96 | |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 97 | def run(self, barrier): |
Yulia Portnova | b1a1507 | 2015-05-06 14:59:25 +0300 | [diff] [blame] | 98 | remote_script = self.get_remote_for_script(self.run_script) |
Yulia Portnova | 886a256 | 2015-04-07 11:16:13 +0300 | [diff] [blame] | 99 | cmd_opts = ' '.join(["%s %s" % (key, val) for key, val |
koder aka kdanilov | abd6ead | 2015-04-24 02:03:07 +0300 | [diff] [blame] | 100 | in self.options.items()]) |
Yulia Portnova | 886a256 | 2015-04-07 11:16:13 +0300 | [diff] [blame] | 101 | cmd = remote_script + ' ' + cmd_opts |
Yulia Portnova | b1a1507 | 2015-05-06 14:59:25 +0300 | [diff] [blame] | 102 | out_err = self.run_over_ssh(cmd, timeout=6000) |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 103 | self.on_result(out_err, cmd) |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 104 | |
| 105 | def parse_results(self, out): |
| 106 | for line in out.split("\n"): |
| 107 | key, separator, value = line.partition(":") |
| 108 | if key and value: |
| 109 | self.on_result_cb((key, float(value))) |
| 110 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 111 | def on_result(self, out_err, cmd): |
| 112 | try: |
| 113 | self.parse_results(out_err) |
| 114 | except Exception as exc: |
koder aka kdanilov | ec1b973 | 2015-04-23 20:43:29 +0300 | [diff] [blame] | 115 | msg_templ = "Error during postprocessing results: {0!s}. {1}" |
| 116 | raise RuntimeError(msg_templ.format(exc, out_err)) |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 117 | |
Yulia Portnova | b1a1507 | 2015-05-06 14:59:25 +0300 | [diff] [blame] | 118 | def merge_results(self, results): |
| 119 | tpcm = sum([val[1] for val in results]) |
| 120 | return {"res": {"TpmC": tpcm}} |
| 121 | |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 122 | |
| 123 | class PgBenchTest(TwoScriptTest): |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 124 | root = os.path.dirname(postgres.__file__) |
Yulia Portnova | b1a1507 | 2015-05-06 14:59:25 +0300 | [diff] [blame] | 125 | pre_run_script = os.path.join(root, "prepare.sh") |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 126 | run_script = os.path.join(root, "run.sh") |
koder aka kdanilov | 4500a5f | 2015-04-17 16:55:17 +0300 | [diff] [blame] | 127 | |
Yulia Portnova | 1f12396 | 2015-05-06 18:48:11 +0300 | [diff] [blame] | 128 | @classmethod |
| 129 | def format_for_console(cls, data): |
| 130 | tab = texttable.Texttable(max_width=120) |
| 131 | tab.set_deco(tab.HEADER | tab.VLINES | tab.BORDER) |
| 132 | tab.header(["TpmC"]) |
| 133 | tab.add_row([data['res']['TpmC']]) |
| 134 | return tab.draw() |
| 135 | |
| 136 | |
Yulia Portnova | b1a1507 | 2015-05-06 14:59:25 +0300 | [diff] [blame] | 137 | class MysqlTest(TwoScriptTest): |
| 138 | root = os.path.dirname(mysql.__file__) |
| 139 | pre_run_script = os.path.join(root, "prepare.sh") |
| 140 | run_script = os.path.join(root, "run.sh") |
| 141 | |
| 142 | @classmethod |
| 143 | def format_for_console(cls, data): |
| 144 | tab = texttable.Texttable(max_width=120) |
| 145 | tab.set_deco(tab.HEADER | tab.VLINES | tab.BORDER) |
| 146 | tab.header(["TpmC"]) |
| 147 | tab.add_row([data['res']['TpmC']]) |
| 148 | return tab.draw() |
| 149 | |
| 150 | |
koder aka kdanilov | 4643fd6 | 2015-02-10 16:20:13 -0800 | [diff] [blame] | 151 | class IOPerfTest(IPerfTest): |
koder aka kdanilov | 46d4f39 | 2015-04-24 11:35:00 +0300 | [diff] [blame] | 152 | tcp_conn_timeout = 30 |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 153 | max_pig_timeout = 5 |
| 154 | soft_runcycle = 5 * 60 |
koder aka kdanilov | 2c47309 | 2015-03-29 17:12:13 +0300 | [diff] [blame] | 155 | |
koder aka kdanilov | abd6ead | 2015-04-24 02:03:07 +0300 | [diff] [blame] | 156 | def __init__(self, *dt, **mp): |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 157 | IPerfTest.__init__(self, *dt, **mp) |
koder aka kdanilov | abd6ead | 2015-04-24 02:03:07 +0300 | [diff] [blame] | 158 | self.config_fname = self.options['cfg'] |
koder aka kdanilov | c368eb6 | 2015-04-28 18:22:01 +0300 | [diff] [blame] | 159 | |
| 160 | if '/' not in self.config_fname and '.' not in self.config_fname: |
| 161 | cfgs_dir = os.path.dirname(io_agent.__file__) |
| 162 | self.config_fname = os.path.join(cfgs_dir, |
| 163 | self.config_fname + '.cfg') |
| 164 | |
koder aka kdanilov | abd6ead | 2015-04-24 02:03:07 +0300 | [diff] [blame] | 165 | self.alive_check_interval = self.options.get('alive_check_interval') |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 166 | |
| 167 | self.config_params = {} |
| 168 | for name, val in self.options.get('params', {}).items(): |
| 169 | if isinstance(val, (list, tuple)): |
| 170 | val = "{%" + ','.join(map(str, val)) + "%}" |
| 171 | self.config_params[name] = val |
| 172 | |
| 173 | self.config_params['VM_COUNT'] = self.options['testnodes_count'] |
koder aka kdanilov | abd6ead | 2015-04-24 02:03:07 +0300 | [diff] [blame] | 174 | self.tool = self.options.get('tool', 'fio') |
koder aka kdanilov | da45e88 | 2015-04-06 02:24:42 +0300 | [diff] [blame] | 175 | self.raw_cfg = open(self.config_fname).read() |
koder aka kdanilov | 0c598a1 | 2015-04-21 03:01:40 +0300 | [diff] [blame] | 176 | self.configs = list(io_agent.parse_all_in_1(self.raw_cfg, |
| 177 | self.config_params)) |
koder aka kdanilov | 4643fd6 | 2015-02-10 16:20:13 -0800 | [diff] [blame] | 178 | |
koder aka kdanilov | 4500a5f | 2015-04-17 16:55:17 +0300 | [diff] [blame] | 179 | cmd_log = os.path.join(self.log_directory, "task_compiled.cfg") |
| 180 | raw_res = os.path.join(self.log_directory, "raw_results.txt") |
koder aka kdanilov | da45e88 | 2015-04-06 02:24:42 +0300 | [diff] [blame] | 181 | |
koder aka kdanilov | 2066daf | 2015-04-23 21:05:41 +0300 | [diff] [blame] | 182 | self.io_py_remote = self.join_remote("agent.py") |
| 183 | self.log_fl = self.join_remote("log.txt") |
| 184 | self.pid_file = self.join_remote("pid") |
| 185 | self.task_file = self.join_remote("task.cfg") |
koder aka kdanilov | e2de58c | 2015-04-24 22:59:36 +0300 | [diff] [blame] | 186 | self.use_sudo = self.options.get("use_sudo", True) |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 187 | self.test_logging = self.options.get("test_logging", False) |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 188 | |
koder aka kdanilov | 4500a5f | 2015-04-17 16:55:17 +0300 | [diff] [blame] | 189 | fio_command_file = open_for_append_or_create(cmd_log) |
koder aka kdanilov | 0c598a1 | 2015-04-21 03:01:40 +0300 | [diff] [blame] | 190 | |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 191 | if self.test_logging: |
| 192 | soft_runcycle = self.soft_runcycle |
| 193 | else: |
| 194 | soft_runcycle = None |
| 195 | |
| 196 | self.fio_configs = io_agent.parse_and_slice_all_in_1( |
| 197 | self.raw_cfg, |
| 198 | self.config_params, |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 199 | soft_runcycle=soft_runcycle, |
| 200 | split_on_names=self.test_logging) |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 201 | |
| 202 | self.fio_configs = list(self.fio_configs) |
koder aka kdanilov | 0c598a1 | 2015-04-21 03:01:40 +0300 | [diff] [blame] | 203 | splitter = "\n\n" + "-" * 60 + "\n\n" |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 204 | |
| 205 | cfg = splitter.join( |
| 206 | map(io_agent.fio_config_to_str, |
| 207 | self.fio_configs)) |
| 208 | |
| 209 | fio_command_file.write(cfg) |
koder aka kdanilov | 4500a5f | 2015-04-17 16:55:17 +0300 | [diff] [blame] | 210 | self.fio_raw_results_file = open_for_append_or_create(raw_res) |
| 211 | |
koder aka kdanilov | e2de58c | 2015-04-24 22:59:36 +0300 | [diff] [blame] | 212 | def __str__(self): |
| 213 | return "{0}({1})".format(self.__class__.__name__, |
| 214 | self.node.get_conn_id()) |
| 215 | |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 216 | def cleanup(self): |
| 217 | # delete_file(conn, self.io_py_remote) |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 218 | # Need to remove tempo files, used for testing |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 219 | pass |
koder aka kdanilov | 4500a5f | 2015-04-17 16:55:17 +0300 | [diff] [blame] | 220 | |
koder aka kdanilov | 2066daf | 2015-04-23 21:05:41 +0300 | [diff] [blame] | 221 | def prefill_test_files(self): |
| 222 | files = {} |
| 223 | |
| 224 | for section in self.configs: |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 225 | sz = ssize2b(section.vals['size']) |
koder aka kdanilov | 2066daf | 2015-04-23 21:05:41 +0300 | [diff] [blame] | 226 | msz = sz / (1024 ** 2) |
| 227 | |
| 228 | if sz % (1024 ** 2) != 0: |
| 229 | msz += 1 |
| 230 | |
| 231 | fname = section.vals['filename'] |
| 232 | |
| 233 | # if already has other test with the same file name |
| 234 | # take largest size |
| 235 | files[fname] = max(files.get(fname, 0), msz) |
| 236 | |
| 237 | cmd_templ = "dd oflag=direct " + \ |
| 238 | "if=/dev/zero of={0} bs={1} count={2}" |
| 239 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 240 | # cmd_templ = "fio --rw=write --bs={1} --direct=1 --size={2} " |
| 241 | |
koder aka kdanilov | e2de58c | 2015-04-24 22:59:36 +0300 | [diff] [blame] | 242 | if self.use_sudo: |
koder aka kdanilov | 2066daf | 2015-04-23 21:05:41 +0300 | [diff] [blame] | 243 | cmd_templ = "sudo " + cmd_templ |
| 244 | |
| 245 | ssize = 0 |
| 246 | stime = time.time() |
| 247 | |
| 248 | for fname, curr_sz in files.items(): |
| 249 | cmd = cmd_templ.format(fname, 1024 ** 2, curr_sz) |
| 250 | ssize += curr_sz |
| 251 | self.run_over_ssh(cmd, timeout=curr_sz) |
| 252 | |
| 253 | ddtime = time.time() - stime |
| 254 | if ddtime > 1E-3: |
| 255 | fill_bw = int(ssize / ddtime) |
| 256 | mess = "Initiall dd fill bw is {0} MiBps for this vm" |
| 257 | logger.info(mess.format(fill_bw)) |
koder aka kdanilov | abd6ead | 2015-04-24 02:03:07 +0300 | [diff] [blame] | 258 | self.coordinate(('init_bw', fill_bw)) |
koder aka kdanilov | 2066daf | 2015-04-23 21:05:41 +0300 | [diff] [blame] | 259 | |
| 260 | def install_utils(self, max_retry=3, timeout=5): |
| 261 | need_install = [] |
| 262 | for bin_name, package in (('fio', 'fio'), ('screen', 'screen')): |
| 263 | try: |
| 264 | self.run_over_ssh('which ' + bin_name, nolog=True) |
| 265 | except OSError: |
| 266 | need_install.append(package) |
| 267 | |
koder aka kdanilov | afd9874 | 2015-04-24 01:27:22 +0300 | [diff] [blame] | 268 | if len(need_install) == 0: |
| 269 | return |
| 270 | |
koder aka kdanilov | 2066daf | 2015-04-23 21:05:41 +0300 | [diff] [blame] | 271 | cmd = "sudo apt-get -y install " + " ".join(need_install) |
| 272 | |
| 273 | for i in range(max_retry): |
| 274 | try: |
| 275 | self.run_over_ssh(cmd) |
| 276 | break |
| 277 | except OSError as err: |
| 278 | time.sleep(timeout) |
| 279 | else: |
| 280 | raise OSError("Can't install - " + str(err)) |
| 281 | |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 282 | def pre_run(self): |
koder aka kdanilov | a4a570f | 2015-04-23 22:11:40 +0300 | [diff] [blame] | 283 | try: |
| 284 | cmd = 'mkdir -p "{0}"'.format(self.remote_dir) |
koder aka kdanilov | e2de58c | 2015-04-24 22:59:36 +0300 | [diff] [blame] | 285 | if self.use_sudo: |
koder aka kdanilov | a4a570f | 2015-04-23 22:11:40 +0300 | [diff] [blame] | 286 | cmd = "sudo " + cmd |
| 287 | cmd += " ; sudo chown {0} {1}".format(self.node.get_user(), |
| 288 | self.remote_dir) |
| 289 | |
| 290 | self.run_over_ssh(cmd) |
| 291 | except Exception as exc: |
| 292 | msg = "Failed to create folder {0} on remote {1}. Error: {2!s}" |
| 293 | msg = msg.format(self.remote_dir, self.node.get_conn_id(), exc) |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 294 | logger.exception(msg) |
koder aka kdanilov | e2de58c | 2015-04-24 22:59:36 +0300 | [diff] [blame] | 295 | raise StopTestError(msg, exc) |
koder aka kdanilov | 783b454 | 2015-04-23 18:57:04 +0300 | [diff] [blame] | 296 | |
koder aka kdanilov | 2066daf | 2015-04-23 21:05:41 +0300 | [diff] [blame] | 297 | self.install_utils() |
koder aka kdanilov | da45e88 | 2015-04-06 02:24:42 +0300 | [diff] [blame] | 298 | |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 299 | local_fname = os.path.splitext(io_agent.__file__)[0] + ".py" |
koder aka kdanilov | 2066daf | 2015-04-23 21:05:41 +0300 | [diff] [blame] | 300 | files_to_copy = {local_fname: self.io_py_remote} |
| 301 | copy_paths(self.node.connection, files_to_copy) |
koder aka kdanilov | 4643fd6 | 2015-02-10 16:20:13 -0800 | [diff] [blame] | 302 | |
koder aka kdanilov | e87ae65 | 2015-04-20 02:14:35 +0300 | [diff] [blame] | 303 | if self.options.get('prefill_files', True): |
koder aka kdanilov | 2066daf | 2015-04-23 21:05:41 +0300 | [diff] [blame] | 304 | self.prefill_test_files() |
koder aka kdanilov | abd6ead | 2015-04-24 02:03:07 +0300 | [diff] [blame] | 305 | elif self.is_primary: |
koder aka kdanilov | 2066daf | 2015-04-23 21:05:41 +0300 | [diff] [blame] | 306 | logger.warning("Prefilling of test files is disabled") |
koder aka kdanilov | 6e2ae79 | 2015-03-04 18:02:24 -0800 | [diff] [blame] | 307 | |
koder aka kdanilov | e2de58c | 2015-04-24 22:59:36 +0300 | [diff] [blame] | 308 | def check_process_is_running(self, sftp, pid): |
| 309 | try: |
| 310 | sftp.stat("/proc/{0}".format(pid)) |
| 311 | return True |
koder aka kdanilov | a855f90 | 2015-04-26 14:31:45 +0300 | [diff] [blame] | 312 | except (OSError, IOError, NameError): |
koder aka kdanilov | e2de58c | 2015-04-24 22:59:36 +0300 | [diff] [blame] | 313 | return False |
| 314 | |
| 315 | def kill_remote_process(self, conn, pid, soft=True): |
| 316 | try: |
| 317 | if soft: |
| 318 | cmd = "kill {0}" |
| 319 | else: |
| 320 | cmd = "kill -9 {0}" |
| 321 | |
| 322 | if self.use_sudo: |
| 323 | cmd = "sudo " + cmd |
| 324 | |
| 325 | self.run_over_ssh(cmd.format(pid)) |
| 326 | return True |
| 327 | except OSError: |
| 328 | return False |
| 329 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 330 | def get_test_status(self, res_file=None): |
| 331 | found_res_file = False |
koder aka kdanilov | 46d4f39 | 2015-04-24 11:35:00 +0300 | [diff] [blame] | 332 | is_connected = None |
koder aka kdanilov | e2de58c | 2015-04-24 22:59:36 +0300 | [diff] [blame] | 333 | is_running = None |
koder aka kdanilov | 46d4f39 | 2015-04-24 11:35:00 +0300 | [diff] [blame] | 334 | pid = None |
| 335 | err = None |
| 336 | |
| 337 | try: |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 338 | # conn = connect(self.node.conn_url, |
| 339 | # conn_timeout=self.tcp_conn_timeout) |
| 340 | # with conn: |
| 341 | conn = self.node.connection |
| 342 | with conn.open_sftp() as sftp: |
| 343 | try: |
| 344 | pid = read_from_remote(sftp, self.pid_file) |
| 345 | is_running = True |
| 346 | except (NameError, IOError, OSError) as exc: |
| 347 | pid = None |
| 348 | is_running = False |
| 349 | |
| 350 | if is_running: |
| 351 | if not self.check_process_is_running(sftp, pid): |
| 352 | try: |
| 353 | sftp.remove(self.pid_file) |
| 354 | except (IOError, NameError, OSError): |
| 355 | pass |
koder aka kdanilov | e2de58c | 2015-04-24 22:59:36 +0300 | [diff] [blame] | 356 | is_running = False |
| 357 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 358 | if res_file is not None: |
| 359 | found_res_file = exists(sftp, res_file) |
koder aka kdanilov | 46d4f39 | 2015-04-24 11:35:00 +0300 | [diff] [blame] | 360 | |
| 361 | is_connected = True |
| 362 | |
koder aka kdanilov | a855f90 | 2015-04-26 14:31:45 +0300 | [diff] [blame] | 363 | except (socket.error, SSHException, EOFError, SFTPError) as exc: |
koder aka kdanilov | 46d4f39 | 2015-04-24 11:35:00 +0300 | [diff] [blame] | 364 | err = str(exc) |
| 365 | is_connected = False |
| 366 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 367 | return found_res_file, is_connected, is_running, pid, err |
koder aka kdanilov | 46d4f39 | 2015-04-24 11:35:00 +0300 | [diff] [blame] | 368 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 369 | def wait_till_finished(self, soft_timeout, timeout, res_fname=None): |
koder aka kdanilov | 46d4f39 | 2015-04-24 11:35:00 +0300 | [diff] [blame] | 370 | conn_id = self.node.get_conn_id() |
| 371 | end_of_wait_time = timeout + time.time() |
koder aka kdanilov | a855f90 | 2015-04-26 14:31:45 +0300 | [diff] [blame] | 372 | soft_end_of_wait_time = soft_timeout + time.time() |
koder aka kdanilov | 46d4f39 | 2015-04-24 11:35:00 +0300 | [diff] [blame] | 373 | |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 374 | time_till_check = random.randint(5, 10) |
koder aka kdanilov | 46d4f39 | 2015-04-24 11:35:00 +0300 | [diff] [blame] | 375 | pid = None |
koder aka kdanilov | e2de58c | 2015-04-24 22:59:36 +0300 | [diff] [blame] | 376 | is_running = False |
koder aka kdanilov | 46d4f39 | 2015-04-24 11:35:00 +0300 | [diff] [blame] | 377 | pid_get_timeout = self.max_pig_timeout + time.time() |
| 378 | curr_connected = True |
| 379 | |
| 380 | while end_of_wait_time > time.time(): |
| 381 | time.sleep(time_till_check) |
| 382 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 383 | found_res_file, is_connected, is_running, npid, err = \ |
| 384 | self.get_test_status(res_fname) |
| 385 | |
| 386 | if found_res_file and not is_running: |
| 387 | return |
koder aka kdanilov | 46d4f39 | 2015-04-24 11:35:00 +0300 | [diff] [blame] | 388 | |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 389 | if is_connected and not is_running: |
| 390 | if pid is None: |
| 391 | if time.time() > pid_get_timeout: |
| 392 | msg = ("On node {0} pid file doesn't " + |
| 393 | "appears in time") |
| 394 | logger.error(msg.format(conn_id)) |
| 395 | raise StopTestError("Start timeout") |
koder aka kdanilov | 46d4f39 | 2015-04-24 11:35:00 +0300 | [diff] [blame] | 396 | else: |
| 397 | # execution finished |
| 398 | break |
| 399 | |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 400 | if npid is not None: |
| 401 | pid = npid |
| 402 | |
koder aka kdanilov | a855f90 | 2015-04-26 14:31:45 +0300 | [diff] [blame] | 403 | if is_connected and pid is not None and is_running: |
| 404 | if time.time() < soft_end_of_wait_time: |
| 405 | time.sleep(soft_end_of_wait_time - time.time()) |
| 406 | |
koder aka kdanilov | 46d4f39 | 2015-04-24 11:35:00 +0300 | [diff] [blame] | 407 | if is_connected and not curr_connected: |
| 408 | msg = "Connection with {0} is restored" |
| 409 | logger.debug(msg.format(conn_id)) |
| 410 | elif not is_connected and curr_connected: |
| 411 | msg = "Lost connection with " + conn_id + ". Error: " + err |
| 412 | logger.debug(msg) |
| 413 | |
| 414 | curr_connected = is_connected |
| 415 | |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 416 | def run(self, barrier): |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 417 | try: |
koder aka kdanilov | a323b30 | 2015-04-26 00:40:22 +0300 | [diff] [blame] | 418 | if len(self.fio_configs) > 1 and self.is_primary: |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 419 | |
| 420 | exec_time = 0 |
| 421 | for test in self.fio_configs: |
| 422 | exec_time += io_agent.calculate_execution_time(test) |
| 423 | |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 424 | # +5% - is a rough estimation for additional operations |
| 425 | # like sftp, etc |
| 426 | exec_time = int(exec_time * 1.05) |
| 427 | |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 428 | exec_time_s = sec_to_str(exec_time) |
koder aka kdanilov | a855f90 | 2015-04-26 14:31:45 +0300 | [diff] [blame] | 429 | now_dt = datetime.datetime.now() |
| 430 | end_dt = now_dt + datetime.timedelta(0, exec_time) |
| 431 | msg = "Entire test should takes aroud: {0} and finished at {1}" |
| 432 | logger.info(msg.format(exec_time_s, |
| 433 | end_dt.strftime("%H:%M:%S"))) |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 434 | |
| 435 | for pos, fio_cfg_slice in enumerate(self.fio_configs): |
| 436 | names = [i.name for i in fio_cfg_slice] |
| 437 | msgs = [] |
| 438 | already_processed = set() |
| 439 | for name in names: |
| 440 | if name not in already_processed: |
| 441 | already_processed.add(name) |
| 442 | |
| 443 | if 1 == names.count(name): |
| 444 | msgs.append(name) |
| 445 | else: |
| 446 | frmt = "{0} * {1}" |
| 447 | msgs.append(frmt.format(name, |
| 448 | names.count(name))) |
| 449 | |
koder aka kdanilov | a323b30 | 2015-04-26 00:40:22 +0300 | [diff] [blame] | 450 | if self.is_primary: |
| 451 | logger.info("Will run tests: " + ", ".join(msgs)) |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 452 | |
koder aka kdanilov | a323b30 | 2015-04-26 00:40:22 +0300 | [diff] [blame] | 453 | nolog = (pos != 0) or not self.is_primary |
| 454 | out_err = self.do_run(barrier, fio_cfg_slice, nolog=nolog) |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 455 | |
| 456 | try: |
| 457 | for data in parse_output(out_err): |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 458 | self.on_result_cb(data) |
| 459 | except (OSError, StopTestError): |
| 460 | raise |
| 461 | except Exception as exc: |
| 462 | msg_templ = "Error during postprocessing results: {0!s}" |
| 463 | raise RuntimeError(msg_templ.format(exc)) |
| 464 | |
| 465 | finally: |
| 466 | barrier.exit() |
| 467 | |
| 468 | def do_run(self, barrier, cfg, nolog=False): |
koder aka kdanilov | abd6ead | 2015-04-24 02:03:07 +0300 | [diff] [blame] | 469 | conn_id = self.node.get_conn_id() |
| 470 | |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 471 | cmd_templ = "screen -S {screen_name} -d -m " + \ |
| 472 | "env python2 {0} -p {pid_file} -o {results_file} " + \ |
| 473 | "--type {1} {2} --json {3}" |
| 474 | |
| 475 | if self.options.get("use_sudo", True): |
| 476 | cmd_templ = "sudo " + cmd_templ |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 477 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 478 | params = [] |
| 479 | for k, v in self.config_params.items(): |
| 480 | if isinstance(v, basestring) and v.startswith("{%"): |
| 481 | continue |
| 482 | params.append("{0}={1}".format(k, v)) |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 483 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 484 | if [] != params: |
| 485 | params = "--params " + " ".join(params) |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 486 | |
koder aka kdanilov | 783b454 | 2015-04-23 18:57:04 +0300 | [diff] [blame] | 487 | with self.node.connection.open_sftp() as sftp: |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 488 | save_to_remote(sftp, self.task_file, |
| 489 | io_agent.fio_config_to_str(cfg)) |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 490 | |
| 491 | screen_name = self.test_uuid |
| 492 | cmd = cmd_templ.format(self.io_py_remote, |
| 493 | self.tool, |
| 494 | params, |
| 495 | self.task_file, |
| 496 | pid_file=self.pid_file, |
| 497 | results_file=self.log_fl, |
| 498 | screen_name=screen_name) |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 499 | |
| 500 | exec_time = io_agent.calculate_execution_time(cfg) |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 501 | exec_time_str = sec_to_str(exec_time) |
| 502 | |
koder aka kdanilov | a855f90 | 2015-04-26 14:31:45 +0300 | [diff] [blame] | 503 | timeout = int(exec_time + max(300, exec_time)) |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 504 | soft_tout = exec_time |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 505 | barrier.wait() |
koder aka kdanilov | a323b30 | 2015-04-26 00:40:22 +0300 | [diff] [blame] | 506 | self.run_over_ssh(cmd, nolog=nolog) |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 507 | if self.is_primary: |
| 508 | templ = "Test should takes about {0}." + \ |
| 509 | " Should finish at {1}," + \ |
| 510 | " will wait at most till {2}" |
| 511 | now_dt = datetime.datetime.now() |
| 512 | end_dt = now_dt + datetime.timedelta(0, exec_time) |
| 513 | wait_till = now_dt + datetime.timedelta(0, timeout) |
koder aka kdanilov | ea22c3d | 2015-04-21 03:42:22 +0300 | [diff] [blame] | 514 | |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 515 | logger.info(templ.format(exec_time_str, |
| 516 | end_dt.strftime("%H:%M:%S"), |
| 517 | wait_till.strftime("%H:%M:%S"))) |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 518 | |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 519 | if not nolog: |
| 520 | msg = "Tests started in screen {1} on each testnode" |
| 521 | logger.debug(msg.format(conn_id, screen_name)) |
koder aka kdanilov | 46d4f39 | 2015-04-24 11:35:00 +0300 | [diff] [blame] | 522 | |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 523 | # TODO: add monitoring socket |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 524 | # if not isinstance(self.node.connection, Local): |
| 525 | # self.node.connection.close() |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 526 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 527 | self.wait_till_finished(soft_tout, timeout, self.log_fl) |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 528 | if not nolog: |
| 529 | logger.debug("Test on node {0} is finished".format(conn_id)) |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 530 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 531 | # if self.node.connection is not Local: |
| 532 | # conn_timeout = self.tcp_conn_timeout * 3 |
| 533 | # self.node.connection = connect(self.node.conn_url, |
| 534 | # conn_timeout=conn_timeout) |
koder aka kdanilov | 4d4771c | 2015-04-23 01:32:02 +0300 | [diff] [blame] | 535 | |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 536 | with self.node.connection.open_sftp() as sftp: |
| 537 | return read_from_remote(sftp, self.log_fl) |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 538 | |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 539 | @classmethod |
| 540 | def merge_results(cls, results): |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 541 | merged = results[0] |
| 542 | for block in results[1:]: |
| 543 | assert block["__meta__"] == merged["__meta__"] |
| 544 | merged['res'].extend(block['res']) |
| 545 | return merged |
koder aka kdanilov | 4500a5f | 2015-04-17 16:55:17 +0300 | [diff] [blame] | 546 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 547 | # @classmethod |
| 548 | # def merge_results(cls, results): |
| 549 | # if len(results) == 0: |
| 550 | # return None |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 551 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 552 | # merged_result = results[0] |
| 553 | # merged_data = merged_result['res'] |
| 554 | # mergable_fields = ['bw', 'clat', 'iops', 'lat', 'slat'] |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 555 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 556 | # for res in results[1:]: |
| 557 | # mm = merged_result['__meta__'] |
| 558 | # assert mm['raw_cfg'] == res['__meta__']['raw_cfg'] |
| 559 | # assert mm['params'] == res['__meta__']['params'] |
| 560 | # mm['timings'].extend(res['__meta__']['timings']) |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 561 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 562 | # data = res['res'] |
| 563 | # for testname, test_data in data.items(): |
| 564 | # if testname not in merged_data: |
| 565 | # merged_data[testname] = test_data |
| 566 | # continue |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 567 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 568 | # res_test_data = merged_data[testname] |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 569 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 570 | # diff = set(test_data.keys()).symmetric_difference( |
| 571 | # res_test_data.keys()) |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 572 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 573 | # msg = "Difference: {0}".format(",".join(diff)) |
| 574 | # assert len(diff) == 0, msg |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 575 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 576 | # for k, v in test_data.items(): |
| 577 | # if k in mergable_fields: |
| 578 | # res_test_data[k].extend(v) |
| 579 | # else: |
| 580 | # msg = "{0!r} != {1!r}".format(res_test_data[k], v) |
| 581 | # assert res_test_data[k] == v, msg |
| 582 | |
| 583 | # return merged_result |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 584 | |
| 585 | @classmethod |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 586 | def format_for_console(cls, data, dinfo): |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 587 | return io_formatter.format_results_for_console(dinfo) |