test: migration: add parse_volume_id calls

so it fails when something bad comes in.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2021-01-29 16:11:31 +01:00 committed by Thomas Lamprecht
parent eabac302ba
commit 93a1c63f4c
3 changed files with 9 additions and 0 deletions

View File

@ -221,6 +221,8 @@ $MigrationTest::Shared::storage_module->mock(
vdisk_free => sub {
my ($scfg, $volid) = @_;
PVE::Storage::parse_volume_id($volid);
die "vdisk_free '$volid' error\n" if defined($fail_config->{vdisk_free})
&& $fail_config->{vdisk_free} eq $volid;
@ -292,6 +294,7 @@ $MigrationTest::Shared::tools_module->mock(
$cmd = shift @{$cmd_tail};
if ($cmd eq 'free') {
my $volid = shift @{$cmd_tail};
PVE::Storage::parse_volume_id($volid);
return 1 if $fail_config->{ssh_pvesm_free}
&& $fail_config->{ssh_pvesm_free} eq $volid;
MigrationTest::Shared::remove_target_volid($volid);

View File

@ -86,6 +86,8 @@ $MigrationTest::Shared::storage_module->mock(
$volid = "${storeid}:${name_without_extension}";
}
PVE::Storage::parse_volume_id($volid);
die "vdisk_alloc '$volid' error\n" if $fail_config->{vdisk_alloc}
&& $fail_config->{vdisk_alloc} eq $volid;

View File

@ -23,6 +23,8 @@ my $test_vmid = $migrate_params->{vmid};
sub add_target_volid {
my ($volid) = @_;
PVE::Storage::parse_volume_id($volid);
lock_file_full("${RUN_DIR_PATH}/target_volids.lock", undef, 0, sub {
my $target_volids = decode_json(file_get_contents("${RUN_DIR_PATH}/target_volids"));
die "target volid already present " if defined($target_volids->{$volid});
@ -35,6 +37,8 @@ sub add_target_volid {
sub remove_target_volid {
my ($volid) = @_;
PVE::Storage::parse_volume_id($volid);
lock_file_full("${RUN_DIR_PATH}/target_volids.lock", undef, 0, sub {
my $target_volids = decode_json(file_get_contents("${RUN_DIR_PATH}/target_volids"));
die "target volid does not exist " if !defined($target_volids->{$volid});