tests: refactor test_init_status

Signed-off-by: Kamil Gierszewski <kamil.gierszewski@huawei.com>
This commit is contained in:
Kamil Gierszewski 2024-09-25 23:18:02 +02:00
parent b3cb1251cc
commit 39c4a3be4e
No known key found for this signature in database

View File

@ -1,9 +1,10 @@
# #
# Copyright(c) 2020-2021 Intel Corporation # Copyright(c) 2020-2021 Intel Corporation
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
import time
import time
import pytest import pytest
from api.cas import cas_module, casctl from api.cas import cas_module, casctl
@ -15,27 +16,28 @@ from test_utils import os_utils
@pytest.mark.os_dependent @pytest.mark.os_dependent
def test_init_status(): def test_init_status():
""" """
title: CAS management device status title: CAS management device status
description: | description: |
Verify that CAS management device is present in OS only when CAS modules are loaded. Verify that CAS management device is present in OS only when CAS modules are loaded.
pass_criteria: pass_criteria:
- CAS management device present in OS when CAS modules are loaded. - CAS management device present in OS when CAS modules are loaded.
- CAS management device not present in OS when CAS modules are not loaded. - CAS management device not present in OS when CAS modules are not loaded.
""" """
with TestRun.step("Check if CAS management device is present in OS."):
with TestRun.step("Check if CAS management device is present in OS"):
time.sleep(5) time.sleep(5)
if cas_module.is_cas_management_dev_present(): if cas_module.is_cas_management_dev_present():
TestRun.LOGGER.info("CAS management device is present in OS when CAS module is loaded.") TestRun.LOGGER.info("CAS management device is present in OS when CAS module is loaded.")
else: else:
TestRun.fail("CAS management device is not present in OS when CAS module is loaded.") TestRun.fail("CAS management device is not present in OS when CAS module is loaded.")
with TestRun.step("Remove CAS module."): with TestRun.step("Remove CAS module"):
cas_module.unload_all_cas_modules() cas_module.unload_all_cas_modules()
with TestRun.step("Stop CAS service."): with TestRun.step("Stop CAS service"):
casctl.stop() casctl.stop()
with TestRun.step("Check if CAS management device is not present in OS."): with TestRun.step("Check if CAS management device is not present in OS"):
time.sleep(5) time.sleep(5)
if not cas_module.is_cas_management_dev_present(): if not cas_module.is_cas_management_dev_present():
TestRun.LOGGER.info( TestRun.LOGGER.info(
@ -43,7 +45,6 @@ def test_init_status():
else: else:
TestRun.fail("CAS management device is present in OS when CAS module is not loaded.") TestRun.fail("CAS management device is present in OS when CAS module is not loaded.")
with TestRun.step("Load CAS modules and start CAS service."): with TestRun.step("Load CAS modules and start CAS service"):
os_utils.load_kernel_module(CasModule.cache.value) os_utils.load_kernel_module(CasModule.cache.value)
os_utils.load_kernel_module(CasModule.disk.value)
casctl.start() casctl.start()