Browse Source

[tests] reduce time waiting for backends to start

reduce time spent waiting for backends to start

tests check for active listening port before proceeding

test runs now complete in about 2/3 the time
personal/stbuehler/mod-csrf
Glenn Strauss 5 years ago
parent
commit
aa14493e47
  1. 2
      src/mod_fastcgi.c
  2. 2
      src/mod_scgi.c
  3. 4
      tests/LightyTest.pm
  4. 6
      tests/mod-fastcgi.t
  5. 6
      tests/mod-scgi.t

2
src/mod_fastcgi.c

@ -939,7 +939,7 @@ static int fcgi_spawn_connection(server *srv,
fcgi_proc *proc) {
int fcgi_fd;
int status;
struct timeval tv = { 0, 100 * 1000 };
struct timeval tv = { 0, 10 * 1000 };
#ifdef HAVE_SYS_UN_H
struct sockaddr_un fcgi_addr_un;
#endif

2
src/mod_scgi.c

@ -709,7 +709,7 @@ static int scgi_spawn_connection(server *srv,
scgi_proc *proc) {
int scgi_fd;
int status;
struct timeval tv = { 0, 100 * 1000 };
struct timeval tv = { 0, 10 * 1000 };
#ifdef HAVE_SYS_UN_H
struct sockaddr_un scgi_addr_un;
#endif

4
tests/LightyTest.pm

@ -122,10 +122,10 @@ sub wait_for_port_with_proc {
my $self = shift;
my $port = shift;
my $child = shift;
my $timeout = 10*10; # 10 secs (valgrind might take a while), select waits 0.1 s
my $timeout = 10*50; # 10 secs (valgrind might take a while), select waits 0.02 s
while (0 == $self->listening_on($port)) {
select(undef, undef, undef, 0.1);
select(undef, undef, undef, 0.02);
$timeout--;
# the process is gone, we failed

6
tests/mod-fastcgi.t

@ -410,8 +410,10 @@ EOF
ok($tf->handle_http($t) == 0, 'killing fastcgi and wait for restart');
# (might take lighttpd 1 sec to detect backend exit)
select(undef, undef, undef, .9);
select(undef, undef, undef, .1) while (!$tf->listening_on(10000));
select(undef, undef, undef, .5);
for (my $c = 2*20; $c && 0 == $tf->listening_on(10000); --$c) {
select(undef, undef, undef, 0.05);
}
$t->{REQUEST} = ( <<EOF
GET /index.fcgi?crlf HTTP/1.0
Host: www.example.org

6
tests/mod-scgi.t

@ -76,8 +76,10 @@ EOF
ok($tf->handle_http($t) == 0, 'killing scgi and wait for restart');
# (might take lighttpd 1 sec to detect backend exit)
select(undef, undef, undef, .9);
select(undef, undef, undef, .1) while (!$tf->listening_on(10000));
select(undef, undef, undef, .5);
for (my $c = 2*20; $c && 0 == $tf->listening_on(10000); --$c) {
select(undef, undef, undef, 0.05);
}
$t->{REQUEST} = ( <<EOF
GET /index.scgi?crlf HTTP/1.0
Host: www.example.org

Loading…
Cancel
Save