Raise exception instead of using TestRun.exception()
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
parent
18c77daec9
commit
263f3137da
@ -8,6 +8,7 @@ import logging
|
|||||||
|
|
||||||
from tests import conftest
|
from tests import conftest
|
||||||
from core.test_run import TestRun
|
from core.test_run import TestRun
|
||||||
|
from test_utils.output import CmdException
|
||||||
|
|
||||||
|
|
||||||
def install_opencas():
|
def install_opencas():
|
||||||
@ -23,22 +24,19 @@ def install_opencas():
|
|||||||
"./configure && "
|
"./configure && "
|
||||||
"make -j")
|
"make -j")
|
||||||
if output.exit_code != 0:
|
if output.exit_code != 0:
|
||||||
TestRun.exception(
|
raise CmdException("Make command executed with nonzero status", output)
|
||||||
f"Make command executed with nonzero status: {output.stdout}\n{output.stderr}")
|
|
||||||
|
|
||||||
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.plugins['opencas'].working_dir} && "
|
||||||
f"make install")
|
f"make install")
|
||||||
if output.exit_code != 0:
|
if output.exit_code != 0:
|
||||||
TestRun.exception(
|
raise CmdException("Error while installing Open CAS", output)
|
||||||
f"Error while installing Open CAS: {output.stdout}\n{output.stderr}")
|
|
||||||
|
|
||||||
TestRun.LOGGER.info("Check if casadm is properly installed.")
|
TestRun.LOGGER.info("Check if casadm is properly installed.")
|
||||||
output = TestRun.executor.run("casadm -V")
|
output = TestRun.executor.run("casadm -V")
|
||||||
if output.exit_code != 0:
|
if output.exit_code != 0:
|
||||||
TestRun.exception(
|
raise CmdException("'casadm -V' command returned an error", output)
|
||||||
f"'casadm -V' command returned an error: {output.stdout}\n{output.stderr}")
|
|
||||||
else:
|
else:
|
||||||
TestRun.LOGGER.info(output.stdout)
|
TestRun.LOGGER.info(output.stdout)
|
||||||
|
|
||||||
@ -47,14 +45,13 @@ def uninstall_opencas():
|
|||||||
TestRun.LOGGER.info("Uninstalling Open CAS")
|
TestRun.LOGGER.info("Uninstalling Open CAS")
|
||||||
output = TestRun.executor.run("casadm -V")
|
output = TestRun.executor.run("casadm -V")
|
||||||
if output.exit_code != 0:
|
if output.exit_code != 0:
|
||||||
TestRun.exception("Open CAS is not properly installed")
|
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.plugins['opencas'].working_dir} && "
|
||||||
f"make uninstall")
|
f"make uninstall")
|
||||||
if output.exit_code != 0:
|
if output.exit_code != 0:
|
||||||
TestRun.exception(
|
raise CmdException("There was an error during uninstall process", output)
|
||||||
f"There was an error during uninstall process: {output.stdout}\n{output.stderr}")
|
|
||||||
|
|
||||||
|
|
||||||
def reinstall_opencas():
|
def reinstall_opencas():
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit c58510d62691ec0984dbbbf151f1bba86c65cff4
|
Subproject commit 1c075f00dd6b02e9c563b10d35dc497a61c59225
|
@ -64,17 +64,17 @@ def pytest_runtest_setup(item):
|
|||||||
try:
|
try:
|
||||||
IP(dut_config['ip'])
|
IP(dut_config['ip'])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
TestRun.exception(
|
raise ValueError(
|
||||||
"IP address from configuration file is in invalid format.")
|
"IP address from configuration file is in invalid format.")
|
||||||
try:
|
try:
|
||||||
dut_config = test_wrapper.prepare(dut_config)
|
dut_config = test_wrapper.prepare(dut_config)
|
||||||
except Exception as ex:
|
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()}")
|
f"{str(ex)}\n{traceback.format_exc()}")
|
||||||
try:
|
try:
|
||||||
TestRun.setup(dut_config)
|
TestRun.setup(dut_config)
|
||||||
except Exception as ex:
|
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()}")
|
f"{str(ex)}\n{traceback.format_exc()}")
|
||||||
|
|
||||||
if 'test_wrapper' in sys.modules:
|
if 'test_wrapper' in sys.modules:
|
||||||
@ -85,7 +85,7 @@ def pytest_runtest_setup(item):
|
|||||||
working_dir=dut_config['working_dir'])
|
working_dir=dut_config['working_dir'])
|
||||||
|
|
||||||
except Exception as exception:
|
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()}")
|
f"{str(exception)}\n{traceback.format_exc()}")
|
||||||
TestRun.LOGGER.info(f"DUT info: {TestRun.dut}")
|
TestRun.LOGGER.info(f"DUT info: {TestRun.dut}")
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ def base_prepare(item):
|
|||||||
for disk in TestRun.dut.disks:
|
for disk in TestRun.dut.disks:
|
||||||
disk.umount_all_partitions()
|
disk.umount_all_partitions()
|
||||||
if not create_partition_table(disk, PartitionTable.gpt):
|
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:
|
if get_force_param(item) and not TestRun.plugins['opencas'].already_updated:
|
||||||
installer.reinstall_opencas()
|
installer.reinstall_opencas()
|
||||||
|
Loading…
Reference in New Issue
Block a user