From 1714a9855c60649985d7652d91343e52667cc875 Mon Sep 17 00:00:00 2001 From: Katarzyna Lapinska Date: Mon, 17 Aug 2020 09:19:31 +0200 Subject: [PATCH] Add reboot if executor can not connect to DUT in test prepare Signed-off-by: Katarzyna Lapinska --- test/functional/tests/conftest.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/functional/tests/conftest.py b/test/functional/tests/conftest.py index c1a803d..189106e 100644 --- a/test/functional/tests/conftest.py +++ b/test/functional/tests/conftest.py @@ -5,6 +5,7 @@ import os import sys +from datetime import timedelta import pytest import yaml @@ -47,7 +48,7 @@ def pytest_runtest_setup(item): raise Exception("You need to specify DUT config. See the example_dut_config.py file.") dut_config['plugins_dir'] = os.path.join(os.path.dirname(__file__), "../lib") - dut_config['opt_plugins'] = {"test_wrapper": {}, "serial_log": {}} + dut_config['opt_plugins'] = {"test_wrapper": {}, "serial_log": {}, "power_control": {}} try: TestRun.prepare(item, dut_config) @@ -55,6 +56,15 @@ def pytest_runtest_setup(item): test_name = item.name.split('[')[0] TestRun.LOGGER = create_log(item.config.getoption('--log-path'), test_name) + TestRun.presetup() + try: + TestRun.executor.wait_for_connection(timedelta(seconds=20)) + except Exception: + try: + TestRun.plugin_manager.get_plugin('power_control').power_cycle() + TestRun.executor.wait_for_connection() + except Exception: + raise Exception("Failed to connect to DUT.") TestRun.setup() except Exception as ex: raise Exception(f"Exception occurred during test setup:\n"