1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
# vi:filetype=
use lib 'lib';
use Test::Nginx::Socket;
plan tests => 2 * blocks();
run_tests();
__DATA__
=== TEST 1: timer without explicit reset
--- config
location /timer {
echo_sleep 0.03;
echo "elapsed $echo_timer_elapsed sec.";
}
--- request
GET /timer
--- response_body_like
^elapsed 0\.0(2[6-9]|3[0-6]) sec\.$
=== TEST 2: timer without explicit reset and sleep
--- config
location /timer {
echo "elapsed $echo_timer_elapsed sec.";
}
--- request
GET /timer
--- response_body_like
^elapsed 0\.00[0-5] sec\.$
=== TEST 3: timing accumulated sleeps
--- config
location /timer {
echo_sleep 0.03;
echo_sleep 0.02;
echo "elapsed $echo_timer_elapsed sec.";
}
--- request
GET /timer
--- response_body_like
^elapsed 0\.0(4[6-9]|5[0-6]) sec\.$
=== TEST 4: timer with explicit reset but without sleep
--- config
location /timer {
echo_reset_timer;
echo "elapsed $echo_timer_elapsed sec.";
}
--- request
GET /timer
--- response_body_like
^elapsed 0\.00[0-5] sec\.$
=== TEST 5: reset timer between sleeps
--- config
location /timer {
echo_sleep 0.02;
echo "elapsed $echo_timer_elapsed sec.";
echo_reset_timer;
echo_sleep 0.03;
echo "elapsed $echo_timer_elapsed sec.";
}
--- request
GET /timer
--- response_body_like
^elapsed 0\.0(1[6-9]|2[0-6]) sec\.
elapsed 0\.0(2[6-9]|3[0-6]) sec\.$
=== TEST 6: reset timer between blocking sleeps
--- config
location /timer {
echo_blocking_sleep 0.02;
echo "elapsed $echo_timer_elapsed sec.";
echo_reset_timer;
echo_blocking_sleep 0.03;
echo "elapsed $echo_timer_elapsed sec.";
}
--- request
GET /timer
--- response_body_like
^elapsed 0\.0(1[6-9]|2[0-9]) sec\.
elapsed 0\.0(2[6-9]|3[0-6]) sec\.$
=== TEST 7: timer without explicit reset
--- config
location = /timer {
return 200 "$echo_timer_elapsed";
}
--- request
GET /timer
--- response_body_like chop
^0(\.0\d*)$
|