all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v3 storage 3/3] test: zfspool: extend some rollback is possible tests with new blockers parameter
Date: Thu, 12 Aug 2021 13:01:02 +0200	[thread overview]
Message-ID: <20210812110111.73883-4-f.ebner@proxmox.com> (raw)
In-Reply-To: <20210812110111.73883-1-f.ebner@proxmox.com>

and fix a few typos.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 test/run_test_zfspoolplugin.pl | 65 +++++++++++++++++++++++++---------
 1 file changed, 49 insertions(+), 16 deletions(-)

diff --git a/test/run_test_zfspoolplugin.pl b/test/run_test_zfspoolplugin.pl
index 2f63f1b..095ccb3 100755
--- a/test/run_test_zfspoolplugin.pl
+++ b/test/run_test_zfspoolplugin.pl
@@ -1362,10 +1362,21 @@ my $test6 = sub {
 
     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 ($@) {
@@ -1378,7 +1389,7 @@ my $test6 = sub {
 	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 ($@) {
@@ -1391,7 +1402,7 @@ my $test6 = sub {
 	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 ($@) {
@@ -1404,7 +1415,7 @@ my $test6 = sub {
 	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 ($@) {
@@ -1417,7 +1428,7 @@ my $test6 = sub {
 	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 ($@) {
@@ -1430,7 +1441,7 @@ my $test6 = sub {
 	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 ($@) {
@@ -1438,23 +1449,45 @@ my $test6 = sub {
 	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');
@@ -1462,7 +1495,7 @@ my $test6 = sub {
     };
     if (!$@) {
 	$count++;
-	warn "Test6 j: Rollback should not possible";
+	warn "Test6 j: Rollback should not be possible";
     }
 
     eval {
@@ -1471,7 +1504,7 @@ my $test6 = sub {
     };
     if (!$@) {
 	$count++;
-	warn "Test6 k: Rollback should not possible";
+	warn "Test6 k: Rollback should not be possible";
     }
 
     eval {
@@ -1480,7 +1513,7 @@ my $test6 = sub {
     };
     if (!$@) {
 	$count++;
-	warn "Test6 l: Rollback should not possible";
+	warn "Test6 l: Rollback should not be possible";
     }
 
     eval {
@@ -1489,7 +1522,7 @@ my $test6 = sub {
     };
     if (!$@) {
 	$count++;
-	warn "Test6 m: Rollback should not possible";
+	warn "Test6 m: Rollback should not be possible";
     }
 };
 $tests->{6} = $test6;
-- 
2.30.2





  parent reply	other threads:[~2021-08-12 11:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-12 11:00 [pve-devel] [PATCH-SERIES v3] fix #3111: fix interaction of snapshot operations with replication Fabian Ebner
2021-08-12 11:01 ` [pve-devel] [PATCH v3 storage 1/3] zfspool: add zfs_get_sorted_snapshot_list helper Fabian Ebner
2021-08-12 11:01 ` [pve-devel] [PATCH v3 storage 2/3] zfspool: add blockers parameter to volume_snapshot_is_possible Fabian Ebner
2021-08-13  6:54   ` Fabian Ebner
2021-08-12 11:01 ` Fabian Ebner [this message]
2021-08-12 11:01 ` [pve-devel] [PATCH v3 container 1/1] config: rollback is possible: add blockers parameter Fabian Ebner
2021-08-12 11:01 ` [pve-devel] [PATCH v3 qemu-server " Fabian Ebner
2021-08-12 11:01 ` [pve-devel] [PATCH v3 guest-common 1/7] partially fix #3111: snapshot rollback: improve removing replication snapshots Fabian Ebner
2021-08-12 11:01 ` [pve-devel] [PATCH v3 guest-common 2/7] config: rollback: factor out helper for " Fabian Ebner
2021-08-12 11:01 ` [pve-devel] [PATCH v3 guest-common 3/7] partially fix #3111: further improve " Fabian Ebner
2021-08-12 11:01 ` [pve-devel] [PATCH v3 guest-common 4/7] replication: remove unused variable and style fixes Fabian Ebner
2021-08-12 11:01 ` [pve-devel] [PATCH v3 guest-common 5/7] replication: pass guest config to find_common_replication_snapshot Fabian Ebner
2021-08-12 11:01 ` [pve-devel] [PATCH v3 guest-common 6/7] partially fix #3111: replication: be less picky when selecting incremental base Fabian Ebner
2021-08-12 11:01 ` [pve-devel] [RFC v3 guest-common 7/7] fix #3111: config: snapshot delete: check if replication still needs it Fabian Ebner
2021-10-06  6:59 ` [pve-devel] [PATCH-SERIES v3] fix #3111: fix interaction of snapshot operations with replication Fabian Ebner
2021-11-09 16:49 ` [pve-devel] applied-series: " Fabian Grünbichler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210812110111.73883-4-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal