Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ disable_by_id_check = true
# shares space with the cache metadata on the 'metadata_dev' device.
#
# cache_dev = '/dev/vdc'

# Optional cache policy name to override the default in dm-cache tests.
# If specified, all test devices use this policy instead of the default smq policy.
#
# cache_policy = 'mq'
76 changes: 20 additions & 56 deletions src/dmtest/cache/resize_origin_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ def check_sized_metadata(cmeta, old_cache_dump, new_origin_size):
check_mappings_truncation(cmeta, old_cache_dump, new_nr_origin_blocks)


def expand_origin_with_reload(fix, policy_name):
def t_expand_origin_with_reload(fix):
cfg = fix.cfg
fast_dev = cfg["metadata_dev"]
origin_dev = cfg["data_dev"]
cache_dev = cfg.get("cache_dev", None)
policy_name = cfg.get("cache_policy", "smq")

block_size = units.kilo(32)
cache_size = units.meg(128)
Expand Down Expand Up @@ -118,11 +119,12 @@ def expand_origin_with_reload(fix, policy_name):
check_sized_metadata(cmeta, cdump.path, new_origin_size)


def shrink_origin_with_reload_drops_mappings(fix, policy_name):
def t_shrink_origin_with_reload_drops_mappings(fix):
cfg = fix.cfg
fast_dev = cfg["metadata_dev"]
origin_dev = cfg["data_dev"]
cache_dev = cfg.get("cache_dev", None)
policy_name = cfg.get("cache_policy", "smq")

block_size = units.kilo(32)
cache_size = units.meg(128)
Expand Down Expand Up @@ -163,11 +165,12 @@ def shrink_origin_with_reload_drops_mappings(fix, policy_name):
# Actually there's no differences between teardown and reload while shrinking
# the origin, as we always have to load a new dm-cache table to change the
# target length. Here we test both the approaches to ensure test coverage.
def shrink_origin_with_teardown_drops_mappings(fix, policy_name):
def t_shrink_origin_with_teardown_drops_mappings(fix):
cfg = fix.cfg
fast_dev = cfg["metadata_dev"]
origin_dev = cfg["data_dev"]
cache_dev = cfg.get("cache_dev", None)
policy_name = cfg.get("cache_policy", "smq")

block_size = units.kilo(32)
cache_size = units.meg(128)
Expand Down Expand Up @@ -206,11 +209,12 @@ def shrink_origin_with_teardown_drops_mappings(fix, policy_name):
check_sized_metadata(cmeta, cdump.path, new_origin_size)


def shrink_origin_with_reload_should_fail_if_blocks_dirty(fix, policy_name):
def t_shrink_origin_with_reload_should_fail_if_blocks_dirty(fix):
cfg = fix.cfg
fast_dev = cfg["metadata_dev"]
origin_dev = cfg["data_dev"]
cache_dev = cfg.get("cache_dev", None)
policy_name = cfg.get("cache_policy", "smq")

block_size = units.kilo(32)
cache_size = units.meg(128)
Expand Down Expand Up @@ -250,11 +254,12 @@ def shrink_origin_with_reload_should_fail_if_blocks_dirty(fix, policy_name):
raise Exception("shrink cache origin succeeded without error")


def shrink_origin_with_teardown_should_fail_if_blocks_dirty(fix, policy_name):
def t_shrink_origin_with_teardown_should_fail_if_blocks_dirty(fix):
cfg = fix.cfg
fast_dev = cfg["metadata_dev"]
origin_dev = cfg["data_dev"]
cache_dev = cfg.get("cache_dev", None)
policy_name = cfg.get("cache_policy", "smq")

block_size = units.kilo(32)
cache_size = units.meg(128)
Expand Down Expand Up @@ -294,62 +299,21 @@ def shrink_origin_with_teardown_should_fail_if_blocks_dirty(fix, policy_name):
else:
raise Exception("shrink cache origin succeeded without error")


def t_expand_origin_with_reload_mq(fix):
expand_origin_with_reload(fix, "mq")

def t_expand_origin_with_reload_smq(fix):
expand_origin_with_reload(fix, "smq")

def t_shrink_origin_with_reload_drops_mappings_mq(fix):
shrink_origin_with_reload_drops_mappings(fix, "mq")

def t_shrink_origin_with_reload_drops_mappings_smq(fix):
shrink_origin_with_reload_drops_mappings(fix, "smq")

def t_shrink_origin_with_teardown_drops_mappings_mq(fix):
shrink_origin_with_teardown_drops_mappings(fix, "mq")

def t_shrink_origin_with_teardown_drops_mappings_smq(fix):
shrink_origin_with_teardown_drops_mappings(fix, "smq")

def t_shrink_origin_with_reload_should_fail_if_blocks_dirty_mq(fix):
shrink_origin_with_reload_should_fail_if_blocks_dirty(fix, "mq")

def t_shrink_origin_with_reload_should_fail_if_blocks_dirty_smq(fix):
shrink_origin_with_reload_should_fail_if_blocks_dirty(fix, "smq")

def t_shrink_origin_with_teardown_should_fail_if_blocks_dirty_mq(fix):
shrink_origin_with_teardown_should_fail_if_blocks_dirty(fix, "mq")

def t_shrink_origin_with_teardown_should_fail_if_blocks_dirty_smq(fix):
shrink_origin_with_teardown_should_fail_if_blocks_dirty(fix, "smq")

#----------------------------------------------------------------

def register(tests):
tests.register_batch(
"/cache/resize/",
[
("expand_origin_with_reload_mq",
t_expand_origin_with_reload_mq),
("expand_origin_with_reload_smq",
t_expand_origin_with_reload_smq),
("shrink_origin_with_reload_drops_mappings_mq",
t_shrink_origin_with_reload_drops_mappings_mq),
("shrink_origin_with_reload_drops_mappings_smq",
t_shrink_origin_with_reload_drops_mappings_smq),
("shrink_origin_with_teardown_drops_mappings_mq",
t_shrink_origin_with_teardown_drops_mappings_mq),
("shrink_origin_with_teardown_drops_mappings_smq",
t_shrink_origin_with_teardown_drops_mappings_smq),
("shrink_origin_with_reload_should_fail_if_blocks_dirty_mq",
t_shrink_origin_with_reload_should_fail_if_blocks_dirty_mq),
("shrink_origin_with_reload_should_fail_if_blocks_dirty_smq",
t_shrink_origin_with_reload_should_fail_if_blocks_dirty_smq),
("shrink_origin_with_teardown_should_fail_if_blocks_dirty_mq",
t_shrink_origin_with_teardown_should_fail_if_blocks_dirty_mq),
("shrink_origin_with_teardown_should_fail_if_blocks_dirty_smq",
t_shrink_origin_with_teardown_should_fail_if_blocks_dirty_smq),
("expand_origin_with_reload",
t_expand_origin_with_reload),
("shrink_origin_with_reload_drops_mappings",
t_shrink_origin_with_reload_drops_mappings),
("shrink_origin_with_teardown_drops_mappings",
t_shrink_origin_with_teardown_drops_mappings),
("shrink_origin_with_reload_should_fail_if_blocks_dirty",
t_shrink_origin_with_reload_should_fail_if_blocks_dirty),
("shrink_origin_with_teardown_should_fail_if_blocks_dirty",
t_shrink_origin_with_teardown_should_fail_if_blocks_dirty),
],
)
14 changes: 4 additions & 10 deletions src/dmtest/cache/small_config_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

#----------------------------------------------------------------

def small_config(fix, policy):
def t_small_config(fix):
cfg = fix.cfg
fast_dev = cfg["metadata_dev"]
origin_dev = cfg["data_dev"]
cache_dev = cfg.get("cache_dev", None)
policy_name = cfg.get("cache_policy", "smq")

stack = ManagedCacheStack(
fast_dev,
Expand All @@ -20,24 +21,17 @@ def small_config(fix, policy):
block_size = units.kilo(32),
cache_size = units.kilo(50),
target_len = units.kilo(50),
policy = policy,
policy = CachePolicy(policy_name),
)
with stack.activate():
pass

def t_small_config_mq(fix):
small_config(fix, CachePolicy("mq"))

def t_small_config_smq(fix):
small_config(fix, CachePolicy("smq"))

#----------------------------------------------------------------

def register(tests):
tests.register_batch(
"/cache/creation/",
[
("small_config_mq", t_small_config_mq),
("small_config_smq", t_small_config_smq),
("small_config", t_small_config),
],
)
36 changes: 6 additions & 30 deletions test_dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -314,50 +314,26 @@ targets = [ "vdo",]
executables = [ "blockdev", "dd", "dmsetup", "vdoformat",]
targets = [ "vdo",]

["/cache/creation/small_config_mq"]
["/cache/creation/small_config"]
executables = [ "blockdev", "cache_check", "dd", "dmsetup",]
targets = [ "cache", "linear",]

["/cache/creation/small_config_smq"]
executables = [ "blockdev", "cache_check", "dd", "dmsetup",]
targets = [ "cache", "linear",]

["/cache/resize/expand_origin_with_reload_mq"]
executables = [ "blockdev", "cache_check", "cache_dump", "cache_restore", "dmsetup",]
targets = [ "cache", "linear",]

["/cache/resize/expand_origin_with_reload_smq"]
executables = [ "blockdev", "cache_check", "cache_dump", "cache_restore", "dmsetup",]
targets = [ "cache", "linear",]

["/cache/resize/shrink_origin_with_reload_drops_mappings_mq"]
["/cache/resize/expand_origin_with_reload"]
executables = [ "blockdev", "cache_check", "cache_dump", "cache_restore", "dmsetup",]
targets = [ "cache", "linear",]

["/cache/resize/shrink_origin_with_reload_drops_mappings_smq"]
["/cache/resize/shrink_origin_with_reload_drops_mappings"]
executables = [ "blockdev", "cache_check", "cache_dump", "cache_restore", "dmsetup",]
targets = [ "cache", "linear",]

["/cache/resize/shrink_origin_with_teardown_drops_mappings_mq"]
["/cache/resize/shrink_origin_with_teardown_drops_mappings"]
executables = [ "blockdev", "cache_check", "cache_dump", "cache_restore", "dmsetup",]
targets = [ "cache", "linear",]

["/cache/resize/shrink_origin_with_teardown_drops_mappings_smq"]
executables = [ "blockdev", "cache_check", "cache_dump", "cache_restore", "dmsetup",]
targets = [ "cache", "linear",]

["/cache/resize/shrink_origin_with_reload_should_fail_if_blocks_dirty_mq"]
executables = [ "blockdev", "cache_check", "cache_restore", "dmsetup",]
targets = [ "cache", "linear",]

["/cache/resize/shrink_origin_with_reload_should_fail_if_blocks_dirty_smq"]
executables = [ "blockdev", "cache_check", "cache_restore", "dmsetup",]
targets = [ "cache", "linear",]

["/cache/resize/shrink_origin_with_teardown_should_fail_if_blocks_dirty_mq"]
["/cache/resize/shrink_origin_with_reload_should_fail_if_blocks_dirty"]
executables = [ "blockdev", "cache_check", "cache_restore", "dmsetup",]
targets = [ "cache", "linear",]

["/cache/resize/shrink_origin_with_teardown_should_fail_if_blocks_dirty_smq"]
["/cache/resize/shrink_origin_with_teardown_should_fail_if_blocks_dirty"]
executables = [ "blockdev", "cache_check", "cache_restore", "dmsetup",]
targets = [ "cache", "linear",]