[pve-devel] [PATCH qemu-server 3/4] tests: fix broken snapshot create tests

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed May 17 12:40:57 CEST 2017


by mocking de/activate vmstate volumes. these were broken by
3a8deb551f2c7648865437961b3593d11bf0591b, which introduced
activating/deactivating vmstate volumes for KRBD

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 test/snapshot-test.pm | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/test/snapshot-test.pm b/test/snapshot-test.pm
index 43b1515..5620d01 100644
--- a/test/snapshot-test.pm
+++ b/test/snapshot-test.pm
@@ -104,6 +104,24 @@ sub mocked_volume_rollback_is_possible {
     die "volume_rollback_is_possible failed\n";
 }
 
+sub mocked_activate_volumes {
+    my ($storecfg, $volumes) = @_;
+    die "Storage config not mocked! aborting\n"
+	if defined($storecfg);
+    die "wrong volume - fake vmstate expected!\n"
+	if ((scalar @$volumes != 1) || @$volumes[0] ne "somestorage:state-volume");
+    return;
+}
+
+sub mocked_deactivate_volumes {
+    my ($storecfg, $volumes) = @_;
+    die "Storage config not mocked! aborting\n"
+	if defined($storecfg);
+    die "wrong volume - fake vmstate expected!\n"
+	if ((scalar @$volumes != 1) || @$volumes[0] ne "somestorage:state-volume");
+    return;
+}
+
 sub mocked_vdisk_free {
     my ($storecfg, $vmstate) = @_;
     die "Storage config not mocked! aborting\n"
@@ -454,6 +472,8 @@ printf("Setting up Mocking for PVE::Storage\n");
 my $storage_module = new Test::MockModule('PVE::Storage');
 $storage_module->mock('config', sub { return undef; });
 $storage_module->mock('path', sub { return "/some/store/statefile/path"; });
+$storage_module->mock('activate_volumes', \&mocked_activate_volumes);
+$storage_module->mock('deactivate_volumes', \&mocked_deactivate_volumes);
 $storage_module->mock('vdisk_free', \&mocked_vdisk_free);
 $storage_module->mock('volume_snapshot', \&mocked_volume_snapshot);
 $storage_module->mock('volume_snapshot_delete', \&mocked_volume_snapshot_delete);
-- 
2.1.4





More information about the pve-devel mailing list