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
750b493
Add mounted_fs() context manager and VDO utility constants
raeburn 777a3d9
Add basic VDO and deduplication tests
raeburn 25ee700
Add VDO full device and ENOSPC tests
raeburn 26ec5d9
Add VDO direct block I/O tests
raeburn 1a5db21
Move and rename wait_until_packer_only() in utils.py
raeburn 8b24e2c
Add VDO compression and hash collision tests
raeburn 6d75a07
Add VDO data generation tests
raeburn 1c41cbf
Add VDO discard and zero block tests
raeburn a42dd67
Add VDO table-line parameter validation tests
raeburn 7247c43
Add VDO device management and dmsetup interaction tests
raeburn 69dd722
Add VDO sysfs interface tests
raeburn 93d6db2
Add VDO logical growth tests
raeburn deeaf82
Add VDO physical growth tests
raeburn 1cb18fd
Add VDO kernel module version checking helpers
raeburn f9348c1
Add VDO kernel formatting tests
raeburn 3ba63c2
Add VDO memory allocation failure test
raeburn d5ed38e
Add VDO thread configuration tests
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
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.