From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id E58E81FF2CF for ; Thu, 11 Jul 2024 13:59:02 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id F282D32B99; Thu, 11 Jul 2024 13:59:17 +0200 (CEST) From: Christoph Heiss To: pve-devel@lists.proxmox.com Date: Thu, 11 Jul 2024 13:57:54 +0200 Message-ID: <20240711115804.706227-3-c.heiss@proxmox.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240711115804.706227-1-c.heiss@proxmox.com> References: <20240711115804.706227-1-c.heiss@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -1.485 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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 URIBL_BLACK 3 Contains an URL listed in the URIBL blacklist [github.io] Subject: [pve-devel] [PATCH installer v3 2/4] test: add test cases for new zfs module 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: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Signed-off-by: Christoph Heiss --- 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 = < { 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