Test update

Update test after separating functions from this test to other files.
Add 'dut_config' to .gitignore.

Signed-off-by: Slawomir_Jankowski <slawomir.jankowski@intel.com>
This commit is contained in:
Slawomir_Jankowski 2019-11-27 12:35:35 +01:00 committed by Ostrokrzew
parent 8356174d80
commit 4c77a7a4ff
2 changed files with 29 additions and 42 deletions

View File

@ -1,2 +1,3 @@
plugins/ plugins/
results/ results/
config/dut_config.yml

View File

@ -13,7 +13,6 @@ from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
from core.test_run import TestRun from core.test_run import TestRun
from test_tools import fs_utils from test_tools import fs_utils
from test_tools.disk_utils import Filesystem from test_tools.disk_utils import Filesystem
from test_utils.filesystem.file import File
from test_utils.size import Size, Unit from test_utils.size import Size, Unit
iterations_per_config = 50 iterations_per_config = 50
@ -159,9 +158,8 @@ def test_stress_reload_cache(cache_mode):
- CAS device loads successfully. - CAS device loads successfully.
- No data corruption. - No data corruption.
""" """
with TestRun.step("Prepare cache and core. Create test file and count it's checksum."): with TestRun.step("Prepare cache and core. Create test file and count its checksum."):
cache, core, md5_before_load, size_before_load, permissions_before_load = \ cache, core, file, file_before = prepare_with_file_creation(cache_mode)
prepare_with_file_creation(cache_mode)
for _ in TestRun.iteration(range(0, iterations_per_config), for _ in TestRun.iteration(range(0, iterations_per_config),
f"Stop and load cache {iterations_per_config} times."): f"Stop and load cache {iterations_per_config} times."):
@ -180,7 +178,12 @@ def test_stress_reload_cache(cache_mode):
TestRun.fail(f"Expected cores count: 1; Actual cores count: {cores_count}.") TestRun.fail(f"Expected cores count: 1; Actual cores count: {cores_count}.")
with TestRun.step("Check md5 of test file."): with TestRun.step("Check md5 of test file."):
check_files(core, size_before_load, permissions_before_load, md5_before_load) core.mount(mount_point)
file_after = file.get_properties()
if file_after != file_before:
TestRun.LOGGER.error("File properties before and after are different.")
core.unmount()
with TestRun.step("Stop all caches."): with TestRun.step("Stop all caches."):
casadm.stop_all_caches() casadm.stop_all_caches()
@ -197,9 +200,8 @@ def test_stress_add_remove_core(cache_mode):
- Core is added and removed successfully. - Core is added and removed successfully.
- No data corruption. - No data corruption.
""" """
with TestRun.step("Prepare cache and core. Create test file and count it's checksum."): with TestRun.step("Prepare cache and core. Create test file and count its checksum."):
cache, core, md5_before_load, size_before_load, permissions_before_load = \ cache, core, file, file_before = prepare_with_file_creation(cache_mode)
prepare_with_file_creation(cache_mode)
for _ in TestRun.iteration(range(0, iterations_per_config), for _ in TestRun.iteration(range(0, iterations_per_config),
f"Add and remove core {iterations_per_config} times."): f"Add and remove core {iterations_per_config} times."):
@ -221,7 +223,12 @@ def test_stress_add_remove_core(cache_mode):
TestRun.fail(f"Expected cores count: 1; Actual cores count: {cores_count}.") TestRun.fail(f"Expected cores count: 1; Actual cores count: {cores_count}.")
with TestRun.step("Check md5 of test file."): with TestRun.step("Check md5 of test file."):
check_files(core, size_before_load, permissions_before_load, md5_before_load) core.mount(mount_point)
file_after = file.get_properties()
if file_after != file_before:
TestRun.LOGGER.error("File properties before and after are different.")
core.unmount()
with TestRun.step("Stop all caches."): with TestRun.step("Stop all caches."):
casadm.stop_all_caches() casadm.stop_all_caches()
@ -238,9 +245,9 @@ def test_stress_reload_module(cache_mode):
- CAS modules reloads with no errors. - CAS modules reloads with no errors.
- No data corruption. - No data corruption.
""" """
with TestRun.step("Prepare cache and core. Create test file and count it's checksum."): with TestRun.step("Prepare cache and core. Create test file and count its checksum."):
cache, core, md5_before_load, size_before_load, permissions_before_load = \ cache, core, file, file_before = prepare_with_file_creation(cache_mode)
prepare_with_file_creation(cache_mode)
with TestRun.step("Save current cache configuration."): with TestRun.step("Save current cache configuration."):
cache_config = cache.get_cache_config() cache_config = cache.get_cache_config()
@ -270,47 +277,26 @@ def test_stress_reload_module(cache_mode):
TestRun.fail("Cache configuration is different than before reloading modules.") TestRun.fail("Cache configuration is different than before reloading modules.")
with TestRun.step("Check md5 of test file."): with TestRun.step("Check md5 of test file."):
check_files(core, size_before_load, permissions_before_load, md5_before_load) core.mount(mount_point)
file_after = file.get_properties()
if file_after != file_before:
TestRun.LOGGER.error("File properties before and after are different.")
core.unmount()
with TestRun.step("Stop all caches."): with TestRun.step("Stop all caches."):
casadm.stop_all_caches() casadm.stop_all_caches()
def check_files(core, size_before, permissions_before, md5_before):
TestRun.LOGGER.info("Checking file md5.")
core.mount(mount_point)
file_after = fs_utils.parse_ls_output(fs_utils.ls(test_file_path))[0]
md5_after = file_after.md5sum()
if md5_before != md5_after:
TestRun.LOGGER.error(f"Md5 before ({md5_before}) and after ({md5_after}) are different.")
if permissions_before.user == file_after.permissions.user:
TestRun.LOGGER.error(f"User permissions before ({permissions_before.user}) "
f"and after ({file_after.permissions.user}) are different.")
if permissions_before.group != file_after.permissions.group:
TestRun.LOGGER.error(f"Group permissions before ({permissions_before.group}) "
f"and after ({file_after.permissions.group}) are different.")
if permissions_before.other != file_after.permissions.other:
TestRun.LOGGER.error(f"Other permissions before ({permissions_before.other}) "
f"and after ({file_after.permissions.other}) are different.")
if size_before != file_after.size:
TestRun.LOGGER.error(f"Size before ({size_before}) and after ({file_after.size}) "
f"are different.")
core.unmount()
def prepare_with_file_creation(config): def prepare_with_file_creation(config):
cache_dev, core_dev = prepare() cache_dev, core_dev = prepare()
cache = casadm.start_cache(cache_dev, config, force=True) cache = casadm.start_cache(cache_dev, config, force=True)
core = cache.add_core(core_dev) core = cache.add_core(core_dev)
core.create_filesystem(Filesystem.ext3) core.create_filesystem(Filesystem.ext3)
core.mount(mount_point) core.mount(mount_point)
file = File.create_file(test_file_path) file = fs_utils.create_test_file(test_file_path)
file.write("Test content") file_properties = file.get_properties()
md5_before_load = file.md5sum()
size_before_load = file.size
permissions_before_load = file.permissions
core.unmount() core.unmount()
return cache, core, md5_before_load, size_before_load, permissions_before_load return cache, core, file, file_properties
def prepare(): def prepare():