-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix parser for root (only) dataset names #621
Changes from all commits
eeb2475
afde374
111943f
cf17797
6d827fc
f54e21a
696cf8e
f0ce0b7
8c53d96
08f15cd
e5dec2b
5156d5a
c0eb719
ff84c33
e66d62f
541d20f
42085d7
f5a0824
963b95a
5e6cf89
0789023
ebd9945
f63d604
84dec8d
3c7d300
83186d7
0b65d9b
3cd1ec4
b911de2
09ef18d
05d72c4
d0947fb
62c2a4b
a179154
9ba442a
80ea4c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
znapzend (0.21.3) unstable; urgency=medium | ||
|
||
* Maintenance release: refine splitting of [[user@]host:]dataset[:with-colons][@snap[:with-colons]] strings to work for the realistic majority of use-cases; fix back support of pool root dataset in such spec | ||
* Update self-tests with verification that [[user@]host:]dataset[:with-colons][@snap[:with-colons]] string decoding yields expected results | ||
* Fixed CI recipes and contents for spell-checker | ||
|
||
-- Jim Klimov <[email protected]> Tue, 9 Jan 2024 13:42:28 +0100 | ||
|
||
znapzend (0.21.2) unstable; urgency=medium | ||
|
||
* Maintenance release: Automate .deb package builds | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
# since there are many use-cases and combinations to take care of. | ||
# We do so below by constructing "task" strings from components we | ||
# know to be a dataset name and some defined (or not) remote spec | ||
# and/or snapshot name, and deconstructing it back with the class | ||
# and/or snapshot name, and de-constructing it back with the class | ||
# method. | ||
# | ||
# Copyright (C) 2024 by Jim Klimov <[email protected]> | ||
|
@@ -31,7 +31,7 @@ | |
|
||
unshift @INC, sub { | ||
my (undef, $filename) = @_; | ||
return () if $filename !~ /ZnapZend|ZFS|znapzend/; | ||
return () if $filename !~ /ZnapZend|ZnapZend.Config|ZFS|znapzend/; | ||
if (my $found = (grep { -e $_ } map { "$_/$filename" } grep { !ref } @INC)[0] ) { | ||
local $/ = undef; | ||
open my $fh, '<', $found or die("Can't read module file $found\n"); | ||
|
@@ -53,6 +53,8 @@ | |
# names so we can actually call them from the test context. | ||
if($filename =~ /ZFS/) { | ||
$module_text =~ s/^1;$/### Quick drop-in\nsub splitDataSetSnapshot {return \$splitDataSetSnapshot->(\$_[1]);}\nsub splitHostDataSet {return \$splitHostDataSet->(\$_[1]);}\n\n1;\n/gm; | ||
} elsif($filename =~ /Config/) { | ||
$module_text =~ s/^1;$/### Quick drop-in\nsub splitHostDataSet {return \$splitHostDataSet->(\$_[1]);}\n\n1;\n/gm; | ||
} | ||
|
||
if(defined($ENV{DEBUG_ZNAPZEND_SELFTEST_REWRITE})) { | ||
|
@@ -67,7 +69,7 @@ | |
# from the file directly | ||
$INC{$filename} = $found; | ||
|
||
warn ("Imported '$found'"); | ||
Check failure on line 72 in t/znapzend-lib-splitter.t GitHub Actions / Perl 5.32
Check failure on line 72 in t/znapzend-lib-splitter.t GitHub Actions / Perl 5.32
Check failure on line 72 in t/znapzend-lib-splitter.t GitHub Actions / Perl 5.32
Check failure on line 72 in t/znapzend-lib-splitter.t GitHub Actions / Perl 5.30
Check failure on line 72 in t/znapzend-lib-splitter.t GitHub Actions / Perl 5.30
Check failure on line 72 in t/znapzend-lib-splitter.t GitHub Actions / Perl 5.30
Check failure on line 72 in t/znapzend-lib-splitter.t GitHub Actions / Perl 5.26
Check failure on line 72 in t/znapzend-lib-splitter.t GitHub Actions / Perl 5.26
Check failure on line 72 in t/znapzend-lib-splitter.t GitHub Actions / Perl 5.26
Check failure on line 72 in t/znapzend-lib-splitter.t GitHub Actions / Perl 5.36
Check failure on line 72 in t/znapzend-lib-splitter.t GitHub Actions / Perl 5.36
|
||
return $fh; | ||
} | ||
else { | ||
|
@@ -81,8 +83,14 @@ | |
return "<undef>"; | ||
} | ||
|
||
sub printTaskReport { | ||
print STDERR "[D] task='" . stringify($_[0]) . | ||
sub printTaskReportCFG { | ||
print STDERR "[D:zCFG] task='" . stringify($_[0]) . | ||
"' => remote='" . stringify($_[1]) . | ||
"' dataSet='" . stringify($_[2]) . "'\n"; | ||
} | ||
|
||
sub printTaskReportZFS { | ||
print STDERR "[D:zZFS] task='" . stringify($_[0]) . | ||
"' => remote='" . stringify($_[1]) . | ||
"' dataSetPathAndSnap='" . stringify($_[2]) . | ||
"' => dataSet='" . stringify($_[3]) . | ||
|
@@ -97,6 +105,16 @@ | |
|
||
is (ref $zZFS,'ZnapZend::ZFS', 'instantiation of ZFS'); | ||
|
||
# NOTE: In absence of any hints we can not reliably discern below | ||
# a task='poolrootfs@snap-2:3' | ||
# vs. task='username@hostname:poolrootfs' | ||
# which one is a local pool's root dataset with a funny but legal | ||
# snapshot name, and which one is a remote user@host spec with a | ||
# remote pool's root dataset. For practical purposes, we proclaim | ||
# preference for the former: we are more likely to look at funny | ||
# local snapshot names, than to back up to (or otherwise care about) | ||
# remote pools' ROOT datasets. | ||
|
||
for my $r (qw(undef hostname username@hostname)) { | ||
for my $d (qw(poolrootfs rpool/dataset rpool/dataset:with-colon)) { | ||
for my $s (qw(undef snapname snap-1 snap-2:3 snap-12:35:00)) { | ||
|
@@ -111,25 +129,65 @@ | |
# Note the methods are externalized from the module for the test by patcher above | ||
my ($remote, $dataSetPathAndSnap) = $zZFS->splitHostDataSet($task); | ||
my ($dataSet, $snapshot) = $zZFS->splitDataSetSnapshot($dataSetPathAndSnap); | ||
#print STDERR "[D] task='$task' => remote='$remote' dataSetPathAndSnap='$dataSetPathAndSnap' => dataSet='$dataSet' snapshot='$snapshot'\n"; | ||
printTaskReport($task, $remote, $dataSetPathAndSnap, $dataSet, $snapshot); | ||
printTaskReportZFS($task, $remote, $dataSetPathAndSnap, $dataSet, $snapshot); | ||
|
||
is (defined ($dataSet), 1, "dataSet should always be defined after parsing"); | ||
is (($dataSet eq $d), 1, "dataSet has expected value after parsing"); | ||
|
||
if ($r ne "undef") { | ||
is (defined ($remote), 1, "remote should be defined after parsing this test case"); | ||
is (($remote eq $r), 1, "remote has expected value after parsing"); | ||
# See big comment above: | ||
if ($task eq 'username@hostname:poolrootfs') { | ||
isnt (defined ($remote), 1, "BOGUS exceptional test case: remote should be not defined after parsing for this exceptional test case"); | ||
is (($dataSet eq "username"), 1, "BOGUS exceptional test case: dataSet has expected BOGUS value after parsing for this exceptional test case"); | ||
is (($snapshot eq "hostname:poolrootfs"), 1, "BOGUS exceptional test case: snapshot has expected BOGUS value after parsing for this exceptional test case"); | ||
} else { | ||
isnt (defined ($remote), 1, "remote should not be defined after parsing this test case"); | ||
is (($dataSet eq $d), 1, "dataSet has expected value after parsing"); | ||
|
||
if ($r ne "undef") { | ||
is (defined ($remote), 1, "remote should be defined after parsing this test case"); | ||
is (($remote eq $r), 1, "remote has expected value after parsing"); | ||
} else { | ||
isnt (defined ($remote), 1, "remote should not be defined after parsing this test case"); | ||
} | ||
|
||
if ($s ne "undef") { | ||
is (defined ($snapshot), 1, "snapshot should be defined after parsing this test case"); | ||
is (($snapshot eq $s), 1, "snapshot has expected value after parsing"); | ||
} else { | ||
isnt (defined ($snapshot), 1, "snapshot should not be defined after parsing this test case"); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
if ($s ne "undef") { | ||
is (defined ($snapshot), 1, "snapshot should be defined after parsing this test case"); | ||
is (($snapshot eq $s), 1, "snapshot has expected value after parsing"); | ||
} else { | ||
isnt (defined ($snapshot), 1, "snapshot should not be defined after parsing this test case"); | ||
} | ||
# This module has its own definition of splitHostDataSet for | ||
# znapzendzetup property parsing - without snapshot parts | ||
use_ok 'ZnapZend::Config'; | ||
|
||
my $zCFG = ZnapZend::Config->new(); | ||
|
||
is (ref $zCFG,'ZnapZend::Config', 'instantiation of Config'); | ||
|
||
for my $r (qw(undef hostname username@hostname)) { | ||
for my $d (qw(poolrootfs rpool/dataset rpool/dataset:with-colon)) { | ||
#EXAMPLE# my $task = 'user@host:dataset'; | ||
|
||
my $task = ''; | ||
if ($r ne "undef") { $task .= $r . ':'; } | ||
$task .= $d; | ||
|
||
# Decode it back, see if we can | ||
# Note the methods are externalized from the module for the test by patcher above | ||
my ($remote, $dataSet) = $zCFG->splitHostDataSet($task); | ||
printTaskReportCFG($task, $remote, $dataSet); | ||
|
||
is (defined ($dataSet), 1, "dataSet should always be defined after parsing"); | ||
is (($dataSet eq $d), 1, "dataSet has expected value after parsing"); | ||
|
||
if ($r ne "undef") { | ||
is (defined ($remote), 1, "remote should be defined after parsing this test case"); | ||
is (($remote eq $r), 1, "remote has expected value after parsing"); | ||
} else { | ||
isnt (defined ($remote), 1, "remote should not be defined after parsing this test case"); | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ariessanea1 : what's with the spam across many repos? Bot in training?