Skip to content

Commit

Permalink
test-conftest: remove autoinstall and update conftest
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Gierszewski committed Aug 9, 2024
1 parent 61c52b2 commit 93e96f8
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions test/functional/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#
# Copyright(c) 2019-2022 Intel Corporation
# Copyright(c) 2023-2024 Huawei Technologies Co., Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#

import os
import posixpath
import sys
import traceback
from datetime import timedelta
Expand All @@ -14,6 +16,7 @@

sys.path.append(os.path.join(os.path.dirname(__file__), "../test-framework"))

from core.test_run import Blocked
from core.test_run_utils import TestRun
from api.cas import installer
from api.cas import casadm
Expand Down Expand Up @@ -91,7 +94,7 @@ def pytest_runtest_setup(item):
TestRun.presetup()
try:
TestRun.executor.wait_for_connection(timedelta(seconds=20))
except paramiko.AuthenticationException:
except (paramiko.AuthenticationException, Blocked):
raise
except Exception:
try:
Expand Down Expand Up @@ -167,7 +170,9 @@ def pytest_runtest_teardown():
for dut in TestRun.duts:
with TestRun.use_dut(dut):
if TestRun.executor:
os.makedirs(os.path.join(TestRun.LOGGER.base_dir, "dut_info", dut.ip),
os.makedirs(os.path.join(TestRun.LOGGER.base_dir, "dut_info",
dut.ip if dut.ip is not None
else dut.config.get("host")),
exist_ok=True)
TestRun.LOGGER.get_additional_logs()
Log.destroy()
Expand All @@ -187,7 +192,6 @@ def pytest_addoption(parser):
parser.addoption("--dut-config", action="append", type=str)
parser.addoption("--log-path", action="store",
default=f"{os.path.join(os.path.dirname(__file__), '../results')}")
parser.addoption("--force-reinstall", action="store_true", default=False)
parser.addoption("--fuzzy-iter-count", action="store")


Expand All @@ -213,10 +217,6 @@ def unmount_cas_devices():
)


def get_force_param(item):
return item.config.getoption("--force-reinstall")


def __drbd_cleanup():
from storage_devices.drbd import Drbd
Drbd.down_all()
Expand Down Expand Up @@ -266,33 +266,24 @@ def base_prepare(item):
raid.remove_partitions()
raid.stop()
for device in raid.array_devices:
Mdadm.zero_superblock(os.path.join('/dev', device.get_device_id()))
Mdadm.zero_superblock(posixpath.join('/dev', device.get_device_id()))
Udev.settle()

RamDisk.remove_all()

for disk in TestRun.dut.disks:
disk_serial = get_disk_serial_number(disk.path)
if disk.serial_number != disk_serial:
if disk.serial_number and disk.serial_number != disk_serial:
raise Exception(
f"Serial for {disk.path} doesn't match the one from the config."
f"Serial from config {disk.serial_number}, actual serial {disk_serial}"
)

disk.umount_all_partitions()
Mdadm.zero_superblock(os.path.join('/dev', disk.get_device_id()))
Mdadm.zero_superblock(posixpath.join('/dev', disk.get_device_id()))
TestRun.executor.run_expect_success("udevadm settle")
disk.remove_partitions()
create_partition_table(disk, PartitionTable.gpt)

cas_version = TestRun.config.get("cas_version") or git.get_current_commit_hash()
if get_force_param(item) and not TestRun.usr.already_updated:
installer.rsync_opencas_sources()
installer.reinstall_opencas(cas_version)
elif not installer.check_if_installed(cas_version):
installer.rsync_opencas_sources()
installer.set_up_opencas(cas_version)

TestRun.usr.already_updated = True
TestRun.LOGGER.add_build_info(f'Commit hash:')
TestRun.LOGGER.add_build_info(f"{git.get_current_commit_hash()}")
Expand Down

0 comments on commit 93e96f8

Please sign in to comment.