Skip to content

Commit c297cf6

Browse files
tests: improve test cases robustness.
162-static-module-location.t runs failed when set env TEST_NGINX_RANDOMIZE to 1. 025-codecache.t 106-timer.t 129-ssl-socket.t run failed when set env TEST_NGINX_USE_VALGRIND to 1. 138-balancer.t runs failed on fedora32 with kernel 5.9.14-100.fc32.x86_64.
1 parent 8981872 commit c297cf6

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ script:
9595
- sudo iptables -I OUTPUT 1 -p udp --dport 10086 -j REJECT
9696
- sudo iptables -I OUTPUT -p tcp --dst 127.0.0.2 --dport 12345 -j DROP
9797
- sudo iptables -I OUTPUT -p udp --dst 127.0.0.2 --dport 12345 -j DROP
98+
- sudo ip route add prohibit 0.0.0.1/32
9899
- cd luajit2/
99100
- make -j$JOBS CCDEBUG=-g Q= PREFIX=$LUAJIT_PREFIX CC=$CC XCFLAGS='-DLUA_USE_APICHECK -DLUA_USE_ASSERT -msse4.2' > build.log 2>&1 || (cat build.log && exit 1)
100101
- sudo make install PREFIX=$LUAJIT_PREFIX > build.log 2>&1 || (cat build.log && exit 1)

t/025-codecache.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ function go(port)
10961096
ngx.say("failed to receive a line: ", err, " [", part, "]")
10971097
end
10981098
1099-
local ok, err = sock:setkeepalive(1)
1099+
local ok, err = sock:setkeepalive(10)
11001100
if not ok then
11011101
ngx.say("failed to set reusable: ", err)
11021102
end

t/106-timer.t

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ F(ngx_http_lua_timer_handler) {
118118
registered timer
119119
foo = 3
120120

121-
--- wait: 0.1
121+
--- wait: 0.2
122122
--- no_error_log
123123
[error]
124124
[alert]
@@ -603,7 +603,7 @@ delete thread 2
603603
--- response_body
604604
hello world
605605

606-
--- wait: 0.12
606+
--- wait: 0.3
607607
--- no_error_log
608608
[error]
609609
[alert]
@@ -613,7 +613,7 @@ hello world
613613
[
614614
"registered timer",
615615
qr/\[lua\] .*? my lua timer handler/,
616-
qr/\[lua\] log_by_lua\(nginx\.conf:\d+\):\d+: elapsed: 0\.0(?:6[4-9]|7[0-6])/,
616+
qr/\[lua\] log_by_lua\(nginx\.conf:\d+\):\d+: elapsed: 0\.0(?:6[4-9]|7[0-9]|8[1-3])/,
617617
"lua ngx.timer expired",
618618
"http lua close fake http connection"
619619
]

t/129-ssl-socket.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,6 +2563,7 @@ qr/\[error\] .* ngx.socket sslhandshake: expecting 1 ~ 5 arguments \(including t
25632563
--- timeout: 10
25642564
25652565
2566+
25662567
=== TEST 32: default cipher -TLSv1.3
25672568
--- skip_openssl: 8: < 1.1.1
25682569
--- http_config

t/138-balancer.t

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ use Test::Nginx::Socket::Lua;
77
#workers(2);
88
#log_level('warn');
99

10+
#connect 0.0.0.1 on newer kernel won't return EINVAL
11+
#so add an route with cmd: sudo ip route add prohibit 0.0.0.1/32
12+
1013
repeat_each(2);
1114

1215
plan tests => repeat_each() * (blocks() * 4 + 9);

t/162-static-module-location.t

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ Hello, world
4141
--- request
4242
GET /t/中文
4343
--- error_code: 301
44-
--- response_headers
45-
Location: http://localhost:1984/t/%E4%B8%AD%E6%96%87/
44+
--- response_headers_like
45+
Location: http:\/\/localhost:\d+\/t\/%E4%B8%AD%E6%96%87\/
4646
--- response_body_like
4747
.*301 Moved Permanently.*
4848

@@ -57,8 +57,8 @@ Hello, world
5757
--- request
5858
GET /t/中文?q=name
5959
--- error_code: 301
60-
--- response_headers
61-
Location: http://localhost:1984/t/%E4%B8%AD%E6%96%87/?q=name
60+
--- response_headers_like
61+
Location: http:\/\/localhost:\d+\/t\/%E4%B8%AD%E6%96%87\/\?q=name
6262
--- response_body_like
6363
.*301 Moved Permanently.*
6464

@@ -73,8 +73,8 @@ Hello, world
7373
--- request
7474
GET /t/%E4%B8%AD%E6%96%87
7575
--- error_code: 301
76-
--- response_headers
77-
Location: http://localhost:1984/t/%E4%B8%AD%E6%96%87/
76+
--- response_headers_like
77+
Location: http:\/\/localhost:\d+\/t\/%E4%B8%AD%E6%96%87\/
7878
--- response_body_like
7979
.*301 Moved Permanently.*
8080

@@ -89,7 +89,7 @@ Hello, world
8989
--- request
9090
GET /t/%E4%B8%AD%E6%96%87?q=name
9191
--- error_code: 301
92-
--- response_headers
93-
Location: http://localhost:1984/t/%E4%B8%AD%E6%96%87/?q=name
92+
--- response_headers_like
93+
Location: http://localhost:\d+\/t\/%E4%B8%AD%E6%96%87\/\?q=name
9494
--- response_body_like
9595
.*301 Moved Permanently.*

0 commit comments

Comments
 (0)