Skip to content
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

Fix up prediction tests to match new filesystem interface #3522

Merged
merged 1 commit into from
Jan 3, 2024
Merged
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
25 changes: 19 additions & 6 deletions tests/client-dbus/tests/udev/test_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _call_predict_usage(encrypted, device_sizes, *, fs_specs=None, overprovision
:param device_sizes: list of sizes of devices for pool
:type device_sizes: list of str
:param fs_specs: list of filesystem specs
:type fs_specs: list of str * Range
:type fs_specs: list of str * (Range or NoneType) * (Range or NoneType)
:param bool overprovision: whether it is allowed to overprovision the pool
"""
with subprocess.Popen(
Expand All @@ -66,7 +66,11 @@ def _call_predict_usage(encrypted, device_sizes, *, fs_specs=None, overprovision
+ (
[]
if fs_specs is None
else [f"--filesystem-size={size.magnitude}" for _, size in fs_specs]
else [
f"--filesystem-size={size.magnitude}"
for _, size, _ in fs_specs
if size is not None
]
)
+ (["--encrypted"] if encrypted else [])
+ ([] if overprovision else ["--no-overprovision"]),
Expand Down Expand Up @@ -105,7 +109,7 @@ def _possibly_add_filesystems(pool_object_path, *, fs_specs=None):

:param str pool_object_path: the D-Bus object path
:param fs_specs: the filesystem specs
:type fs_specs: list of str * Range or NoneType
:type fs_specs: list of str * (Range or NoneType) * (Range or NoneType)

:returns: the change in size of pool's TotalPhysicalUsed value
:rtype: Range
Expand All @@ -123,7 +127,16 @@ def _possibly_add_filesystems(pool_object_path, *, fs_specs=None):
message,
) = Pool.Methods.CreateFilesystems(
pool_proxy,
{"specs": map(lambda x: (x[0], (True, str(x[1].magnitude))), fs_specs)},
{
"specs": map(
lambda x: (
x[0],
(False, "") if x[1] is None else (True, str(x[1].magnitude)),
(False, "") if x[2] is None else (True, str(x[2].magnitude)),
),
fs_specs,
)
},
)

if return_code != 0:
Expand Down Expand Up @@ -302,7 +315,7 @@ def test_prediction_filesystems(self):
pool_name = random_string(5)
create_pool(pool_name, devnodes)
self.wait_for_pools(1)
self._test_prediction(pool_name, fs_specs=[("fs1", Range(1, TiB))])
self._test_prediction(pool_name, fs_specs=[("fs1", Range(1, TiB), None)])

def test_prediction_no_overprov(self):
"""
Expand All @@ -317,5 +330,5 @@ def test_prediction_no_overprov(self):
create_pool(pool_name, devnodes, overprovision=False)
self.wait_for_pools(1)
self._test_prediction(
pool_name, fs_specs=[("fs1", Range(2, GiB))], overprovision=False
pool_name, fs_specs=[("fs1", Range(2, GiB), None)], overprovision=False
)