From 93a1c63f4cd70a602b4b2d31be2dd5f69a19948b Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Fri, 29 Jan 2021 16:11:31 +0100 Subject: [PATCH] test: migration: add parse_volume_id calls so it fails when something bad comes in. Signed-off-by: Fabian Ebner --- test/MigrationTest/QemuMigrateMock.pm | 3 +++ test/MigrationTest/QmMock.pm | 2 ++ test/MigrationTest/Shared.pm | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/test/MigrationTest/QemuMigrateMock.pm b/test/MigrationTest/QemuMigrateMock.pm index efd6130b..2d424e01 100644 --- a/test/MigrationTest/QemuMigrateMock.pm +++ b/test/MigrationTest/QemuMigrateMock.pm @@ -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); diff --git a/test/MigrationTest/QmMock.pm b/test/MigrationTest/QmMock.pm index 2f1fffc6..2d5d5c6c 100644 --- a/test/MigrationTest/QmMock.pm +++ b/test/MigrationTest/QmMock.pm @@ -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; diff --git a/test/MigrationTest/Shared.pm b/test/MigrationTest/Shared.pm index 65524655..8ae6a6e1 100644 --- a/test/MigrationTest/Shared.pm +++ b/test/MigrationTest/Shared.pm @@ -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});