Merge pull request #263 from robertbaldyga/tests-update-tf-plugins
tests: Update TF - plugins
This commit is contained in:
commit
8180736c67
@ -10,12 +10,12 @@ from connection.local_executor import LocalExecutor
|
|||||||
def get_current_commit_hash():
|
def get_current_commit_hash():
|
||||||
local_executor = LocalExecutor()
|
local_executor = LocalExecutor()
|
||||||
return local_executor.run(
|
return local_executor.run(
|
||||||
f"cd {TestRun.plugins['opencas'].repo_dir} &&"
|
f"cd {TestRun.usr.repo_dir} &&"
|
||||||
f'git show HEAD -s --pretty=format:"%H"').stdout
|
f'git show HEAD -s --pretty=format:"%H"').stdout
|
||||||
|
|
||||||
|
|
||||||
def get_current_commit_message():
|
def get_current_commit_message():
|
||||||
local_executor = LocalExecutor()
|
local_executor = LocalExecutor()
|
||||||
return local_executor.run(
|
return local_executor.run(
|
||||||
f"cd {TestRun.plugins['opencas'].repo_dir} &&"
|
f"cd {TestRun.usr.repo_dir} &&"
|
||||||
f'git show HEAD -s --pretty=format:"%B"').stdout
|
f'git show HEAD -s --pretty=format:"%B"').stdout
|
||||||
|
@ -14,14 +14,14 @@ from test_utils.output import CmdException
|
|||||||
def install_opencas():
|
def install_opencas():
|
||||||
TestRun.LOGGER.info("Copying Open CAS repository to DUT")
|
TestRun.LOGGER.info("Copying Open CAS repository to DUT")
|
||||||
TestRun.executor.rsync(
|
TestRun.executor.rsync(
|
||||||
f"{TestRun.plugins['opencas'].repo_dir}/",
|
f"{TestRun.usr.repo_dir}/",
|
||||||
f"{TestRun.plugins['opencas'].working_dir}/",
|
f"{TestRun.usr.working_dir}/",
|
||||||
exclude_list=["test/functional/results/"],
|
exclude_list=["test/functional/results/"],
|
||||||
delete=True)
|
delete=True)
|
||||||
|
|
||||||
TestRun.LOGGER.info("Building Open CAS")
|
TestRun.LOGGER.info("Building Open CAS")
|
||||||
output = TestRun.executor.run(
|
output = TestRun.executor.run(
|
||||||
f"cd {TestRun.plugins['opencas'].working_dir} && "
|
f"cd {TestRun.usr.working_dir} && "
|
||||||
"./configure && "
|
"./configure && "
|
||||||
"make -j")
|
"make -j")
|
||||||
if output.exit_code != 0:
|
if output.exit_code != 0:
|
||||||
@ -29,7 +29,7 @@ def install_opencas():
|
|||||||
|
|
||||||
TestRun.LOGGER.info("Installing Open CAS")
|
TestRun.LOGGER.info("Installing Open CAS")
|
||||||
output = TestRun.executor.run(
|
output = TestRun.executor.run(
|
||||||
f"cd {TestRun.plugins['opencas'].working_dir} && "
|
f"cd {TestRun.usr.working_dir} && "
|
||||||
f"make install")
|
f"make install")
|
||||||
if output.exit_code != 0:
|
if output.exit_code != 0:
|
||||||
raise CmdException("Error while installing Open CAS", output)
|
raise CmdException("Error while installing Open CAS", output)
|
||||||
@ -49,7 +49,7 @@ def uninstall_opencas():
|
|||||||
raise CmdException("Open CAS is not properly installed", output)
|
raise CmdException("Open CAS is not properly installed", output)
|
||||||
else:
|
else:
|
||||||
TestRun.executor.run(
|
TestRun.executor.run(
|
||||||
f"cd {TestRun.plugins['opencas'].working_dir} && "
|
f"cd {TestRun.usr.working_dir} && "
|
||||||
f"make uninstall")
|
f"make uninstall")
|
||||||
if output.exit_code != 0:
|
if output.exit_code != 0:
|
||||||
raise CmdException("There was an error during uninstall process", output)
|
raise CmdException("There was an error during uninstall process", output)
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 588d6d72d93de63fbed334832ef529cb3ade0077
|
Subproject commit 4b4c66db919bb44bba06de5998e2e81517c7ea4b
|
@ -9,7 +9,6 @@ import sys
|
|||||||
import pytest
|
import pytest
|
||||||
import yaml
|
import yaml
|
||||||
import traceback
|
import traceback
|
||||||
from IPy import IP
|
|
||||||
|
|
||||||
sys.path.append(os.path.join(os.path.dirname(__file__), "../test-framework"))
|
sys.path.append(os.path.join(os.path.dirname(__file__), "../test-framework"))
|
||||||
|
|
||||||
@ -23,15 +22,8 @@ from test_tools.device_mapper import DeviceMapper
|
|||||||
from log.logger import create_log, Log
|
from log.logger import create_log, Log
|
||||||
from test_utils.singleton import Singleton
|
from test_utils.singleton import Singleton
|
||||||
|
|
||||||
plugins_dir = os.path.join(os.path.dirname(__file__), "../plugins")
|
|
||||||
sys.path.append(plugins_dir)
|
|
||||||
try:
|
|
||||||
from test_wrapper import plugin as test_wrapper
|
|
||||||
except ImportError as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
|
class Opencas(metaclass=Singleton):
|
||||||
class OpencasPlugin(metaclass=Singleton):
|
|
||||||
def __init__(self, repo_dir, working_dir):
|
def __init__(self, repo_dir, working_dir):
|
||||||
self.repo_dir = repo_dir
|
self.repo_dir = repo_dir
|
||||||
self.working_dir = working_dir
|
self.working_dir = working_dir
|
||||||
@ -48,48 +40,31 @@ def pytest_runtest_setup(item):
|
|||||||
# User can also have own test wrapper, which runs test prepare, cleanup, etc.
|
# User can also have own test wrapper, which runs test prepare, cleanup, etc.
|
||||||
# Then it should be placed in plugins package
|
# Then it should be placed in plugins package
|
||||||
|
|
||||||
TestRun.prepare(item)
|
try:
|
||||||
|
with open(item.config.getoption('--dut-config')) as cfg:
|
||||||
|
dut_config = yaml.safe_load(cfg)
|
||||||
|
except Exception:
|
||||||
|
raise Exception("You need to specify DUT config. See the example_dut_config.py file.")
|
||||||
|
|
||||||
test_name = item.name.split('[')[0]
|
dut_config['plugins_dir'] = os.path.join(os.path.dirname(__file__), "../lib")
|
||||||
TestRun.LOGGER = create_log(item.config.getoption('--log-path'), test_name)
|
dut_config['opt_plugins'] = {"test_wrapper": {}}
|
||||||
|
|
||||||
with TestRun.LOGGER.step("Dut prepare"):
|
try:
|
||||||
try:
|
TestRun.prepare(item, dut_config)
|
||||||
try:
|
|
||||||
with open(item.config.getoption('--dut-config')) as cfg:
|
|
||||||
dut_config = yaml.safe_load(cfg)
|
|
||||||
except Exception:
|
|
||||||
TestRun.block("You need to specify DUT config. See the example_dut_config.py file.")
|
|
||||||
|
|
||||||
if 'test_wrapper' in sys.modules:
|
test_name = item.name.split('[')[0]
|
||||||
if 'ip' in dut_config:
|
TestRun.LOGGER = create_log(item.config.getoption('--log-path'), test_name)
|
||||||
try:
|
|
||||||
IP(dut_config['ip'])
|
|
||||||
except ValueError:
|
|
||||||
raise ValueError(
|
|
||||||
"IP address from configuration file is in invalid format.")
|
|
||||||
try:
|
|
||||||
dut_config = test_wrapper.prepare(dut_config)
|
|
||||||
except Exception as ex:
|
|
||||||
raise Exception(f"Exception occurred on test wrapper prepare stage:\n"
|
|
||||||
f"{str(ex)}\n{traceback.format_exc()}")
|
|
||||||
try:
|
|
||||||
TestRun.setup(dut_config)
|
|
||||||
except Exception as ex:
|
|
||||||
raise Exception(f"Exception occurred during test setup:\n"
|
|
||||||
f"{str(ex)}\n{traceback.format_exc()}")
|
|
||||||
|
|
||||||
if 'test_wrapper' in sys.modules:
|
TestRun.setup()
|
||||||
test_wrapper.try_setup_serial_log(dut_config)
|
except Exception as ex:
|
||||||
|
raise Exception(f"Exception occurred during test setup:\n"
|
||||||
|
f"{str(ex)}\n{traceback.format_exc()}")
|
||||||
|
|
||||||
TestRun.plugins['opencas'] = OpencasPlugin(
|
TestRun.usr = Opencas(
|
||||||
repo_dir=os.path.join(os.path.dirname(__file__), "../../.."),
|
repo_dir=os.path.join(os.path.dirname(__file__), "../../.."),
|
||||||
working_dir=dut_config['working_dir'])
|
working_dir=dut_config['working_dir'])
|
||||||
|
|
||||||
except Exception as exception:
|
TestRun.LOGGER.info(f"DUT info: {TestRun.dut}")
|
||||||
raise Exception(f"Conftest prepare exception:\n"
|
|
||||||
f"{str(exception)}\n{traceback.format_exc()}")
|
|
||||||
TestRun.LOGGER.info(f"DUT info: {TestRun.dut}")
|
|
||||||
|
|
||||||
base_prepare(item)
|
base_prepare(item)
|
||||||
TestRun.LOGGER.write_to_command_log("Test body")
|
TestRun.LOGGER.write_to_command_log("Test body")
|
||||||
@ -128,17 +103,11 @@ def pytest_runtest_teardown():
|
|||||||
TestRun.LOGGER.warning(f"Exception occured during platform cleanup.\n"
|
TestRun.LOGGER.warning(f"Exception occured during platform cleanup.\n"
|
||||||
f"{str(ex)}\n{traceback.format_exc()}")
|
f"{str(ex)}\n{traceback.format_exc()}")
|
||||||
|
|
||||||
if 'test_wrapper' in sys.modules:
|
|
||||||
try:
|
|
||||||
test_wrapper.cleanup()
|
|
||||||
except Exception as ex:
|
|
||||||
TestRun.LOGGER.warning(f"Exception occured during test wrapper cleanup.\n{str(ex)}"
|
|
||||||
f"\n{traceback.format_exc()}")
|
|
||||||
|
|
||||||
TestRun.LOGGER.end()
|
TestRun.LOGGER.end()
|
||||||
if TestRun.executor:
|
if TestRun.executor:
|
||||||
TestRun.LOGGER.get_additional_logs()
|
TestRun.LOGGER.get_additional_logs()
|
||||||
Log.destroy()
|
Log.destroy()
|
||||||
|
TestRun.teardown()
|
||||||
|
|
||||||
|
|
||||||
def pytest_configure(config):
|
def pytest_configure(config):
|
||||||
@ -200,11 +169,11 @@ def base_prepare(item):
|
|||||||
if not create_partition_table(disk, PartitionTable.gpt):
|
if not create_partition_table(disk, PartitionTable.gpt):
|
||||||
raise Exception(f"Failed to remove partitions from {disk}")
|
raise Exception(f"Failed to remove partitions from {disk}")
|
||||||
|
|
||||||
if get_force_param(item) and not TestRun.plugins['opencas'].already_updated:
|
if get_force_param(item) and not TestRun.usr.already_updated:
|
||||||
installer.reinstall_opencas()
|
installer.reinstall_opencas()
|
||||||
elif not installer.check_if_installed():
|
elif not installer.check_if_installed():
|
||||||
installer.install_opencas()
|
installer.install_opencas()
|
||||||
TestRun.plugins['opencas'].already_updated = True
|
TestRun.usr.already_updated = True
|
||||||
TestRun.LOGGER.add_build_info(f'Commit hash:')
|
TestRun.LOGGER.add_build_info(f'Commit hash:')
|
||||||
TestRun.LOGGER.add_build_info(f"{git.get_current_commit_hash()}")
|
TestRun.LOGGER.add_build_info(f"{git.get_current_commit_hash()}")
|
||||||
TestRun.LOGGER.add_build_info(f'Commit message:')
|
TestRun.LOGGER.add_build_info(f'Commit message:')
|
||||||
|
Loading…
Reference in New Issue
Block a user