Skip to content

Commit 234d055

Browse files
jimklimovJim Klimovoetiker
authored
t/zfs: introduce ZNAPZENDTEST_ZFS_list_max_snapshots toggle [#691] (#691)
* t/zfs: introduce ZNAPZENDTEST_ZFS_list_max_snapshots toggle [#691] Signed-off-by: Jim Klimov <jimklimov+znapzend@gmail.com> * README.md: revise suggestion about remaining PID files [#691] Signed-off-by: Jim Klimov <jimklimov+znapzend@gmail.com> * README.md: further update the developer-oriented "make check" suggestions [#691] Signed-off-by: Jim Klimov <jimklimov+znapzend@gmail.com> * README.md, CHANGES: suggest how to run real programs with mock tools to debug failed tests [#691] Signed-off-by: Jim Klimov <jimklimov+znapzend@gmail.com> * README.md: suggest how to run tested perl programs with debug tracer [#691] Signed-off-by: Jim Klimov <jimklimov+znapzend@gmail.com> * Update check-spelling metadata for PR #691 Drop some more words check-spelling action deems unneeded; add a few for this PR. Signed-off-by: Jim Klimov <jimklimov+znapzend@gmail.com> --------- Signed-off-by: Jim Klimov <jimklimov+znapzend@gmail.com> Co-authored-by: Jim Klimov <jimklimov+znapzend@gmail.com> Co-authored-by: Tobias Oetiker <tobi@oetiker.ch>
1 parent 973266e commit 234d055

4 files changed

Lines changed: 59 additions & 7 deletions

File tree

.github/workflows/spelling/expect.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ dstname
119119
DTIPS
120120
DTRT
121121
dummydataset
122+
ebug
122123
ebuild
123124
ecdsa
124125
eckels
@@ -207,10 +208,7 @@ installinfo
207208
Inztructionz
208209
ioloop
209210
Ip
210-
Ipath
211-
Ipictures
212211
irc
213-
Irecursive
214212
IRI
215213
isa
216214
isbn
@@ -361,6 +359,7 @@ propval
361359
Proxmox
362360
psgi
363361
pstcmd
362+
pwd
364363
QNX
365364
qq
366365
qw

CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
znapzend (0.23.3) UNRELEASED; urgency=medium
22

33
* Revised CI recipes to pass on contributor forks #680 -- @jimklimov
4+
* Introduced `ZNAPZENDTEST_ZFS_list_max_snapshots` in mock `t/zfs`
5+
(default `58` for `dst`, as it was hard-coded since at least 2014,
6+
adding `+2` more to `src` datasets), to speed up developer testing
7+
iterations; updated the README.md with suggestions #691 -- @jimklimov
48
* Revised `.gitignore` files, `Makefile.am` and Git tracked content
59
to drop files (re-)generated during build from Git and so simplify
610
life for developers; those generated files are directly added to

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,49 @@ or
183183
> might behave differently. While that can happen in practice, that would be
184184
> a bug to report and pursue fixing.
185185
186+
The tests use mocked tools under the `t` directory. Notably, the mock operation
187+
to `zfs list` generates a large listing of dataset snapshots (once a minute for
188+
an hour, by default), leading to significant test times like an hour or two!
189+
190+
To speed up development iterations, when you just want to make sure no simple
191+
regressions were added, you can `export ZNAPZENDTEST_ZFS_list_max_snapshots=3`
192+
or so to significantly speed up the test suite.
193+
194+
Also note that interrupted tests tend to leave the `znapzend*.pid` files in
195+
place (and corresponding daemons may remain running), so before re-running
196+
the tests you may want to follow up with `make clean-pidfiles` to kill any
197+
processes mentioned in those files (if present) and remove them.
198+
199+
Combining the suggestions above, a relatively quick developer testing command
200+
(taking about 5 minutes for the full suite), optionally with a log file to
201+
later trawl for errors (if any), could look like this:
202+
203+
```sh
204+
:; ZNAPZENDTEST_ZFS_list_max_snapshots=3 make clean-pidfiles check \
205+
2>&1 | tee "test-make-check-`date +%s`.log"
206+
```
207+
208+
To speed up development of tests (or to troubleshoot/debug any failures),
209+
you can also craft and execute individual test cases using the mock tools,
210+
by just preferring them in your `PATH`, e.g.:
211+
212+
```sh
213+
:; PATH="`pwd`/t:$PATH" ./bin/znapzendzetup \
214+
edit --donotask --tsformat=%Y%m%d-%H%M%S \
215+
SRC "1h=>10min" tank/source \
216+
DST:0 "1h=>10min" backup/destination
217+
```
218+
219+
As usual with Perl programming, you can run the interpreter with one of the
220+
development/debugging modules enabled (may need to install some from CPAN
221+
or your OS packaging), e.g. `Devel::ebug` or `Devel::Trace`:
222+
223+
```sh
224+
:; perl -d:Trace ./bin/znapzendzetup \
225+
edit --donotask --recursive=on \
226+
SRC tank/source
227+
```
228+
186229
Packages
187230
--------
188231

t/zfs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,16 +289,22 @@ for ($command){
289289
print STDERR "failed to list mock dataset(s)\n";
290290
exit 1;
291291
}
292-
if ($ARGV[4] && $ARGV[3] eq '-t' && $ARGV[4] eq 'snapshot'){
292+
if ($ARGV[4] && $ARGV[3] eq '-t' && $ARGV[4] eq 'snapshot') {
293293
if ($ARGV[-1] =~ /^[^\@]+\@[^\@]+$/){
294294
print $ARGV[-1] . "\n";
295295
exit;
296296
}
297297
exit 1 if !exists $dataSets{$ARGV[-1]};
298-
my $snapCount = ($dataSets{$ARGV[-1]} eq 'src') ? 60 : 58;
299-
#get timestamp rounded to minutes
298+
my $snapCount = envval('ZNAPZENDTEST_ZFS_list_max_snapshots');
299+
if (!defined($snapCount) || $snapCount !~ /^\d+$/) {
300+
$snapCount = 58; # +2 for src
301+
}
302+
if ($dataSets{$ARGV[-1]} eq 'src') {
303+
$snapCount += 2;
304+
}
305+
# Get timestamp rounded to minutes
300306
my $time = localtime(int(time / 60) * 60 - 3600);
301-
for (my $i = 0; $i < $snapCount; $i++){
307+
for (my $i = 0; $i < $snapCount; $i++) {
302308
print $ARGV[-1] . '@' . $time->strftime('%Y-%m-%d-%H%M%S') . "\n";
303309
$time += 60;
304310
}

0 commit comments

Comments
 (0)