From 95e67f9c3e6e605da07081b9521ed2eaa2add648 Mon Sep 17 00:00:00 2001 From: Cheyenne Wills Date: Fri, 15 Mar 2024 16:24:05 -0600 Subject: [PATCH] tests: rx/perf wait for server init before client The rx/perf test can occasionally fail due to the rxperf server not being fully initialized before the client started. This can cause test errors, even without changes to the rx code. C_TAP_VERBOSE=1 make check TESTS="rx/perf" ... rx/perf 1..4 ok 1 - Started rxperf server not ok 2 - single threaded client ran successfully RPC: threads 30, times 1, write bytes 1048576, read bytes... ok 3 - multi threaded client ran succesfully ok 4 - Server exited succesfully FAILED 2 (exit status 1) Add a routine that waits for the rx_perf server to become available. Loop several times trying the connection via the rx_perf client, with a short delay between retries. If the connection cannot be established, fail the test. Clean up trailing whitespace on a couple of lines. Note: This failure was observed in an OpenAFS buildbot worker that included a make tests, and which would occasionally fail when there was no rx related code changes. The intermittent failure could be duplicated on a slower virtual test system, but would not fail on a faster system. Thanks to mmeffie@sinenomine.net for the 'wait_for_server' contribution. Reviewed-on: https://gerrit.openafs.org/15676 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk Reviewed-by: Andrew Deason (cherry picked from commit 6ace773fdcff0486663a0cc4381d7b6ce2352c04) Change-Id: I75c6cd1e4e724d4803b62e2f74e5307cb8fcb14d Reviewed-on: https://gerrit.openafs.org/15736 Reviewed-by: Michael Meffie Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Benjamin Kaduk --- tests/rx/perf-t | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/tests/rx/perf-t b/tests/rx/perf-t index 530630aed9..11ade3a38f 100755 --- a/tests/rx/perf-t +++ b/tests/rx/perf-t @@ -11,21 +11,45 @@ my $build = $ENV{C_TAP_BUILD}; $build = ".." if (!defined($build)); my $rxperf = $build."/../src/tools/rxperf/rxperf"; + +# Wait for the server to finish initializing. +sub +wait_for_server { + my $pid = shift; + for (my $i = 0; $i < 10; $i++) { + if ($i > 0) { + sleep(1); + } + my $rc = system($rxperf, "client", "-c", "rpc", "-p", $port, "-S", + "128", "-R", "128", "-T", "1", "-H", "-N", + "-o", "/dev/null"); + if ($rc == 0) { + return; + } + } + kill("TERM", $pid); + waitpid($pid, 0); + die("Unable to contact rxperf server."); +} + # Start up an rxperf server my $pid = fork(); if ($pid == -1) { fail("Failed to fork rxperf server"); exit(1); -} elsif ($pid == 0) { +} elsif ($pid == 0) { exec({$rxperf} "rxperf", "server", "-p", $port, "-u", "1024", "-H", "-N"); die("Kabooom ?"); } +# Give the server some time to initialize +wait_for_server($pid); + pass("Started rxperf server"); # Start up an rxperf client, and run a test -is(0, +is(0, system("$rxperf client -c rpc -p $port -S 1048576 -R 1048576 -T 30 -u 1024 -H -N"), "single threaded client ran successfully"); @@ -44,5 +68,3 @@ if (WIFSIGNALED($?) && WTERMSIG($?) != SIGTERM) { } else { pass("Server exited succesfully"); } - -