Skip to content

Commit

Permalink
Merge pull request #3522 from mulkieran/filesystem-spec-fix
Browse files Browse the repository at this point in the history
Fix up prediction tests to match new filesystem interface
  • Loading branch information
mulkieran authored Jan 3, 2024
2 parents 6ec24c5 + 7ec9ddc commit 38f40fa
Showing 1 changed file with 19 additions and 6 deletions.
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
)

0 comments on commit 38f40fa

Please sign in to comment.