forked from jthornber/dmtest-python
-
Notifications
You must be signed in to change notification settings - Fork 3
Add VDO tests converted from vdo-devel perl tests #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
raeburn
wants to merge
17
commits into
device-mapper-utils:main
Choose a base branch
from
raeburn:vdo-convert
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
edfffcf
Switch from toml package to tomllib + tomli_w
raeburn 5eb7d8a
Reformatted and sorted test_dependencies.toml.
raeburn 10e4b19
Simplify test registration in VDO tests
raeburn 92e04b2
Add module docstring to VDO tests
raeburn 7964c78
Move wait_until_packer_only() to utils.py
raeburn 56cd6eb
Remove udevadm settle calls from pre-existing VDO tests
raeburn 8f2648a
Add mounted_fs() context manager and VDO utility functions
raeburn ec2f647
Add basic VDO and deduplication tests
raeburn 766f5a1
Add VDO full device and ENOSPC tests
raeburn ed1de57
Add VDO direct block I/O tests
raeburn 0247fb7
Add VDO compression and hash collision tests
raeburn a21cef9
Add VDO data generation tests
raeburn 85fec49
Add VDO discard and zero block tests
raeburn 12f9bef
Add VDO device management and dmsetup interaction tests
raeburn cdd2dac
Add VDO logical and physical growth tests
raeburn d274f11
Add VDO kernel formatting tests
raeburn d6485ab
Add VDO memory allocation failure test
raeburn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| toml==0.10.2 | ||
| pudb | ||
| numpy | ||
| pudb | ||
| pyyaml | ||
| tomli_w |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| """VDO basic functional test. | ||
|
|
||
| Verifies VDO persistence by writing data to a filesystem on VDO, stopping | ||
| the VDO device, restarting it, and verifying the data is still readable. | ||
| """ | ||
| from dmtest.assertions import assert_equal, assert_string_in | ||
| from dmtest.utils import get_dmesg_log | ||
| from dmtest.vdo.utils import standard_vdo, standard_stack, mounted_fs | ||
| import dmtest.process as process | ||
| import time | ||
|
|
||
| def t_basic(fix): | ||
| """Basic VDO functional test: write files, stop/start VDO, verify data persists.""" | ||
| # Create VDO with slab_bits=17 (SLAB_BITS_SMALL) | ||
| with standard_vdo(fix, slab_bits=17) as vdo: | ||
| with mounted_fs(vdo.path, format=True) as mount_point: | ||
| # Create file foo1 with "Hello World" | ||
| file1 = f"{mount_point}/foo1" | ||
| process.run(f"bash -c 'echo Hello World > {file1}'") | ||
|
|
||
| # Create subdirectory dir2 | ||
| dir2 = f"{mount_point}/dir2" | ||
| process.run(f"mkdir {dir2}") | ||
|
|
||
| # Copy foo1 to dir2/foo2 | ||
| file2 = f"{dir2}/foo2" | ||
| process.run(f"cp {file1} {file2}") | ||
|
|
||
| # Copy foo1 to foo3 | ||
| file3 = f"{mount_point}/foo3" | ||
| process.run(f"cp {file1} {file3}") | ||
|
|
||
| # Drop caches | ||
| process.run("echo 1 > /proc/sys/vm/drop_caches") | ||
|
|
||
| # Verify content of foo1 and foo2 | ||
| result1 = process.run(f"cat {file1}") | ||
| assert_equal(result1[1].strip(), "Hello World") | ||
|
|
||
| result2 = process.run(f"cat {file2}") | ||
| assert_equal(result2[1].strip(), "Hello World") | ||
|
|
||
| # VDO device is now stopped (exited context manager) | ||
| # Get kernel log timestamp before restarting | ||
| start_time = time.time() | ||
|
|
||
| # Restart VDO device without reformatting | ||
| with standard_vdo(fix, format=False, slab_bits=17) as vdo: | ||
| with mounted_fs(vdo.path) as mount_point: | ||
| # Verify content of foo3 | ||
| file3 = f"{mount_point}/foo3" | ||
| result3 = process.run(f"cat {file3}") | ||
| assert_equal(result3[1].strip(), "Hello World") | ||
|
|
||
| # Check kernel log for VDO startup message | ||
| log_message = get_dmesg_log(start_time) | ||
| assert_string_in(log_message, "VDO commencing normal operation") | ||
|
|
||
| def register(tests): | ||
| tests.register("/vdo/basic/basic01", t_basic) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| """ | ||
| VDO BasicFSDedupe test - Filesystem-level deduplication verification | ||
| """ | ||
| import logging as log | ||
| import os | ||
| import shutil | ||
| import tempfile | ||
|
|
||
| from dmtest.assertions import assert_near | ||
| from dmtest.gendatablocks import make_block_range | ||
| from dmtest.vdo.stats import vdo_stats, make_delta_stats | ||
| from dmtest.vdo.utils import standard_vdo, fsync, mounted_fs | ||
|
|
||
|
|
||
| def t_basic_fs_dedupe(fix) -> None: | ||
| """ | ||
| Basic filesystem-level deduplication test that writes a dataset twice | ||
| and verifies deduplication achieves expected space savings. | ||
| """ | ||
| MB = 1024 * 1024 | ||
| num_files = 32 | ||
| file_size_mb = 8 | ||
| blocks_per_file = file_size_mb * MB // 4096 # 8MB / 4KB = 2048 blocks | ||
|
|
||
| with standard_vdo(fix) as vdo: | ||
| with mounted_fs(vdo.path, format=True, lazy_itable_init=False) as mount_point: | ||
| # Create subdirectories on VDO filesystem | ||
| original_dir = os.path.join(mount_point, "original") | ||
| copy1_dir = os.path.join(mount_point, "copy1") | ||
| os.makedirs(original_dir) | ||
| os.makedirs(copy1_dir) | ||
|
|
||
| # Record initial stats after filesystem setup | ||
| fsync(vdo.path) | ||
| initial_stats = vdo_stats(vdo) | ||
|
|
||
| # Generate dataset in a scratch directory | ||
| with tempfile.TemporaryDirectory() as scratch_dir: | ||
| dataset_dir = os.path.join(scratch_dir, "dataset") | ||
| os.makedirs(dataset_dir) | ||
|
|
||
| log.info(f"Generating dataset: {num_files} files × {file_size_mb}MB each = 256MB total") | ||
| for i in range(num_files): | ||
| file_path = os.path.join(dataset_dir, f"file_{i:08d}") | ||
| # Create the file first | ||
| with open(file_path, 'w') as f: | ||
| pass | ||
| # Write data to the file | ||
| block_range = make_block_range(file_path, blocks_per_file) | ||
| block_range.write(f"BFD{i:04d}", dedupe=0.0, fsync=False) | ||
|
|
||
| # Copy dataset to "original" directory | ||
| log.info("Copying dataset to 'original' directory") | ||
| shutil.copytree(dataset_dir, os.path.join(original_dir, "data")) | ||
|
|
||
| # Sync and check stats after first write | ||
| fsync(vdo.path) | ||
| stats_after_first = vdo_stats(vdo) | ||
| delta_first = make_delta_stats(stats_after_first, initial_stats) | ||
|
|
||
| data_blocks = delta_first['dataBlocksUsed'] | ||
| logical_blocks = delta_first['logicalBlocksUsed'] | ||
| ratio_first = data_blocks / logical_blocks if logical_blocks > 0 else 0 | ||
|
|
||
| log.info(f"After first write: data={data_blocks}, logical={logical_blocks}, ratio={ratio_first:.3f}") | ||
| # Verify minimal deduplication on first write (filesystem metadata may cause some variance) | ||
| assert_near(ratio_first, 1.0, 0.1, "Data-to-logical ratio after first write") | ||
|
|
||
| # Copy the same dataset to "copy1" directory (duplicate copy) | ||
| log.info("Copying dataset to 'copy1' directory (duplicate)") | ||
| shutil.copytree(dataset_dir, os.path.join(copy1_dir, "data")) | ||
|
|
||
| # Sync and check stats after second write | ||
| fsync(vdo.path) | ||
| stats_after_second = vdo_stats(vdo) | ||
| delta_second = make_delta_stats(stats_after_second, initial_stats) | ||
|
|
||
| data_blocks_2 = delta_second['dataBlocksUsed'] | ||
| logical_blocks_2 = delta_second['logicalBlocksUsed'] | ||
| ratio_second = data_blocks_2 / logical_blocks_2 if logical_blocks_2 > 0 else 0 | ||
|
|
||
| log.info(f"After second write: data={data_blocks_2}, logical={logical_blocks_2}, ratio={ratio_second:.3f}") | ||
| # Verify significant deduplication on second write (~50% ratio expected) | ||
| assert_near(ratio_second, 0.5, 0.05, "Data-to-logical ratio after second write (with dedupe)") | ||
|
|
||
|
|
||
| def register(tests): | ||
| tests.register("/vdo/basic/fs-dedupe", t_basic_fs_dedupe) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird having tool improvements interspersed with new tests. I'd prefer to see tool and utility fixes and improvements described and justified on their own merits. I think it's too easy to overlook the broader implications of a change if it's not the main focus of the commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured this was a bugfix (to make concurrent invocations work) needed for one of the tests, not a significant improvement on its own.