tests: increase sws timeout for more robust testing
- for https CONNECT forwarding, this was fixed at 5 seconds which led to spurious CI test failures - add --keepalive parameter to sws to control this - let httpserver use 30 seconds Closes #10898
This commit is contained in:
parent
632e0fbe70
commit
356dd0b73a
@ -53,6 +53,7 @@ my $portfile; # port number file
|
|||||||
my $logfile; # log file
|
my $logfile; # log file
|
||||||
my $cmdfile; # command file
|
my $cmdfile; # command file
|
||||||
my $connect; # IP to connect to on CONNECT
|
my $connect; # IP to connect to on CONNECT
|
||||||
|
my $keepalive_secs; # number of seconds to keep idle connections
|
||||||
my $srcdir;
|
my $srcdir;
|
||||||
my $gopher = 0;
|
my $gopher = 0;
|
||||||
|
|
||||||
@ -126,6 +127,12 @@ while(@ARGV) {
|
|||||||
shift @ARGV;
|
shift @ARGV;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elsif($ARGV[0] eq '--keepalive') {
|
||||||
|
if($ARGV[1]) {
|
||||||
|
$keepalive_secs = $ARGV[1];
|
||||||
|
shift @ARGV;
|
||||||
|
}
|
||||||
|
}
|
||||||
elsif($ARGV[0] eq '--id') {
|
elsif($ARGV[0] eq '--id') {
|
||||||
if($ARGV[1] =~ /^(\d+)$/) {
|
if($ARGV[1] =~ /^(\d+)$/) {
|
||||||
$idnum = $1 if($1 > 0);
|
$idnum = $1 if($1 > 0);
|
||||||
@ -171,6 +178,7 @@ $flags .= "--pidfile \"$pidfile\" ".
|
|||||||
"--portfile \"$portfile\" ";
|
"--portfile \"$portfile\" ";
|
||||||
$flags .= "--gopher " if($gopher);
|
$flags .= "--gopher " if($gopher);
|
||||||
$flags .= "--connect $connect " if($connect);
|
$flags .= "--connect $connect " if($connect);
|
||||||
|
$flags .= "--keepalive $keepalive_secs " if($keepalive_secs);
|
||||||
if($ipvnum eq 'unix') {
|
if($ipvnum eq 'unix') {
|
||||||
$flags .= "--unix-socket '$unix_socket' ";
|
$flags .= "--unix-socket '$unix_socket' ";
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -1552,6 +1552,8 @@ sub runhttpserver {
|
|||||||
my $idnum = 1;
|
my $idnum = 1;
|
||||||
my $exe = "$perl $srcdir/http-server.pl";
|
my $exe = "$perl $srcdir/http-server.pl";
|
||||||
my $verbose_flag = "--verbose ";
|
my $verbose_flag = "--verbose ";
|
||||||
|
my $keepalive_secs = 30; # forwarded to sws, was 5 by default which
|
||||||
|
# led to pukes in CI jobs
|
||||||
|
|
||||||
if($alt eq "ipv6") {
|
if($alt eq "ipv6") {
|
||||||
# if IPv6, use a different setup
|
# if IPv6, use a different setup
|
||||||
@ -1590,6 +1592,7 @@ sub runhttpserver {
|
|||||||
my $flags = "";
|
my $flags = "";
|
||||||
$flags .= "--gopher " if($proto eq "gopher");
|
$flags .= "--gopher " if($proto eq "gopher");
|
||||||
$flags .= "--connect $HOSTIP " if($alt eq "proxy");
|
$flags .= "--connect $HOSTIP " if($alt eq "proxy");
|
||||||
|
$flags .= "--keepalive $keepalive_secs ";
|
||||||
$flags .= $verbose_flag if($debugprotocol);
|
$flags .= $verbose_flag if($debugprotocol);
|
||||||
$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
|
$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
|
||||||
$flags .= "--logdir \"$LOGDIR\" ";
|
$flags .= "--logdir \"$LOGDIR\" ";
|
||||||
|
|||||||
@ -146,8 +146,8 @@ static void storerequest(const char *reqbuf, size_t totalsize);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *serverlogfile = DEFAULT_LOGFILE;
|
const char *serverlogfile = DEFAULT_LOGFILE;
|
||||||
const char *logdir = "log";
|
static const char *logdir = "log";
|
||||||
char loglockfile[256];
|
static char loglockfile[256];
|
||||||
|
|
||||||
#define SWSVERSION "curl test suite HTTP server/0.1"
|
#define SWSVERSION "curl test suite HTTP server/0.1"
|
||||||
|
|
||||||
@ -1391,7 +1391,8 @@ static curl_socket_t connect_to(const char *ipaddr, unsigned short port)
|
|||||||
static void http_connect(curl_socket_t *infdp,
|
static void http_connect(curl_socket_t *infdp,
|
||||||
curl_socket_t rootfd,
|
curl_socket_t rootfd,
|
||||||
const char *ipaddr,
|
const char *ipaddr,
|
||||||
unsigned short ipport)
|
unsigned short ipport,
|
||||||
|
int keepalive_secs)
|
||||||
{
|
{
|
||||||
curl_socket_t serverfd[2] = {CURL_SOCKET_BAD, CURL_SOCKET_BAD};
|
curl_socket_t serverfd[2] = {CURL_SOCKET_BAD, CURL_SOCKET_BAD};
|
||||||
curl_socket_t clientfd[2] = {CURL_SOCKET_BAD, CURL_SOCKET_BAD};
|
curl_socket_t clientfd[2] = {CURL_SOCKET_BAD, CURL_SOCKET_BAD};
|
||||||
@ -1747,7 +1748,7 @@ static void http_connect(curl_socket_t *infdp,
|
|||||||
} /* (rc > 0) */
|
} /* (rc > 0) */
|
||||||
else {
|
else {
|
||||||
timeout_count++;
|
timeout_count++;
|
||||||
if(timeout_count > 5) {
|
if(timeout_count > keepalive_secs) {
|
||||||
logmsg("CONNECT proxy timeout after %d idle seconds!", timeout_count);
|
logmsg("CONNECT proxy timeout after %d idle seconds!", timeout_count);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1867,7 +1868,8 @@ static curl_socket_t accept_connection(curl_socket_t sock)
|
|||||||
is no data waiting, or < 0 if it should be closed */
|
is no data waiting, or < 0 if it should be closed */
|
||||||
static int service_connection(curl_socket_t msgsock, struct httprequest *req,
|
static int service_connection(curl_socket_t msgsock, struct httprequest *req,
|
||||||
curl_socket_t listensock,
|
curl_socket_t listensock,
|
||||||
const char *connecthost)
|
const char *connecthost,
|
||||||
|
int keepalive_secs)
|
||||||
{
|
{
|
||||||
if(got_exit_signal)
|
if(got_exit_signal)
|
||||||
return -1;
|
return -1;
|
||||||
@ -1914,7 +1916,8 @@ static int service_connection(curl_socket_t msgsock, struct httprequest *req,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
http_connect(&msgsock, listensock, connecthost, req->connect_port);
|
http_connect(&msgsock, listensock, connecthost, req->connect_port,
|
||||||
|
keepalive_secs);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1960,6 +1963,7 @@ int main(int argc, char *argv[])
|
|||||||
const char *socket_type = "IPv4";
|
const char *socket_type = "IPv4";
|
||||||
char port_str[11];
|
char port_str[11];
|
||||||
const char *location_str = port_str;
|
const char *location_str = port_str;
|
||||||
|
int keepalive_secs = 5;
|
||||||
|
|
||||||
/* a default CONNECT port is basically pointless but still ... */
|
/* a default CONNECT port is basically pointless but still ... */
|
||||||
size_t socket_idx;
|
size_t socket_idx;
|
||||||
@ -2059,6 +2063,21 @@ int main(int argc, char *argv[])
|
|||||||
arg++;
|
arg++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(!strcmp("--keepalive", argv[arg])) {
|
||||||
|
arg++;
|
||||||
|
if(argc>arg) {
|
||||||
|
char *endptr;
|
||||||
|
unsigned long ulnum = strtoul(argv[arg], &endptr, 10);
|
||||||
|
if((endptr != argv[arg] + strlen(argv[arg])) ||
|
||||||
|
(ulnum && ((ulnum < 0UL) || (ulnum > 65535UL)))) {
|
||||||
|
fprintf(stderr, "sws: invalid --keepalive argument (%s), must "
|
||||||
|
"be number of seconds\n", argv[arg]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
keepalive_secs = curlx_ultous(ulnum);
|
||||||
|
arg++;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if(!strcmp("--connect", argv[arg])) {
|
else if(!strcmp("--connect", argv[arg])) {
|
||||||
/* The connect host IP number that the proxy will connect to no matter
|
/* The connect host IP number that the proxy will connect to no matter
|
||||||
what the client asks for, but also use this as a hint that we run as
|
what the client asks for, but also use this as a hint that we run as
|
||||||
@ -2320,7 +2339,7 @@ int main(int argc, char *argv[])
|
|||||||
/* Service this connection until it has nothing available */
|
/* Service this connection until it has nothing available */
|
||||||
do {
|
do {
|
||||||
rc = service_connection(all_sockets[socket_idx], req, sock,
|
rc = service_connection(all_sockets[socket_idx], req, sock,
|
||||||
connecthost);
|
connecthost, keepalive_secs);
|
||||||
if(got_exit_signal)
|
if(got_exit_signal)
|
||||||
goto sws_cleanup;
|
goto sws_cleanup;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user