[PATCH pve-storage v1 35/54] test: list volumes: fix broken test checking for vmlist modifications

Max R. Carrara
2026-04-22T11:19:09Z

This test never actually did anything, since it didn't use the mocked
vmlist at all. Therefore, fix it by comparing the vmlist with its
original after all tests have run.

Verified that this test catches modifications to the vmlist by
manually adding a line that modifies it in the `list_volumes()`
method, running the tests to see if this fails, and then removing that
line again.

Signed-off-by: Max R. Carrara <m.carrara@proxmox.com>
---
src/test/list_volumes_test.pm | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/src/test/list_volumes_test.pm b/src/test/list_volumes_test.pm
index 053ebbe3..2d941b60 100644
--- a/src/test/list_volumes_test.pm
+++ b/src/test/list_volumes_test.pm
@@ -719,26 +719,19 @@ sub main() {
my $plan = scalar @tests;
plan tests => $plan + 1;

- {
- # don't accidentally modify vmlist, see bug report
- # https://pve.proxmox.com/pipermail/pve-devel/2020-January/041096.html
- my $scfg_with_type = { path => $storage_dir, type => 'dir' };
- my $original_vmlist = { ids => {} };
- my $tested_vmlist = dclone($original_vmlist);
-
- PVE::Storage::Plugin->list_volumes('sid', $scfg_with_type, undef, ['images']);
-
- is_deeply($tested_vmlist, $original_vmlist, 'PVE::Cluster::vmlist remains unmodified')
- || diag(
- "Expected vmlist to remain\n",
- explain($original_vmlist),
- "but it turned to\n",
- explain($tested_vmlist),
- );
- }
+ # Keep the original vmlist around in order to check whether it was modified
+ # after running all the tests. See:
+ # https://pve.proxmox.com/pipermail/pve-devel/2020-January/041096.html
+ my $original_vmlist = dclone(PVE::Cluster::get_vmlist());

run_legacy_tests();

+ my $vmlist = PVE::Cluster::get_vmlist();
+
+ is_deeply(
+ $vmlist, $original_vmlist, 'Result of PVE::Cluster::get_vmlist remains unmodified',
+ );
+
done_testing();

return;
--
2.47.3