eval {
PVE::Storage::volume_snapshot($cfg, "$storagename:$vmdisk", 'snap1');
- if ( 1 !=
- PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$vmdisk", 'snap1')) {
+
+ my $blockers = [];
+ my $res = PVE::Storage::volume_rollback_is_possible(
+ $cfg,
+ "$storagename:$vmdisk",
+ 'snap1',
+ $blockers,
+ );
+ if ($res != 1) {
+ $count++;
+ warn "Test6 a: Rollback should be possible";
+ }
+ if (scalar($blockers->@*) != 0) {
$count++;
- warn "Test6 a: Rollback sould possible"
+ warn "Test6 a: 'blockers' should be empty";
}
};
if ($@) {
if ( 1 !=
PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$vmbase", 'snap1')) {
$count++;
- warn "Test6 b: Rollback sould possible"
+ warn "Test6 b: Rollback should be possible";
}
};
if ($@) {
if ( 1 !=
PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$vmbase\/$vmlinked", 'snap1')) {
$count++;
- warn "Test6 c: Rollback sould possible"
+ warn "Test6 c: Rollback should be possible";
}
};
if ($@) {
if ( 1 !=
PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$ctdisk", 'snap1')) {
$count++;
- warn "Test6 d: Rollback sould possible"
+ warn "Test6 d: Rollback should be possible";
}
};
if ($@) {
if ( 1 !=
PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$ctbase", 'snap1')) {
$count++;
- warn "Test6 e: Rollback sould possible"
+ warn "Test6 e: Rollback should be possible";
}
};
if ($@) {
if ( 1 !=
PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$ctbase\/$ctlinked", 'snap1')) {
$count++;
- warn "Test6 f: Rollback sould possible"
+ warn "Test6 f: Rollback should be possible";
}
};
if ($@) {
warn "Test6 f: $@";
}
+ my $blockers = [];
eval {
PVE::Storage::volume_snapshot($cfg, "$storagename:$vmdisk", 'snap2');
- PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$vmdisk", 'snap1');
+ PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$vmdisk", 'snap1', $blockers);
};
if (!$@) {
$count++;
- warn "Test6 g: Rollback should not possible";
+ warn "Test6 g: Rollback should not be possible";
+ } elsif (scalar($blockers->@*) != 1 || $blockers->[0] ne 'snap2') {
+ $count++;
+ warn "Test6 g: 'blockers' should be ['snap2']";
}
+ undef $blockers;
+ $blockers = [];
eval {
PVE::Storage::volume_snapshot($cfg, "$storagename:$vmbase", 'snap2');
- PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$vmbase", 'snap1');
+ PVE::Storage::volume_snapshot($cfg, "$storagename:$vmbase", 'snap3');
+ PVE::Storage::volume_rollback_is_possible($cfg, "$storagename:$vmbase", 'snap1', $blockers);
};
if (!$@) {
$count++;
- warn "Test6 h: Rollback should not possible";
+ warn "Test6 h: Rollback should not be possible";
+ } else {
+ if (scalar($blockers->@*) != 2) {
+ $count++;
+ warn "Test6 g: 'blockers' should contain two elements";
+ }
+ my $blockers_hash = { map { $_ => 1 } $blockers->@* };
+ if (!$blockers_hash->{'snap2'}) {
+ $count++;
+ warn "Test6 g: 'blockers' should contain 'snap2'";
+ }
+ if (!$blockers_hash->{'snap3'}) {
+ $count++;
+ warn "Test6 g: 'blockers' should contain 'snap3'";
+ }
}
+ undef $blockers;
eval {
PVE::Storage::volume_snapshot($cfg, "$storagename:$vmlinked", 'snap2');
};
if (!$@) {
$count++;
- warn "Test6 j: Rollback should not possible";
+ warn "Test6 j: Rollback should not be possible";
}
eval {
};
if (!$@) {
$count++;
- warn "Test6 k: Rollback should not possible";
+ warn "Test6 k: Rollback should not be possible";
}
eval {
};
if (!$@) {
$count++;
- warn "Test6 l: Rollback should not possible";
+ warn "Test6 l: Rollback should not be possible";
}
eval {
};
if (!$@) {
$count++;
- warn "Test6 m: Rollback should not possible";
+ warn "Test6 m: Rollback should not be possible";
}
};
$tests->{6} = $test6;