Merge pull request #210 from robertbaldyga/remove-testrun-exception

Update test-framework submodule
This commit is contained in:
Robert Baldyga 2019-11-29 13:36:19 +01:00 committed by GitHub
commit 718763374b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 28 deletions

View File

@ -8,6 +8,7 @@ import logging
from tests import conftest
from core.test_run import TestRun
from test_utils.output import CmdException
def install_opencas():
@ -23,22 +24,19 @@ def install_opencas():
"./configure && "
"make -j")
if output.exit_code != 0:
TestRun.exception(
f"Make command executed with nonzero status: {output.stdout}\n{output.stderr}")
raise CmdException("Make command executed with nonzero status", output)
TestRun.LOGGER.info("Installing Open CAS")
output = TestRun.executor.run(
f"cd {TestRun.plugins['opencas'].working_dir} && "
f"make install")
if output.exit_code != 0:
TestRun.exception(
f"Error while installing Open CAS: {output.stdout}\n{output.stderr}")
raise CmdException("Error while installing Open CAS", output)
TestRun.LOGGER.info("Check if casadm is properly installed.")
output = TestRun.executor.run("casadm -V")
if output.exit_code != 0:
TestRun.exception(
f"'casadm -V' command returned an error: {output.stdout}\n{output.stderr}")
raise CmdException("'casadm -V' command returned an error", output)
else:
TestRun.LOGGER.info(output.stdout)
@ -47,14 +45,13 @@ def uninstall_opencas():
TestRun.LOGGER.info("Uninstalling Open CAS")
output = TestRun.executor.run("casadm -V")
if output.exit_code != 0:
TestRun.exception("Open CAS is not properly installed")
raise CmdException("Open CAS is not properly installed", output)
else:
TestRun.executor.run(
f"cd {TestRun.plugins['opencas'].working_dir} && "
f"make uninstall")
if output.exit_code != 0:
TestRun.exception(
f"There was an error during uninstall process: {output.stdout}\n{output.stderr}")
raise CmdException("There was an error during uninstall process", output)
def reinstall_opencas():

@ -1 +1 @@
Subproject commit c58510d62691ec0984dbbbf151f1bba86c65cff4
Subproject commit 0910d7f45e9f9ae05b0cf4b2fc1e802269b7f3ce

View File

@ -64,17 +64,17 @@ def pytest_runtest_setup(item):
try:
IP(dut_config['ip'])
except ValueError:
TestRun.exception(
raise ValueError(
"IP address from configuration file is in invalid format.")
try:
dut_config = test_wrapper.prepare(dut_config)
except Exception as ex:
TestRun.LOGGER.exception(f"Exception occurred on test wrapper prepare stage:\n"
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:
TestRun.LOGGER.exception(f"Exception occurred during test setup:\n"
raise Exception(f"Exception occurred during test setup:\n"
f"{str(ex)}\n{traceback.format_exc()}")
if 'test_wrapper' in sys.modules:
@ -85,7 +85,7 @@ def pytest_runtest_setup(item):
working_dir=dut_config['working_dir'])
except Exception as exception:
TestRun.LOGGER.exception(f"Conftest prepare exception:\n"
raise Exception(f"Conftest prepare exception:\n"
f"{str(exception)}\n{traceback.format_exc()}")
TestRun.LOGGER.info(f"DUT info: {TestRun.dut}")
@ -97,16 +97,7 @@ def pytest_runtest_setup(item):
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
def pytest_runtest_makereport(item, call):
res = (yield).get_result()
TestRun.outcome = res.outcome
from _pytest.outcomes import Failed
if res.when == "call" and res.failed:
msg = f"{call.excinfo.type.__name__}: {call.excinfo.value}"
if call.excinfo.type is Failed:
TestRun.LOGGER.error(msg)
else:
TestRun.LOGGER.exception(msg)
TestRun.makereport(item, call, res)
def pytest_runtest_teardown():
@ -197,7 +188,7 @@ def base_prepare(item):
for disk in TestRun.dut.disks:
disk.umount_all_partitions()
if not create_partition_table(disk, PartitionTable.gpt):
TestRun.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:
installer.reinstall_opencas()