mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 23:10:58 +00:00
6ace773fdc
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. Change-Id: Ie11e0d726ce287c45a677f3bb799388121aafc1e Reviewed-on: https://gerrit.openafs.org/15676 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Reviewed-by: Andrew Deason <adeason@sinenomine.net>
72 lines
1.8 KiB
Perl
Executable File
72 lines
1.8 KiB
Perl
Executable File
#!/usr/bin/env perl
|
|
|
|
use strict;
|
|
use warnings;
|
|
use lib $ENV{C_TAP_SOURCE} . "/tests-lib/perl5";
|
|
|
|
use afstest qw(obj_path);
|
|
use Test::More tests=>4;
|
|
use POSIX qw(:sys_wait_h :signal_h);
|
|
|
|
my $port = 4000;
|
|
my $rxperf = obj_path("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) {
|
|
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,
|
|
system("$rxperf client -c rpc -p $port -S 1048576 -R 1048576 -T 30 -u 1024 -H -N"),
|
|
"single threaded client ran successfully");
|
|
|
|
is (0,
|
|
system("$rxperf client -c rpc -p $port -S 1048576 -R 1048576 -T 1 -t 30 -u 1024 -H -N"),
|
|
"multi threaded client ran succesfully");
|
|
|
|
# Kill the server, and check its exit code
|
|
|
|
kill("TERM", $pid);
|
|
waitpid($pid, 0);
|
|
my $ecode = ${^CHILD_ERROR_NATIVE};
|
|
if (WIFSIGNALED($ecode) && WTERMSIG($ecode) != SIGTERM) {
|
|
fail("Server died with signal ".WTERMSIG($ecode));
|
|
} elsif (WIFEXITED($ecode) && WEXITSTATUS($ecode) != 0) {
|
|
fail("Server exited with code". WEXITSTATUS($ecode));
|
|
} else {
|
|
pass("Server exited succesfully");
|
|
}
|