Skip to content

Commit f2fef78

Browse files
committed
storage: limit data written per VDI with --write-volume-cap
Refactor stream management to support arbitrary span distributions. The new StreamSpan dataclass encapsulates stream metadata and operations, while partially_populate_device() now supports configurable span counts and skip patterns. This required to upgrade randstream to the version 0.6.0 which supports arbitrary position. The default cap is 2GiB. Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
1 parent 3ee475f commit f2fef78

5 files changed

Lines changed: 179 additions & 68 deletions

File tree

conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ def pytest_addoption(parser: pytest.Parser) -> None:
110110
default="1GiB",
111111
help="Default volume size for tests"
112112
)
113+
parser.addoption(
114+
"--write-volume-cap",
115+
action="store",
116+
default="2GiB",
117+
help="Maximum amount of data written to a volume"
118+
)
113119

114120
def pytest_configure(config: pytest.Config) -> None:
115121
global_config.ignore_ssh_banner = config.getoption('--ignore-ssh-banner')
@@ -119,6 +125,9 @@ def pytest_configure(config: pytest.Config) -> None:
119125
volume_size = config.getoption('--volume-size')
120126
assert volume_size is not None
121127
global_config.volume_size = parse_size(volume_size)
128+
write_volume_cap = config.getoption('--write-volume-cap')
129+
assert write_volume_cap is not None
130+
global_config.write_volume_cap = parse_size(write_volume_cap)
122131

123132
def pytest_generate_tests(metafunc: pytest.Metafunc) -> None:
124133
if "vm_ref" in metafunc.fixturenames:

lib/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
ignore_ssh_banner = False
44
ssh_output_max_lines = 20
55
volume_size = 1 * GiB
6+
write_volume_cap = 2 * GiB
67

78
def sr_device_config(datakey: str, *, required: list[str] = []) -> dict[str, str]:
89
import data # import here to avoid depending on this user file for collecting tests

tests/storage/nfs/test_nfs_sr.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,17 @@ def test_invalid_vdi_size(self, nfs_sr: SR, image_format: ImageFormat):
140140
@pytest.mark.usefixtures('vm_ref')
141141
@pytest.mark.parametrize('dispatch_nfs', ['vm_on_nfs_sr', 'vm_on_nfs4_sr'], indirect=True)
142142
@pytest.mark.parametrize("compression", ["none", "gzip", "zstd"])
143-
def test_xva_export_import(self, dispatch_nfs: VM, compression: XVACompression, temp_large_dir: str, defer: Defer) \
144-
-> None:
145-
if "NFS4" in dispatch_nfs.vdis[0].sr.get_name_label() and config.volume_size > 20 * GiB:
143+
def test_xva_export_import(self, dispatch_nfs: VM, compression: XVACompression, temp_large_dir: str,
144+
defer: Defer) -> None:
145+
if "NFS4" in dispatch_nfs.vdis[0].sr.get_name_label() and config.write_volume_cap > 20 * GiB:
146146
pytest.skip("Skipping NFSv4 large VDI test (known performance issue)")
147147
xva_export_import(dispatch_nfs, compression, temp_large_dir, defer)
148148

149149
@pytest.mark.small_vm
150150
@pytest.mark.parametrize('dispatch_nfs', ['nfs_sr', 'nfs4_sr'], indirect=True)
151151
def test_vdi_export_import(self, storage_test_vm: VM, dispatch_nfs: SR, image_format: ImageFormat,
152152
temp_large_dir: str, defer: Defer) -> None:
153-
if "NFS4" in dispatch_nfs.get_name_label() and config.volume_size > 20 * GiB:
153+
if "NFS4" in dispatch_nfs.get_name_label() and config.write_volume_cap > 20 * GiB:
154154
pytest.skip("Skipping NFSv4 large VDI test (known performance issue)")
155155
vdi_export_import(storage_test_vm, dispatch_nfs, image_format, temp_large_dir, defer)
156156

0 commit comments

Comments
 (0)