koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 1 | import time |
koder aka kdanilov | 23e6bdf | 2016-12-24 02:18:54 +0200 | [diff] [blame] | 2 | import json |
koder aka kdanilov | e21d747 | 2015-02-14 19:02:04 -0800 | [diff] [blame] | 3 | import logging |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 4 | from concurrent.futures import Future |
| 5 | from typing import List, Dict, Tuple, Optional, Union, cast |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 6 | |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 7 | from . import utils, ssh_utils, hw_info |
| 8 | from .config import ConfigBlock |
koder aka kdanilov | 7308462 | 2016-11-16 21:51:08 +0200 | [diff] [blame] | 9 | from .node import setup_rpc, connect |
koder aka kdanilov | 7f59d56 | 2016-12-26 01:34:23 +0200 | [diff] [blame] | 10 | from .node_interfaces import NodeInfo, IRPCNode |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 11 | from .stage import Stage, StepOrder |
koder aka kdanilov | 7f59d56 | 2016-12-26 01:34:23 +0200 | [diff] [blame] | 12 | from .sensors import collect_sensors_data |
koder aka kdanilov | 108ac36 | 2017-01-19 20:17:16 +0200 | [diff] [blame] | 13 | from .suits.all_suits import all_suits |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 14 | from .test_run_class import TestRun |
koder aka kdanilov | 7f59d56 | 2016-12-26 01:34:23 +0200 | [diff] [blame] | 15 | from .utils import StopTestError |
koder aka kdanilov | a732a60 | 2017-02-01 20:29:56 +0200 | [diff] [blame] | 16 | from .result_classes import SuiteConfig |
koder aka kdanilov | 108ac36 | 2017-01-19 20:17:16 +0200 | [diff] [blame] | 17 | from .hlstorage import ResultStorage |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 18 | |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 19 | |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 20 | logger = logging.getLogger("wally") |
koder aka kdanilov | cee4334 | 2015-04-14 22:52:53 +0300 | [diff] [blame] | 21 | |
koder aka kdanilov | 7acd6bd | 2015-02-12 14:28:30 -0800 | [diff] [blame] | 22 | |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 23 | class ConnectStage(Stage): |
| 24 | """Connect to nodes stage""" |
koder aka kdanilov | e21d747 | 2015-02-14 19:02:04 -0800 | [diff] [blame] | 25 | |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 26 | priority = StepOrder.CONNECT |
koder aka kdanilov | 0fdaaee | 2015-06-30 11:10:48 +0300 | [diff] [blame] | 27 | |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 28 | def run(self, ctx: TestRun) -> None: |
koder aka kdanilov | 7308462 | 2016-11-16 21:51:08 +0200 | [diff] [blame] | 29 | with ctx.get_pool() as pool: |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 30 | logger.info("Connecting to %s nodes", len(ctx.nodes_info)) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 31 | |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 32 | def connect_ext(node_info: NodeInfo) -> Tuple[bool, Union[IRPCNode, NodeInfo]]: |
| 33 | try: |
| 34 | ssh_node = connect(node_info, conn_timeout=ctx.config.connect_timeout) |
koder aka kdanilov | 23e6bdf | 2016-12-24 02:18:54 +0200 | [diff] [blame] | 35 | |
koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 36 | return True, setup_rpc(ssh_node, |
| 37 | ctx.rpc_code, |
| 38 | ctx.default_rpc_plugins, |
| 39 | log_level=ctx.config.rpc_log_level) |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 40 | except Exception as exc: |
koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 41 | logger.exception("During connect to %s: %s", node_info, exc) |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 42 | return False, node_info |
koder aka kdanilov | 0fdaaee | 2015-06-30 11:10:48 +0300 | [diff] [blame] | 43 | |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 44 | failed_testnodes = [] # type: List[NodeInfo] |
| 45 | failed_nodes = [] # type: List[NodeInfo] |
| 46 | ctx.nodes = [] |
koder aka kdanilov | 0fdaaee | 2015-06-30 11:10:48 +0300 | [diff] [blame] | 47 | |
koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 48 | for ok, node in pool.map(connect_ext, ctx.nodes_info.values()): |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 49 | if not ok: |
| 50 | node = cast(NodeInfo, node) |
| 51 | if 'testnode' in node.roles: |
| 52 | failed_testnodes.append(node) |
| 53 | else: |
| 54 | failed_nodes.append(node) |
| 55 | else: |
| 56 | ctx.nodes.append(cast(IRPCNode, node)) |
koder aka kdanilov | 22d134e | 2016-11-08 11:33:19 +0200 | [diff] [blame] | 57 | |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 58 | if failed_nodes: |
| 59 | msg = "Node(s) {} would be excluded - can't connect" |
koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 60 | logger.warning(msg.format(", ".join(map(str, failed_nodes)))) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 61 | |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 62 | if failed_testnodes: |
koder aka kdanilov | 23e6bdf | 2016-12-24 02:18:54 +0200 | [diff] [blame] | 63 | msg = "Can't start RPC on testnode(s) " + ",".join(map(str, failed_testnodes)) |
koder aka kdanilov | c368eb6 | 2015-04-28 18:22:01 +0300 | [diff] [blame] | 64 | logger.error(msg) |
| 65 | raise utils.StopTestError(msg) |
| 66 | |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 67 | if not failed_nodes: |
| 68 | logger.info("All nodes connected successfully") |
koder aka kdanilov | cee4334 | 2015-04-14 22:52:53 +0300 | [diff] [blame] | 69 | |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 70 | def cleanup(self, ctx: TestRun) -> None: |
koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 71 | if ctx.config.get("download_rpc_logs", False): |
| 72 | for node in ctx.nodes: |
| 73 | if node.rpc_log_file is not None: |
koder aka kdanilov | 108ac36 | 2017-01-19 20:17:16 +0200 | [diff] [blame] | 74 | nid = node.node_id |
koder aka kdanilov | a732a60 | 2017-02-01 20:29:56 +0200 | [diff] [blame] | 75 | path = "rpc_logs/{}.txt".format(nid) |
koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 76 | node.conn.server.flush_logs() |
| 77 | log = node.get_file_content(node.rpc_log_file) |
koder aka kdanilov | 7f59d56 | 2016-12-26 01:34:23 +0200 | [diff] [blame] | 78 | if path in ctx.storage: |
koder aka kdanilov | ffaf48d | 2016-12-27 02:25:29 +0200 | [diff] [blame] | 79 | ctx.storage.append_raw(log, path) |
koder aka kdanilov | 7f59d56 | 2016-12-26 01:34:23 +0200 | [diff] [blame] | 80 | else: |
koder aka kdanilov | ffaf48d | 2016-12-27 02:25:29 +0200 | [diff] [blame] | 81 | ctx.storage.put_raw(log, path) |
koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 82 | logger.debug("RPC log from node {} stored into storage::{}".format(nid, path)) |
| 83 | |
| 84 | with ctx.get_pool() as pool: |
| 85 | list(pool.map(lambda node: node.disconnect(stop=True), ctx.nodes)) |
koder aka kdanilov | cee4334 | 2015-04-14 22:52:53 +0300 | [diff] [blame] | 86 | |
koder aka kdanilov | 0fdaaee | 2015-06-30 11:10:48 +0300 | [diff] [blame] | 87 | |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 88 | class CollectInfoStage(Stage): |
| 89 | """Collect node info""" |
koder aka kdanilov | 3d2bc4f | 2016-11-12 18:31:18 +0200 | [diff] [blame] | 90 | |
koder aka kdanilov | 23e6bdf | 2016-12-24 02:18:54 +0200 | [diff] [blame] | 91 | priority = StepOrder.START_SENSORS - 2 |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 92 | config_block = 'collect_info' |
| 93 | |
| 94 | def run(self, ctx: TestRun) -> None: |
| 95 | if not ctx.config.collect_info: |
| 96 | return |
| 97 | |
koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 98 | futures = {} # type: Dict[Tuple[str, str], Future] |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 99 | |
| 100 | with ctx.get_pool() as pool: |
koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 101 | # can't make next RPC request until finish with previous |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 102 | for node in ctx.nodes: |
koder aka kdanilov | 108ac36 | 2017-01-19 20:17:16 +0200 | [diff] [blame] | 103 | nid = node.node_id |
koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 104 | hw_info_path = "hw_info/{}".format(nid) |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 105 | if hw_info_path not in ctx.storage: |
koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 106 | futures[(hw_info_path, nid)] = pool.submit(hw_info.get_hw_info, node) |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 107 | |
koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 108 | for (path, nid), future in futures.items(): |
| 109 | try: |
koder aka kdanilov | 7f59d56 | 2016-12-26 01:34:23 +0200 | [diff] [blame] | 110 | ctx.storage.put(future.result(), path) |
koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 111 | except Exception: |
| 112 | logger.exception("During collecting hardware info from %s", nid) |
| 113 | raise utils.StopTestError() |
| 114 | |
| 115 | futures.clear() |
| 116 | for node in ctx.nodes: |
koder aka kdanilov | 108ac36 | 2017-01-19 20:17:16 +0200 | [diff] [blame] | 117 | nid = node.node_id |
koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 118 | sw_info_path = "sw_info/{}".format(nid) |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 119 | if sw_info_path not in ctx.storage: |
koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 120 | futures[(sw_info_path, nid)] = pool.submit(hw_info.get_sw_info, node) |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 121 | |
koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 122 | for (path, nid), future in futures.items(): |
| 123 | try: |
koder aka kdanilov | 7f59d56 | 2016-12-26 01:34:23 +0200 | [diff] [blame] | 124 | ctx.storage.put(future.result(), path) |
koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 125 | except Exception: |
| 126 | logger.exception("During collecting software info from %s", nid) |
| 127 | raise utils.StopTestError() |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 128 | |
| 129 | |
| 130 | class ExplicitNodesStage(Stage): |
| 131 | """add explicit nodes""" |
| 132 | |
| 133 | priority = StepOrder.DISCOVER |
| 134 | config_block = 'nodes' |
| 135 | |
| 136 | def run(self, ctx: TestRun) -> None: |
koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 137 | if 'all_nodes' in ctx.storage: |
| 138 | logger.info("Skip explicid nodes filling, as all_nodes all ready in storage") |
| 139 | return |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 140 | |
koder aka kdanilov | bbbe1dc | 2016-12-20 01:19:56 +0200 | [diff] [blame] | 141 | for url, roles in ctx.config.get('nodes', {}).raw().items(): |
kdanylov aka koder | 150b219 | 2017-04-01 16:53:01 +0300 | [diff] [blame^] | 142 | ctx.merge_node(ssh_utils.parse_ssh_uri(url), set(role.strip() for role in roles.split(","))) |
koder aka kdanilov | bbbe1dc | 2016-12-20 01:19:56 +0200 | [diff] [blame] | 143 | logger.debug("Add node %s with roles %s", url, roles) |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 144 | |
| 145 | |
| 146 | class SaveNodesStage(Stage): |
| 147 | """Save nodes list to file""" |
| 148 | |
| 149 | priority = StepOrder.CONNECT |
| 150 | |
| 151 | def run(self, ctx: TestRun) -> None: |
koder aka kdanilov | 7f59d56 | 2016-12-26 01:34:23 +0200 | [diff] [blame] | 152 | ctx.storage.put_list(ctx.nodes_info.values(), 'all_nodes') |
koder aka kdanilov | 962ee5f | 2016-12-19 02:40:08 +0200 | [diff] [blame] | 153 | |
| 154 | |
| 155 | class SleepStage(Stage): |
| 156 | """Save nodes list to file""" |
| 157 | |
| 158 | priority = StepOrder.TEST |
| 159 | config_block = 'sleep' |
| 160 | |
| 161 | def run(self, ctx: TestRun) -> None: |
| 162 | logger.debug("Will sleep for %r seconds", ctx.config.sleep) |
| 163 | time.sleep(ctx.config.sleep) |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 164 | |
| 165 | |
koder aka kdanilov | 23e6bdf | 2016-12-24 02:18:54 +0200 | [diff] [blame] | 166 | class PrepareNodes(Stage): |
| 167 | priority = StepOrder.START_SENSORS - 1 |
| 168 | |
| 169 | def __init__(self): |
| 170 | Stage.__init__(self) |
| 171 | self.nodeepscrub_updated = False |
| 172 | self.noscrub_updated = False |
| 173 | |
| 174 | def run(self, ctx: TestRun) -> None: |
| 175 | ceph_sett = ctx.config.get('ceph_settings', "").split() |
| 176 | if ceph_sett: |
| 177 | for node in ctx.nodes: |
| 178 | if "ceph-mon" in node.info.roles or "ceph-osd" in node.info.roles: |
| 179 | state = json.loads(node.run("ceph health --format json"))["summary"]["summary"] |
| 180 | if 'noscrub' in ceph_sett: |
| 181 | if 'noscrub' in state: |
| 182 | logger.debug("noscrub already set on cluster") |
| 183 | else: |
| 184 | logger.info("Applying noscrub settings to ceph cluster") |
| 185 | node.run("ceph osd set noscrub") |
| 186 | self.noscrub_updated = True |
| 187 | |
| 188 | if 'nodeepscrub' in ceph_sett: |
| 189 | if 'nodeepscrub' in state: |
| 190 | logger.debug("noscrub already set on cluster") |
| 191 | else: |
| 192 | logger.info("Applying noscrub settings to ceph cluster") |
| 193 | node.run("ceph osd set noscrub") |
| 194 | self.nodeepscrub_updated = True |
| 195 | break |
| 196 | |
| 197 | def cleanup(self, ctx: TestRun) -> None: |
| 198 | if self.nodeepscrub_updated or self.noscrub_updated: |
| 199 | for node in ctx.nodes: |
| 200 | if "ceph-mon" in node.info.roles or "ceph-osd" in node.info.roles : |
| 201 | if self.noscrub_updated: |
| 202 | logger.info("Reverting noscrub setting for ceph cluster") |
| 203 | node.run("ceph osd unset noscrub") |
| 204 | self.noscrub_updated = False |
| 205 | |
| 206 | if self.nodeepscrub_updated: |
| 207 | logger.info("Reverting noscrub setting for ceph cluster") |
| 208 | node.run("ceph osd unset nodeepscrub") |
| 209 | self.nodeepscrub_updated = False |
| 210 | |
| 211 | |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 212 | class RunTestsStage(Stage): |
| 213 | |
| 214 | priority = StepOrder.TEST |
| 215 | config_block = 'tests' |
| 216 | |
| 217 | def run(self, ctx: TestRun) -> None: |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 218 | if ctx.config.no_tests: |
| 219 | logger.info("Skiping tests, as 'no_tests' config settings is True") |
| 220 | return |
koder aka kdanilov | 3d2bc4f | 2016-11-12 18:31:18 +0200 | [diff] [blame] | 221 | |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 222 | for suite_idx, test_suite in enumerate(ctx.config.get('tests', [])): |
| 223 | test_nodes = [node for node in ctx.nodes if 'testnode' in node.info.roles] |
koder aka kdanilov | da45e88 | 2015-04-06 02:24:42 +0300 | [diff] [blame] | 224 | |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 225 | if not test_nodes: |
| 226 | logger.error("No test nodes found") |
| 227 | raise StopTestError() |
gstepanov | 023c1e4 | 2015-04-08 15:50:19 +0300 | [diff] [blame] | 228 | |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 229 | if len(test_suite) != 1: |
| 230 | logger.error("Test suite %s contain more than one test. Put each test in separated group", suite_idx) |
| 231 | raise StopTestError() |
koder aka kdanilov | 7022706 | 2016-11-26 23:23:21 +0200 | [diff] [blame] | 232 | |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 233 | name, params = list(test_suite.items())[0] |
| 234 | vm_count = params.get('node_limit', None) # type: Optional[int] |
koder aka kdanilov | 7022706 | 2016-11-26 23:23:21 +0200 | [diff] [blame] | 235 | |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 236 | # select test nodes |
| 237 | if vm_count is None: |
| 238 | curr_test_nodes = test_nodes |
| 239 | else: |
| 240 | curr_test_nodes = test_nodes[:vm_count] |
koder aka kdanilov | 7022706 | 2016-11-26 23:23:21 +0200 | [diff] [blame] | 241 | |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 242 | if not curr_test_nodes: |
| 243 | logger.error("No nodes found for test, skipping it.") |
| 244 | continue |
| 245 | |
kdanylov aka koder | 150b219 | 2017-04-01 16:53:01 +0300 | [diff] [blame^] | 246 | if name not in all_suits: |
| 247 | logger.error("Test suite %r not found. Only suits [%s] available", name, ", ".join(all_suits)) |
| 248 | raise StopTestError() |
| 249 | |
koder aka kdanilov | 108ac36 | 2017-01-19 20:17:16 +0200 | [diff] [blame] | 250 | test_cls = all_suits[name] |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 251 | remote_dir = ctx.config.default_test_local_folder.format(name=name, uuid=ctx.config.run_uuid) |
koder aka kdanilov | a732a60 | 2017-02-01 20:29:56 +0200 | [diff] [blame] | 252 | suite = SuiteConfig(test_cls.name, |
| 253 | params=params, |
| 254 | run_uuid=ctx.config.run_uuid, |
| 255 | nodes=test_nodes, |
| 256 | remote_dir=remote_dir, |
| 257 | idx=suite_idx, |
| 258 | keep_raw_files=ctx.config.keep_raw_files) |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 259 | |
koder aka kdanilov | 108ac36 | 2017-01-19 20:17:16 +0200 | [diff] [blame] | 260 | test_cls(storage=ResultStorage(ctx.storage), |
| 261 | suite=suite, |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 262 | on_idle=lambda: collect_sensors_data(ctx, False)).run() |
gstepanov | 023c1e4 | 2015-04-08 15:50:19 +0300 | [diff] [blame] | 263 | |
koder aka kdanilov | 39e449e | 2016-12-17 15:15:26 +0200 | [diff] [blame] | 264 | @classmethod |
| 265 | def validate_config(cls, cfg: ConfigBlock) -> None: |
| 266 | pass |
koder aka kdanilov | 7f59d56 | 2016-12-26 01:34:23 +0200 | [diff] [blame] | 267 | |
| 268 | |
koder aka kdanilov | 7f59d56 | 2016-12-26 01:34:23 +0200 | [diff] [blame] | 269 | class LoadStoredNodesStage(Stage): |
| 270 | priority = StepOrder.DISCOVER |
| 271 | |
| 272 | def run(self, ctx: TestRun) -> None: |
| 273 | if 'all_nodes' in ctx.storage: |
| 274 | if ctx.nodes_info: |
| 275 | logger.error("Internal error: Some nodes already stored in " + |
| 276 | "nodes_info before LoadStoredNodesStage stage") |
| 277 | raise StopTestError() |
koder aka kdanilov | 108ac36 | 2017-01-19 20:17:16 +0200 | [diff] [blame] | 278 | ctx.nodes_info = {node.node_id: node |
koder aka kdanilov | 7f59d56 | 2016-12-26 01:34:23 +0200 | [diff] [blame] | 279 | for node in ctx.storage.load_list(NodeInfo, "all_nodes")} |
| 280 | logger.info("%s nodes loaded from database", len(ctx.nodes_info)) |