From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer v3 2/4] test: add test cases for new zfs module
Date: Thu, 11 Jul 2024 13:57:54 +0200 [thread overview]
Message-ID: <20240711115804.706227-3-c.heiss@proxmox.com> (raw)
In-Reply-To: <20240711115804.706227-1-c.heiss@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
Changes v2 -> v3:
* no changes
Changes v1 -> v2:
* new patch, split out from patch #1
* rewrote tests to use a pre-defined input instead, thus being able
to enable the tests unconditionally
test/Makefile | 7 ++++-
test/zfs-get-pool-list.pl | 57 +++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 1 deletion(-)
create mode 100755 test/zfs-get-pool-list.pl
diff --git a/test/Makefile b/test/Makefile
index 99bf14e..c473af8 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -3,12 +3,13 @@ all:
export PERLLIB=..
.PHONY: check
-check: test-zfs-arc-max test-run-command test-parse-fqdn test-ui2-stdio
+check: test-zfs-arc-max test-run-command test-parse-fqdn test-ui2-stdio test-zfs-get-pool-list
.PHONY: test-zfs-arc-max
test-zfs-arc-max:
./zfs-arc-max.pl
+.PHONY: test-run-command
test-run-command:
./run-command.pl
@@ -19,3 +20,7 @@ test-parse-fqdn:
.PHONY: test-ui2-stdio
test-ui2-stdio:
./ui2-stdio.pl
+
+.PHONY: test-zfs-get-pool-list
+test-zfs-get-pool-list:
+ ./zfs-get-pool-list.pl
diff --git a/test/zfs-get-pool-list.pl b/test/zfs-get-pool-list.pl
new file mode 100755
index 0000000..34e6b20
--- /dev/null
+++ b/test/zfs-get-pool-list.pl
@@ -0,0 +1,57 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use File::Temp;
+use Test::More tests => 8;
+
+use Proxmox::Sys::ZFS;
+use Proxmox::UI;
+
+my $log_file = File::Temp->new();
+Proxmox::Log::init($log_file->filename);
+
+Proxmox::UI::init_stdio();
+
+our $ZPOOL_IMPORT_TEST_OUTPUT = <<EOT;
+ pool: testpool
+ id: 4958685680270539150
+ state: ONLINE
+ action: The pool can be imported using its name or numeric identifier.
+ config:
+
+ testpool ONLINE
+ vdc ONLINE
+ vdd ONLINE
+
+ pool: rpool
+ id: 9412322616744093413
+ state: FAULTED
+status: The pool was last accessed by another system.
+ action: The pool can be imported using its name or numeric identifier and
+ the '-f' flag.
+ see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-EY
+ config:
+
+ rpool ONLINE
+ mirror-0 ONLINE
+ vda3 ONLINE
+ vdb3 ONLINE
+EOT
+
+my $pools = {
+ testpool => { id => '4958685680270539150', state => 'ONLINE' },
+ rpool => { id => '9412322616744093413', state => 'FAULTED' },
+};
+
+open(my $fh, '<', \$ZPOOL_IMPORT_TEST_OUTPUT);
+my $result = Proxmox::Sys::ZFS::zpool_import_parse_output($fh);
+while (my ($name, $info) = each %$pools) {
+ my ($p) = grep { $_->{name} eq $name } @$result;
+ ok(defined($p), "pool $name was found");
+ is($p->{id}, $info->{id}, "pool $name has correct id");
+ is($p->{state}, $info->{state}, "pool $name has correct state");
+ like($p->{action}, qr/^The pool can be imported using its name or numeric identifier/,
+ "pool $name can be imported");
+}
--
2.45.1
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2024-07-11 11:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-11 11:57 [pve-devel] [PATCH installer v3 0/4] add check/rename for already-existing ZFS rpool Christoph Heiss
2024-07-11 11:57 ` [pve-devel] [PATCH installer v3 1/4] proxmox: add zfs module for retrieving importable zpool info Christoph Heiss
2024-07-11 11:57 ` Christoph Heiss [this message]
2024-07-11 11:57 ` [pve-devel] [PATCH installer v3 3/4] install: config: rename option lvm_auto_rename -> existing_storage_auto_rename Christoph Heiss
2024-07-11 11:57 ` [pve-devel] [PATCH installer v3 4/4] low-level: install: check for already-existing `rpool` on install Christoph Heiss
2024-07-12 9:36 ` Aaron Lauterer
2024-07-15 14:49 ` Christoph Heiss
2024-07-12 9:42 ` [pve-devel] [PATCH installer v3 0/4] add check/rename for already-existing ZFS rpool Aaron Lauterer
2024-07-15 14:52 ` Christoph Heiss
2024-07-16 8:33 ` Christoph Heiss
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=20240711115804.706227-3-c.heiss@proxmox.com \
--to=c.heiss@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.