Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd26e639

Browse files
author
Felipe Zimmerle
committed
test: nginx: Speeds up regression test in nginx.
Instead of use `sleep` it nows parser the nginx logs to figure outwhenever it start or stop. Audit log timeout was reduced to 8 seconds.
1 parentfe14d9d commitd26e639

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

‎tests/run-regression-tests-nginx.pl‎

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -459,14 +459,19 @@ sub match_log {
459459
return;
460460
}
461461

462-
$timeout = 0unless (defined$timeout);
462+
$timeout = 1unless (defined$timeout);
463+
464+
if ($timeout == 1)
465+
{
466+
$timeout = 0.5;
467+
}
463468

464469
# Audit logs are taking too long to be written on the disk. One of the
465470
# consequence of that is to have tests that demands to read from audit
466471
# log failing. Increase the timeout here, make it wait a little bit
467472
# more for the logs before gave up.
468473
if ($nameeq"audit") {
469-
$timeout =20;
474+
$timeout =8;
470475
}
471476

472477
my$i = 0;
@@ -490,6 +495,7 @@ sub match_log {
490495
#dbg("Match \"$re\" in $name \"$$rbuf\" ($n)");
491496
if ($$rbuf =~m/$re/m) {
492497
$rc =$&;
498+
# print "bonga\n";
493499
last;
494500
}
495501
# TODO: Use select()/poll()
@@ -503,6 +509,7 @@ sub match_log {
503509
printSTDERR"."
504510
}
505511
}
512+
system("sync");
506513
}while (gettimeofday -$t0 <$timeout);
507514
}
508515
printSTDERR"\n"if ($graphed);
@@ -619,14 +626,16 @@ sub nginx_stop {
619626
$rc = -1;
620627
}
621628

622-
sleep 0.5;
623-
if (-e$PID_FILE) {
624-
vrb("Nginx pid file still exists, sleeping for more 20 seconds.");
625-
sleep 20;
629+
unless (defined match_log("error",qr/signal [0-9]+\(SIGCHLD\) received/, 60,"exited with code 0")) {
630+
vrb(join("",map { quote_shell($_) }@p));
631+
msg("nginx server failed to shutdown.");
632+
sleep 0.5;
633+
return -1;
634+
}
626635

627-
if (-e$PID_FILE) {
628-
msg("Nginx stop failed:$PID_FILE still exists");
629-
}
636+
if (-e$PID_FILE) {
637+
msg("nginx server failed to shutdown.");
638+
return -1;
630639
}
631640

632641
return$rc;
@@ -767,14 +776,13 @@ sub nginx_start {
767776
$rc = -1;
768777
}
769778

770-
# Look for startup msg
771-
#unless (defined match_log("error", qr/start worker process/, 60, "Waiting on nginx to start: ")) {
772-
#vrb(join(" ", map { quote_shell($_) } @p));
773-
#vrb(match_log("error", qr/(^.*ModSecurity: .*)/sm, 10));
774-
#msg("Nginx server failed to start.");
775-
#nginx_stop();
776-
#return -1;
777-
#}
779+
# Look for startup msworker cycleg
780+
unless (defined match_log("error",qr/setproctitle: "nginx: worker process"/, 60,"worker cycle")) {
781+
vrb(join("",map { quote_shell($_) }@p));
782+
msg("Nginx server failed to start.");
783+
nginx_stop();
784+
return -1;
785+
}
778786

779787
return$rc;
780788
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp