tests: refactor test_clean_reboot
Signed-off-by: Kamil Gierszewski <kamil.gierszewski@huawei.com>
This commit is contained in:
parent
61ff8f60c5
commit
b3cb1251cc
@ -4,7 +4,7 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import os
|
||||
import posixpath
|
||||
import pytest
|
||||
|
||||
from api.cas import casadm
|
||||
@ -18,9 +18,6 @@ from test_utils.os_utils import drop_caches, DropCachesMode, sync
|
||||
from test_utils.size import Size, Unit
|
||||
|
||||
|
||||
mount_point = "/mnt/test"
|
||||
|
||||
|
||||
@pytest.mark.os_dependent
|
||||
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||
@ -31,48 +28,65 @@ mount_point = "/mnt/test"
|
||||
def test_load_after_clean_shutdown(reboot_type, cache_mode, filesystem):
|
||||
"""
|
||||
title: Planned system shutdown test.
|
||||
description: Test for data consistency after clean system shutdown.
|
||||
description: |
|
||||
Test for data consistency after clean system shutdown.
|
||||
pass_criteria:
|
||||
- DUT should reboot successfully.
|
||||
- DUT reboot successful.
|
||||
- Checksum of file on core device should be the same before and after reboot.
|
||||
"""
|
||||
with TestRun.step("Prepare CAS device."):
|
||||
mount_point = "/mnt/test"
|
||||
|
||||
with TestRun.step("Prepare cache and core devices"):
|
||||
cache_disk = TestRun.disks["cache"]
|
||||
cache_disk.create_partitions([Size(1, Unit.GibiByte)])
|
||||
cache_dev = cache_disk.partitions[0]
|
||||
core_dev = TestRun.disks["core"]
|
||||
|
||||
cache_disk.create_partitions([Size(1, Unit.GibiByte)])
|
||||
|
||||
cache_dev = cache_disk.partitions[0]
|
||||
|
||||
with TestRun.step("Start cache and add core"):
|
||||
cache = casadm.start_cache(cache_dev, cache_mode, force=True)
|
||||
core = cache.add_core(core_dev)
|
||||
|
||||
with TestRun.step("Create filesystem on the core device and mount it"):
|
||||
core.create_filesystem(filesystem, blocksize=int(Size(1, Unit.Blocks4096)))
|
||||
core.mount(mount_point)
|
||||
|
||||
with TestRun.step("Create file on cache and count its checksum."):
|
||||
test_file = File(os.path.join(mount_point, "test_file"))
|
||||
Dd().input("/dev/zero").output(test_file.full_path).block_size(
|
||||
Size(1, Unit.KibiByte)
|
||||
).count(1024).run()
|
||||
with TestRun.step("Create file on exported object"):
|
||||
test_file = File(posixpath.join(mount_point, "test_file"))
|
||||
|
||||
dd = (
|
||||
Dd()
|
||||
.input("/dev/zero")
|
||||
.output(test_file.full_path)
|
||||
.block_size(Size(1, Unit.KibiByte))
|
||||
.count(1024)
|
||||
)
|
||||
dd.run()
|
||||
|
||||
with TestRun.step("Calculate test file md5sums before reboot"):
|
||||
test_file.refresh_item()
|
||||
test_file_md5 = test_file.md5sum()
|
||||
sync()
|
||||
drop_caches(DropCachesMode.ALL)
|
||||
|
||||
with TestRun.step("Reset platform."):
|
||||
with TestRun.step("Reset platform"):
|
||||
if reboot_type == "soft":
|
||||
TestRun.executor.reboot()
|
||||
else:
|
||||
power_control = TestRun.plugin_manager.get_plugin("power_control")
|
||||
power_control.power_cycle()
|
||||
|
||||
with TestRun.step("Load cache."):
|
||||
with TestRun.step("Load cache and mount core"):
|
||||
casadm.load_cache(cache_dev)
|
||||
core.mount(mount_point)
|
||||
|
||||
with TestRun.step("Check file md5sum."):
|
||||
with TestRun.step("Compare test file md5sums"):
|
||||
test_file.refresh_item()
|
||||
if test_file_md5 != test_file.md5sum():
|
||||
TestRun.LOGGER.error("Checksums does not match - file is corrupted.")
|
||||
else:
|
||||
TestRun.LOGGER.info("File checksum is correct.")
|
||||
|
||||
with TestRun.step("Remove test file."):
|
||||
with TestRun.step("Remove test file"):
|
||||
test_file.remove()
|
||||
|
Loading…
Reference in New Issue
Block a user