From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <f.ebner@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 4AC0B6C3B7
 for <pve-devel@lists.proxmox.com>; Fri, 29 Jan 2021 16:12:18 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 4247F1121B
 for <pve-devel@lists.proxmox.com>; Fri, 29 Jan 2021 16:11:48 +0100 (CET)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [212.186.127.180])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id D20DC111E2
 for <pve-devel@lists.proxmox.com>; Fri, 29 Jan 2021 16:11:46 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9529D43B5D
 for <pve-devel@lists.proxmox.com>; Fri, 29 Jan 2021 16:11:46 +0100 (CET)
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Fri, 29 Jan 2021 16:11:31 +0100
Message-Id: <20210129151143.10014-2-f.ebner@proxmox.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20210129151143.10014-1-f.ebner@proxmox.com>
References: <20210129151143.10014-1-f.ebner@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.004 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RCVD_IN_DNSWL_MED        -2.3 Sender listed at https://www.dnswl.org/,
 medium trust
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [qemumigratemock.pm, shared.pm, qmmock.pm]
Subject: [pve-devel] [PATCH v2 qemu-server 01/13] test: migration: add
 parse_volume_id calls
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Fri, 29 Jan 2021 15:12:18 -0000

so it fails when something bad comes in.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---

New in v2, added because I ran into a problem with an early version of patch #12
which wasn't detected by the tests. See patch #12 for the details.

 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 efd6130..2d424e0 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 2f1fffc..2d5d5c6 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 d7aeb36..e48b82c 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});
-- 
2.20.1