Repository navigation
Fix variable naming, enhance tests, and update CI workflows #89
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
base: main
Are you sure you want to change the base?
Changes from all commits
7e84ae8
d039ccb
e30b21d
55a6058
7665957
19e07f3
458e14a
e2ce80b
d8393ed
e47627b
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 |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| __pycache__/ | ||
| *.pyc |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,14 +57,35 @@ sub write_file { | |
| close $fh or die "$path: $!"; | ||
| } | ||
|
|
||
| # Emulated guests run the same walks many times slower. Their jobs set | ||
| # TEST_NGINX_TIME_SCALE to stretch every wait; it never shortens one. | ||
| my $time_scale = ($ENV{TEST_NGINX_TIME_SCALE} // '') =~ /^[1-9]\d{0,2}$/ | ||
| ? $ENV{TEST_NGINX_TIME_SCALE} : 1; | ||
|
|
||
| sub await { | ||
| my ($test, $why, $seconds) = @_; | ||
| my $deadline = time + ($seconds || 10); | ||
| my ($test, $why, $seconds, $state) = @_; | ||
| my $deadline = time + ($seconds || 10) * $time_scale; | ||
| while (time < $deadline) { | ||
| return if $test->(); | ||
| sleep 0.01; | ||
| } | ||
| die "$why\n"; | ||
| $state->() if $state; | ||
| die "timed out: $why\n"; | ||
| } | ||
|
|
||
| # Queue state and the end of the error log, for a failure that has no other | ||
| # trace. Never dies: the server may be the thing that failed. | ||
| sub dump_state { | ||
| my ($s) = @_; | ||
| return sub { | ||
| my $v = eval { status($s) }; | ||
| my $log = eval { read_file("$s->{root}/error.log") }; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Preserve the status exception before reading the log. If Save
|
||
| diag('status: ' . (defined $v ? JSON::PP::encode_json($v->{cache}) | ||
| : "unavailable: $@")); | ||
| my @lines = split /^/, $log // ''; | ||
| diag('error.log tail: ' . join('', @lines[($#lines > 29 ? $#lines - 29 : 0) .. $#lines])) | ||
| if @lines; | ||
| }; | ||
| } | ||
|
|
||
| sub config { | ||
|
|
@@ -381,7 +402,7 @@ sub classify_generation_file { | |
| sub drain { | ||
| my ($s) = @_; | ||
| await(sub { my $v = status($s); !$v->{cache}{pending}{total} && !$v->{cache}{active} }, | ||
| 'pending work did not drain', 30); | ||
| 'pending work did not drain', 30, dump_state($s)); | ||
| } | ||
|
|
||
| # A controllable origin gives deterministic late-writer/probe races. It runs | ||
|
|
@@ -612,20 +633,24 @@ sub stop_server { | |
| @severe = grep { !/\[emerg\].*cache_purge_traffic_class needs more distinct/ } @severe; | ||
| } | ||
| if ($s->{listen_fault}) { | ||
| @severe = grep { !/\[emerg\].*(?:bind\(\) to 127\.0\.0\.1:\d+ failed \(\d+: (?:Address already in use|Unknown error)\)|still could not bind\(\))/ } @severe; | ||
| @severe = grep { !/\[emerg\].*(?:bind\(\) to 127\.0\.0\.1:\d+ failed \(\d+: (?:Address(?: already)? in use|Unknown error)\)|still could not bind\(\))/ } @severe; | ||
| } | ||
| is_deeply(\@severe, [], 'no unexpected severe diagnostic'); | ||
|
|
||
| } | ||
|
|
||
| END { | ||
| # waitpid() overwrites $?, which Test::Builder reads as the exit status: a | ||
| # die with a server still running would look like a clean exit (254). | ||
| my $status = $?; | ||
| for my $s (@servers) { | ||
| next unless $s->{pid}; | ||
| kill 'CONT', @{$s->{stopped}} if @{$s->{stopped}}; | ||
| kill 'TERM', -$s->{pid}; | ||
| waitpid($s->{pid}, 0); | ||
| stop_origin($s); | ||
| } | ||
| $? = $status; | ||
| } | ||
|
|
||
| sub warm { | ||
|
|
@@ -1444,7 +1469,8 @@ subtest 'unreadable scan roots return an explicit HTTP problem' => sub { | |
| : request($s, '/cache/*', 'PURGE'); | ||
| unlink $s->{cache} or die $!; | ||
| rename "$s->{cache}.saved", $s->{cache} or die $!; | ||
| is($r->{status}, 500, 'scan failure is not reported as success'); | ||
| is($r->{status}, 500, 'scan failure is not reported as success') | ||
| or do { diag('response: ' . JSON::PP::encode_json($r)); dump_state($s)->() }; | ||
| is($r->{headers}{'cache-purge-code'}, 'scan_failed', 'specific scan error header'); | ||
| is($r->{headers}{'content-type'}, 'application/problem+json', 'scan error uses problem JSON'); | ||
| my $body = decode_json($r->{content}); | ||
|
|
@@ -2217,8 +2243,10 @@ subtest "one worker serves HTTP and completes active work, thread pool=$pool" => | |
| my ($old) = read_file("$s->{root}/error.log") =~ /start worker process (\d+)/; | ||
| reload_server($s); | ||
| drain($s); | ||
| ok(!grep({ -e $_ } @targets), 'active walk completed across reload'); | ||
| is(status($s)->{cache}{files}{deleted}, $files, 'active walk counted exactly once'); | ||
| ok(!grep({ -e $_ } @targets), 'active walk completed across reload') | ||
| or dump_state($s)->(); | ||
| is(status($s)->{cache}{files}{deleted}, $files, 'active walk counted exactly once') | ||
| or dump_state($s)->(); | ||
| await(sub { read_file("$s->{root}/error.log") =~ /worker process $old exited with code 0/ }, | ||
| 'old worker did not finish graceful exit'); | ||
| like(read_file("$s->{root}/error.log"), qr/interpreting it as milliseconds/, | ||
|
|
@@ -2241,7 +2269,7 @@ subtest "one worker serves HTTP and completes active work, thread pool=$pool" => | |
| die $error; | ||
| }; | ||
| await(sub { my $v = status($s); !$v->{cache}{active} && $v->{cache}{files}{deleted} == 2 * $files }, | ||
| 'exit cleanup did not record completed work'); | ||
| 'exit cleanup did not record completed work', 30, dump_state($s)); | ||
| ok(!grep({ -e $_ } @targets), 'worker exit records completed traversal once'); | ||
| @targets = map { fixture($s, "/cache/exit/$_", $prefix, $s->{cache}) } 1 .. $files; | ||
| is(request($s, '/cache/exit*', 'PURGE')->{status}, 202, 'shutdown work accepted'); | ||
|
|
@@ -2335,7 +2363,7 @@ subtest 'traffic class HIT/MISS counters are subsets of the totals' => sub { | |
| my $t = $totals->(); | ||
| ($t->{hit} + $t->{miss}) - ($before->{hit} + $before->{miss}) == $counted; | ||
| }, 'counted requests were not observed'); | ||
| my ($v, $c) = class_status($s); | ||
| ($v, $c) = class_status($s); | ||
| for my $name (qw(bot human)) { | ||
| is($c->{$name}{hit}, $seen{$name}{HIT} || 0, "$name HIT count"); | ||
| is($c->{$name}{miss}, $seen{$name}{MISS} || 0, "$name MISS count"); | ||
|
|
@@ -2479,7 +2507,7 @@ subtest 'a reload that fails after the shared zone is attached keeps its slots f | |
| write_file("$s->{root}/nginx.conf", config($s)); | ||
| kill 'HUP', $s->{pid}; | ||
| await(sub { substr(read_file("$s->{root}/error.log"), $mark) | ||
| =~ /bind\(\) to 127\.0\.0\.1:\d+ failed \(\d+: (?:Address already in use|Unknown error)\)/ }, | ||
| =~ /bind\(\) to 127\.0\.0\.1:\d+ failed \(\d+: (?:Address(?: already)? in use|Unknown error)\)/ }, | ||
| 'the provoked reload failure was not logged', 20); | ||
| $s->{generation}--; | ||
| is(request($s, '/status-a')->{headers}{'x-generation'}, $s->{generation}, | ||
|
|
||
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.
The ARM host can wedge sparc64 guests.
With
arm64_host=true, the sparc64 jobs leave x86_64 and run onubuntu-24.04-arm. The anyvm launcher uses its patched sparc64 QEMU only on Linux x86_64. On the ARM host, it falls back to system QEMU, which the anyvm sources document as able to wedge under heavy concurrent disk and network I/O. A longer await timeout cannot recover lost interrupts. Keep sparc64 on x86_64 by excluding it from the ARM selector. Apply the same condition to the NetBSDruns-onat line 118.Suggested fix for the OpenBSD selector
Committable suggestion