Skip to content

Commit 1657a98

Browse files
Merge pull request #1717 from robertbaldyga/test-load-dirty
tests: Add test checking proper load of cache with dirty data
2 parents 7f821e5 + 19b5f83 commit 1657a98

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

test/functional/tests/initialize/test_initialize_load.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#
22
# Copyright(c) 2019-2022 Intel Corporation
33
# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd.
4+
# Copyright(c) 2026 Unvertical
45
# SPDX-License-Identifier: BSD-3-Clause
56
#
67

@@ -9,10 +10,12 @@
910
from api.cas import casadm, casadm_parser
1011
from api.cas.cache_config import (CleaningPolicy,
1112
CacheMode,
13+
CacheModeTrait,
1214
CacheLineSize,
1315
FlushParametersAlru,
1416
Time,
1517
FlushParametersAcp)
18+
from api.cas.casadm_params import StatsFilter
1619
from core.test_run import TestRun
1720
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
1821
from test_tools.fio.fio import Fio
@@ -142,3 +145,72 @@ def test_load_x_cores_to_one_cache(cache_mode, cleaning_policy, cache_line_size,
142145
with TestRun.step("Check if there are no error statistics."):
143146
if cache.get_statistics().error_stats.total_errors != 0:
144147
TestRun.fail("There are errors in the cache.")
148+
149+
@pytest.mark.parametrize("cache_mode", CacheMode.with_traits(CacheModeTrait.LazyWrites))
150+
@pytest.mark.parametrizex("cache_line_size", CacheLineSize)
151+
@pytest.mark.parametrizex("cleaning_policy", CleaningPolicy)
152+
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
153+
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
154+
def test_load_cache_dirty(cache_mode, cache_line_size, cleaning_policy):
155+
"""
156+
title: Load cache with dirty data after stopping it without flush
157+
description: |
158+
Verify that cache loads properly after being stopped with dirty data and no flush.
159+
pass_criteria:
160+
- Cache loads successfully.
161+
- There is dirty data on the cache after load.
162+
"""
163+
with TestRun.step("Prepare cache and core devices"):
164+
cache_dev = TestRun.disks['cache']
165+
cache_dev.create_partitions([Size(512, Unit.MebiByte)])
166+
cache_dev = cache_dev.partitions[0]
167+
core_dev = TestRun.disks['core']
168+
core_dev.create_partitions([Size(1, Unit.GibiByte)])
169+
core_dev = core_dev.partitions[0]
170+
171+
with TestRun.step("Start cache and add core"):
172+
cache = casadm.start_cache(cache_dev, cache_mode, cache_line_size, force=True)
173+
core = cache.add_core(core_dev)
174+
175+
with TestRun.step("Configure cleaning policy"):
176+
cache.set_cleaning_policy(cleaning_policy)
177+
if cleaning_policy == CleaningPolicy.alru:
178+
alru = FlushParametersAlru()
179+
alru.wake_up_time = Time(seconds=5)
180+
cache.set_params_alru(alru)
181+
if cleaning_policy == CleaningPolicy.acp:
182+
acp = FlushParametersAcp()
183+
acp.wake_up_time = Time(seconds=5)
184+
cache.set_params_acp(acp)
185+
186+
with TestRun.step("Run FIO on exported object"):
187+
fio = (Fio().create_command()
188+
.io_engine(IoEngine.libaio)
189+
.read_write(ReadWrite.write)
190+
.block_size(cache_line_size)
191+
.io_depth(64)
192+
.direct()
193+
.sync()
194+
.size(Size(1, Unit.GibiByte))
195+
.target(core.path)
196+
)
197+
fio.run()
198+
199+
with TestRun.step("Verify that cache has dirty data"):
200+
cache_stats = cache.get_statistics([StatsFilter.usage], percentage_val=True)
201+
if cache_stats.usage_stats.dirty < 0.5:
202+
TestRun.block("Ditry lower than 50%")
203+
204+
with TestRun.step("Stop cache without flush"):
205+
cache.stop(no_data_flush=True)
206+
207+
with TestRun.step("Load cache"):
208+
cache = casadm.load_cache(cache_dev)
209+
210+
with TestRun.step("Verify that cache still has dirty data"):
211+
cache_stats = cache.get_statistics([StatsFilter.usage], percentage_val=True)
212+
if cache_stats.usage_stats.dirty < 0.5:
213+
TestRun.fail("Ditry lower than 50%")
214+
215+
with TestRun.step("Stop cache"):
216+
cache.stop()

0 commit comments

Comments
 (0)