From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 176C4766D7 for ; Tue, 19 Oct 2021 09:55:15 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 01E3F29A15 for ; Tue, 19 Oct 2021 09:55:14 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (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 5CD49298EE for ; Tue, 19 Oct 2021 09:55:09 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 514E6468E0 for ; Tue, 19 Oct 2021 09:55:04 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Tue, 19 Oct 2021 09:54:58 +0200 Message-Id: <20211019075459.14328-10-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211019075459.14328-1-f.ebner@proxmox.com> References: <20211019075459.14328-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.268 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH manager 2/3] test: replication: mock volume_snapshot_info X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Oct 2021 07:55:15 -0000 Signed-off-by: Fabian Ebner --- test/ReplicationTestEnv.pm | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/test/ReplicationTestEnv.pm b/test/ReplicationTestEnv.pm index dea1921b..35653e75 100755 --- a/test/ReplicationTestEnv.pm +++ b/test/ReplicationTestEnv.pm @@ -154,6 +154,17 @@ my $pve_storage_module = Test::MockModule->new('PVE::Storage'); my $mocked_storage_content = {}; +my $timestamp_counter = 0; + +sub generate_snapshot_info { + $timestamp_counter++; + + return { + id => $timestamp_counter, + timestamp => $timestamp_counter, + }; +} + sub register_mocked_volid { my ($volid, $snapname) = @_; @@ -163,7 +174,7 @@ sub register_mocked_volid { my $d = $mocked_storage_content->{$storeid}->{$volname} //= {}; - $d->{$snapname} = 1 if $snapname; + $d->{$snapname} = generate_snapshot_info() if $snapname; } my $mocked_volume_snapshot_list = sub { @@ -186,7 +197,7 @@ my $mocked_volume_snapshot = sub { my $d = $mocked_storage_content->{$storeid}->{$volname}; die "no such volid '$volid'\n" if !$d; - $d->{$snap} = 1; + $d->{$snap} = generate_snapshot_info(); return; }; @@ -200,6 +211,14 @@ my $mocked_volume_snapshot_delete = sub { delete $d->{$snap} || die "no such snapshot '$snap' on '$volid'\n"; }; +my $mocked_volume_snapshot_info = sub { + my ($cfg, $volid) = @_; + + my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid); + + return $mocked_storage_content->{$storeid}->{$volname} // {}; +}; + my $pve_replication_module = Test::MockModule->new('PVE::Replication'); my $mocked_job_logfile_name = sub { @@ -253,6 +272,7 @@ sub setup { $pve_storage_module->mock(volume_snapshot_list => $mocked_volume_snapshot_list); $pve_storage_module->mock(volume_snapshot => $mocked_volume_snapshot); $pve_storage_module->mock(volume_snapshot_delete => $mocked_volume_snapshot_delete); + $pve_storage_module->mock(volume_snapshot_info => $mocked_volume_snapshot_info); $pve_replication_config_module->mock( new => $mocked_replication_config_new, -- 2.30.2