tests: await portfile to be complete

When running under load, a started server may not produce a valid portfile
before the runner starts reading it. If the read is not successful, wait
for 100ms and try again, timing out after 15 seconds.

Fixes #17492
Closes #17495
This commit is contained in:
Stefan Eissing 2025-05-31 13:31:03 +02:00 committed by Daniel Stenberg
parent fe81a80ae7
commit 759d33a25c
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -29,6 +29,7 @@
package servers;
use IO::Socket;
use Time::HiRes;
use strict;
use warnings;
@ -1145,8 +1146,16 @@ sub runhttpserver {
# where is it?
my $port = 0;
if(!$port_or_path) {
my $waits = 0;
# wait at max 15 seconds to the port file to become valid
while(!$port_or_path && ($waits < (15 * 10))) {
$port = $port_or_path = pidfromfile($portfile);
Time::HiRes::sleep(0.1) unless $port_or_path;
++$waits;
}
if(!$port) {
logmsg "RUN: failed waiting for server to produce port file $portfile\n";
return (1, 0, 0, 0);
}
if($verb) {