Count md5sum of tmp files in recovery tests before reboot
Signed-off-by: klapinsk <katarzyna.lapinska@intel.com>
This commit is contained in:
parent
5a6d4bea86
commit
28ae17e23b
@ -28,9 +28,7 @@ def copy_file(source, target, size, direct=None):
|
|||||||
dd.run()
|
dd.run()
|
||||||
|
|
||||||
|
|
||||||
def compare_files(file1, file2, should_differ=False):
|
def compare_files(file1_md5, file2_md5, should_differ=False):
|
||||||
file1_md5 = file1.md5sum()
|
|
||||||
file2_md5 = file2.md5sum()
|
|
||||||
if should_differ ^ (file1_md5 != file2_md5):
|
if should_differ ^ (file1_md5 != file2_md5):
|
||||||
if should_differ:
|
if should_differ:
|
||||||
TestRun.fail("Source and target file checksums are identical.")
|
TestRun.fail("Source and target file checksums are identical.")
|
||||||
|
@ -9,7 +9,6 @@ from api.cas import casadm, cli
|
|||||||
from api.cas.cache_config import CacheMode, CacheModeTrait, CleaningPolicy, SeqCutOffPolicy
|
from api.cas.cache_config import CacheMode, CacheModeTrait, CleaningPolicy, SeqCutOffPolicy
|
||||||
from core.test_run import TestRun
|
from core.test_run import TestRun
|
||||||
from storage_devices.disk import DiskTypeSet, DiskType, DiskTypeLowerThan
|
from storage_devices.disk import DiskTypeSet, DiskType, DiskTypeLowerThan
|
||||||
from test_tools.dd import Dd
|
|
||||||
from test_tools.disk_utils import Filesystem
|
from test_tools.disk_utils import Filesystem
|
||||||
from test_tools.fs_utils import readlink
|
from test_tools.fs_utils import readlink
|
||||||
from test_utils import os_utils
|
from test_utils import os_utils
|
||||||
@ -47,6 +46,7 @@ def test_recovery_flush_reset_raw(cache_mode):
|
|||||||
|
|
||||||
with TestRun.step("Create test files."):
|
with TestRun.step("Create test files."):
|
||||||
source_file, target_file = create_test_files(test_file_size)
|
source_file, target_file = create_test_files(test_file_size)
|
||||||
|
source_file_md5 = source_file.md5sum()
|
||||||
|
|
||||||
with TestRun.step("Setup cache and add core."):
|
with TestRun.step("Setup cache and add core."):
|
||||||
cache = casadm.start_cache(cache_device, cache_mode)
|
cache = casadm.start_cache(cache_device, cache_mode)
|
||||||
@ -74,7 +74,8 @@ def test_recovery_flush_reset_raw(cache_mode):
|
|||||||
"before restart."):
|
"before restart."):
|
||||||
copy_file(source=readlink(core_device.path), target=target_file.full_path,
|
copy_file(source=readlink(core_device.path), target=target_file.full_path,
|
||||||
size=test_file_size, direct="iflag")
|
size=test_file_size, direct="iflag")
|
||||||
compare_files(source_file, target_file, should_differ=True)
|
target_file_md5 = target_file.md5sum()
|
||||||
|
compare_files(source_file_md5, target_file_md5, should_differ=True)
|
||||||
|
|
||||||
with TestRun.step("Load cache."):
|
with TestRun.step("Load cache."):
|
||||||
cache = casadm.load_cache(cache_device)
|
cache = casadm.load_cache(cache_device)
|
||||||
@ -91,11 +92,16 @@ def test_recovery_flush_reset_raw(cache_mode):
|
|||||||
"Compare it with the first version – they should be the same."):
|
"Compare it with the first version – they should be the same."):
|
||||||
copy_file(source=readlink(core_device.path), target=target_file.full_path,
|
copy_file(source=readlink(core_device.path), target=target_file.full_path,
|
||||||
size=test_file_size, direct="iflag")
|
size=test_file_size, direct="iflag")
|
||||||
compare_files(source_file, target_file)
|
target_file_md5 = target_file.md5sum()
|
||||||
|
compare_files(source_file_md5, target_file_md5)
|
||||||
|
|
||||||
with TestRun.step("Cleanup core device and remove test files."):
|
with TestRun.step("Cleanup core device and remove test files."):
|
||||||
|
try:
|
||||||
target_file.remove()
|
target_file.remove()
|
||||||
source_file.remove()
|
source_file.remove()
|
||||||
|
except Exception:
|
||||||
|
# On some OSes files at /tmp location are automatically removed after DUT hard reset
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
|
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
|
||||||
@ -126,6 +132,7 @@ def test_recovery_flush_reset_fs(cache_mode, fs):
|
|||||||
|
|
||||||
with TestRun.step("Create test files."):
|
with TestRun.step("Create test files."):
|
||||||
source_file, target_file = create_test_files(test_file_size)
|
source_file, target_file = create_test_files(test_file_size)
|
||||||
|
source_file_md5 = source_file.md5sum()
|
||||||
|
|
||||||
with TestRun.step("Setup cache and add core."):
|
with TestRun.step("Setup cache and add core."):
|
||||||
cache = casadm.start_cache(cache_device, cache_mode)
|
cache = casadm.start_cache(cache_device, cache_mode)
|
||||||
@ -170,10 +177,15 @@ def test_recovery_flush_reset_fs(cache_mode, fs):
|
|||||||
copy_file(source=os.path.join(mount_point, "source_test_file"),
|
copy_file(source=os.path.join(mount_point, "source_test_file"),
|
||||||
target=target_file.full_path,
|
target=target_file.full_path,
|
||||||
size=test_file_size, direct="iflag")
|
size=test_file_size, direct="iflag")
|
||||||
compare_files(source_file, target_file)
|
target_file_md5 = target_file.md5sum()
|
||||||
|
compare_files(source_file_md5, target_file_md5)
|
||||||
|
|
||||||
with TestRun.step("Unmount core device and remove test files."):
|
with TestRun.step("Unmount core device and remove test files."):
|
||||||
core_device.unmount()
|
core_device.unmount()
|
||||||
|
try:
|
||||||
target_file.remove()
|
target_file.remove()
|
||||||
source_file.remove()
|
source_file.remove()
|
||||||
|
except Exception:
|
||||||
|
# On some OSes files at /tmp location are automatically removed after DUT hard reset
|
||||||
|
pass
|
||||||
Udev.enable()
|
Udev.enable()
|
||||||
|
@ -9,7 +9,6 @@ from api.cas import casadm
|
|||||||
from api.cas.cache_config import CacheMode, CacheModeTrait, CacheLineSize
|
from api.cas.cache_config import CacheMode, CacheModeTrait, CacheLineSize
|
||||||
from core.test_run import TestRun
|
from core.test_run import TestRun
|
||||||
from storage_devices.disk import DiskTypeSet, DiskType, DiskTypeLowerThan
|
from storage_devices.disk import DiskTypeSet, DiskType, DiskTypeLowerThan
|
||||||
from test_tools.dd import Dd
|
|
||||||
from test_tools.disk_utils import Filesystem
|
from test_tools.disk_utils import Filesystem
|
||||||
from test_utils.size import Size, Unit
|
from test_utils.size import Size, Unit
|
||||||
from tests.lazy_writes.recovery.recovery_tests_methods import create_test_files, copy_file, \
|
from tests.lazy_writes.recovery.recovery_tests_methods import create_test_files, copy_file, \
|
||||||
@ -47,6 +46,7 @@ def test_recovery_unplug_cache_fs(cache_mode, cls, filesystem, direct):
|
|||||||
|
|
||||||
with TestRun.step("Create test files."):
|
with TestRun.step("Create test files."):
|
||||||
source_file, target_file = create_test_files(test_file_size)
|
source_file, target_file = create_test_files(test_file_size)
|
||||||
|
source_file_md5 = source_file.md5sum()
|
||||||
|
|
||||||
with TestRun.step("Create filesystem on core device."):
|
with TestRun.step("Create filesystem on core device."):
|
||||||
core_device.create_filesystem(filesystem)
|
core_device.create_filesystem(filesystem)
|
||||||
@ -92,12 +92,17 @@ def test_recovery_unplug_cache_fs(cache_mode, cls, filesystem, direct):
|
|||||||
with TestRun.step("Copy file from core device and check md5sum."):
|
with TestRun.step("Copy file from core device and check md5sum."):
|
||||||
copy_file(source=test_file_path, target=target_file.full_path,
|
copy_file(source=test_file_path, target=target_file.full_path,
|
||||||
size=test_file_size, direct="iflag" if direct else None)
|
size=test_file_size, direct="iflag" if direct else None)
|
||||||
compare_files(source_file, target_file)
|
target_file_md5 = target_file.md5sum()
|
||||||
|
compare_files(source_file_md5, target_file_md5)
|
||||||
|
|
||||||
with TestRun.step("Unmount core device and remove files."):
|
with TestRun.step("Unmount core device and remove files."):
|
||||||
core_device.unmount()
|
core_device.unmount()
|
||||||
|
try:
|
||||||
target_file.remove()
|
target_file.remove()
|
||||||
source_file.remove()
|
source_file.remove()
|
||||||
|
except Exception:
|
||||||
|
# On some OSes files at /tmp location are automatically removed after DUT hard reset
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
|
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
|
||||||
@ -125,6 +130,7 @@ def test_recovery_unplug_cache_raw(cache_mode, cls):
|
|||||||
|
|
||||||
with TestRun.step("Create test files."):
|
with TestRun.step("Create test files."):
|
||||||
source_file, target_file = create_test_files(test_file_size)
|
source_file, target_file = create_test_files(test_file_size)
|
||||||
|
source_file_md5 = source_file.md5sum()
|
||||||
|
|
||||||
with TestRun.step("Start cache and add core."):
|
with TestRun.step("Start cache and add core."):
|
||||||
cache = casadm.start_cache(cache_device, cache_mode, cls)
|
cache = casadm.start_cache(cache_device, cache_mode, cls)
|
||||||
@ -158,8 +164,13 @@ def test_recovery_unplug_cache_raw(cache_mode, cls):
|
|||||||
with TestRun.step("Copy file from core device and check md5sum."):
|
with TestRun.step("Copy file from core device and check md5sum."):
|
||||||
copy_file(source=core_device.path, target=target_file.full_path,
|
copy_file(source=core_device.path, target=target_file.full_path,
|
||||||
size=test_file_size, direct="iflag")
|
size=test_file_size, direct="iflag")
|
||||||
compare_files(source_file, target_file)
|
target_file_md5 = target_file.md5sum()
|
||||||
|
compare_files(source_file_md5, target_file_md5)
|
||||||
|
|
||||||
with TestRun.step("Cleanup core device and remove test files."):
|
with TestRun.step("Cleanup core device and remove test files."):
|
||||||
|
try:
|
||||||
target_file.remove()
|
target_file.remove()
|
||||||
source_file.remove()
|
source_file.remove()
|
||||||
|
except Exception:
|
||||||
|
# On some OSes files at /tmp location are automatically removed after DUT hard reset
|
||||||
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user