tests: fix broken snapshot create tests

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

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2017-05-17 12:40:57 +02:00 committed by Wolfgang Bumiller
parent d47ea4d05a
commit 101a1b3f95

View File

@ -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);