Skip to content

Commit 1bce885

Browse files
committed
added tests for the various "lua socket blah blah timed out" error messages; also tweaked other cosocket test cases for different test modes.
1 parent f95c55f commit 1bce885

File tree

4 files changed

+55
-41
lines changed

4 files changed

+55
-41
lines changed

t/058-tcp-socket.t

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use Test::Nginx::Socket;
55

66
repeat_each(2);
77

8-
plan tests => repeat_each() * (blocks() * 2 + 6);
8+
plan tests => repeat_each() * (blocks() * 2 + 8);
99

1010
our $HtmlDir = html_dir;
1111

@@ -345,7 +345,7 @@ connected: 1
345345
--- config
346346
server_tokens off;
347347
resolver $TEST_NGINX_RESOLVER;
348-
resolver_timeout 1s;
348+
resolver_timeout 2s;
349349
location /t {
350350
content_by_lua '
351351
local sock = ngx.socket.tcp()
@@ -1763,7 +1763,7 @@ subrequest: 200, OK\r
17631763
local sock = ngx.socket.tcp()
17641764
local port = ngx.var.port
17651765
1766-
sock:settimeout(200)
1766+
sock:settimeout(300)
17671767
17681768
local ok, err = sock:connect("127.0.0.1", port)
17691769
if not ok then
@@ -1836,7 +1836,7 @@ close: 1 nil
18361836
local sock = ngx.socket.tcp()
18371837
local port = ngx.var.port
18381838
1839-
sock:settimeout(200)
1839+
sock:settimeout(300)
18401840
18411841
local ok, err = sock:connect("127.0.0.1", port)
18421842
if not ok then
@@ -1891,7 +1891,7 @@ close: 1 nil
18911891
local sock = ngx.socket.tcp()
18921892
local port = ngx.var.port
18931893
1894-
sock:settimeout(200)
1894+
sock:settimeout(300)
18951895
18961896
local ok, err = sock:connect("127.0.0.1", port)
18971897
if not ok then

t/065-tcp-socket-timeout.t

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use Test::Nginx::Socket;
1818

1919
repeat_each(2);
2020

21-
plan tests => repeat_each() * (blocks() * 3 + 10);
21+
plan tests => repeat_each() * (blocks() * 4 + 10);
2222

2323
our $HtmlDir = html_dir;
2424

@@ -55,6 +55,7 @@ GET /t
5555
failed to connect: timeout
5656
--- error_log
5757
lua socket connect timeout: 100
58+
lua socket connect timed out
5859

5960

6061

@@ -82,6 +83,7 @@ GET /t
8283
failed to connect: timeout
8384
--- error_log
8485
lua socket connect timeout: 150
86+
lua socket connect timed out
8587

8688

8789

@@ -109,6 +111,7 @@ GET /t
109111
failed to connect: timeout
110112
--- error_log
111113
lua socket connect timeout: 102
114+
lua socket connect timed out
112115

113116

114117

@@ -136,6 +139,7 @@ GET /t
136139
failed to connect: timeout
137140
--- error_log
138141
lua socket connect timeout: 102
142+
lua socket connect timed out
139143

140144

141145

@@ -163,6 +167,7 @@ GET /t
163167
failed to connect: timeout
164168
--- error_log
165169
lua socket connect timeout: 102
170+
lua socket connect timed out
166171

167172

168173

@@ -196,9 +201,10 @@ GET /t
196201
--- response_body
197202
connected: 1
198203
failed to receive: timeout
199-
--- error_log eval
200-
["lua socket read timeout: 100",
201-
"lua socket connect timeout: 60000"]
204+
--- error_log
205+
lua socket read timeout: 100
206+
lua socket connect timeout: 60000
207+
lua socket read timed out
202208

203209

204210

@@ -234,9 +240,10 @@ GET /t
234240
--- response_body
235241
connected: 1
236242
failed to receive: timeout
237-
--- error_log eval
238-
["lua socket connect timeout: 60000",
239-
"lua socket read timeout: 150"]
243+
--- error_log
244+
lua socket connect timeout: 60000
245+
lua socket read timeout: 150
246+
lua socket read timed out
240247

241248

242249

@@ -272,9 +279,10 @@ GET /t
272279
--- response_body
273280
connected: 1
274281
failed to receive: timeout
275-
--- error_log eval
276-
["lua socket connect timeout: 60000",
277-
"lua socket read timeout: 102"]
282+
--- error_log
283+
lua socket connect timeout: 60000
284+
lua socket read timeout: 102
285+
lua socket read timed out
278286

279287

280288

@@ -311,9 +319,10 @@ GET /t
311319
--- response_body
312320
connected: 1
313321
failed to receive: timeout
314-
--- error_log eval
315-
["lua socket connect timeout: 60000",
316-
"lua socket read timeout: 102"]
322+
--- error_log
323+
lua socket connect timeout: 60000
324+
lua socket read timeout: 102
325+
lua socket read timed out
317326

318327

319328

@@ -349,9 +358,10 @@ GET /t
349358
--- response_body
350359
connected: 1
351360
failed to receive: timeout
352-
--- error_log eval
353-
["lua socket read timeout: 102",
354-
"lua socket connect timeout: 60000"]
361+
--- error_log
362+
lua socket read timeout: 102
363+
lua socket connect timeout: 60000
364+
lua socket read timed out
355365

356366

357367

@@ -385,9 +395,10 @@ GET /t
385395
--- response_body
386396
connected: 1
387397
failed to send: timeout
388-
--- error_log eval
389-
["lua socket send timeout: 100",
390-
"lua socket connect timeout: 60000"]
398+
--- error_log
399+
lua socket send timeout: 100
400+
lua socket connect timeout: 60000
401+
lua socket write timed out
391402

392403

393404

@@ -423,9 +434,10 @@ GET /t
423434
--- response_body
424435
connected: 1
425436
failed to send: timeout
426-
--- error_log eval
427-
["lua socket connect timeout: 60000",
428-
"lua socket send timeout: 150"]
437+
--- error_log
438+
lua socket connect timeout: 60000
439+
lua socket send timeout: 150
440+
lua socket write timed out
429441

430442

431443

@@ -461,9 +473,10 @@ GET /t
461473
--- response_body
462474
connected: 1
463475
failed to send: timeout
464-
--- error_log eval
465-
["lua socket connect timeout: 60000",
466-
"lua socket send timeout: 102"]
476+
--- error_log
477+
lua socket connect timeout: 60000
478+
lua socket send timeout: 102
479+
lua socket write timed out
467480

468481

469482

@@ -499,9 +512,10 @@ GET /t
499512
--- response_body
500513
connected: 1
501514
failed to send: timeout
502-
--- error_log eval
503-
["lua socket connect timeout: 60000",
504-
"lua socket send timeout: 102"]
515+
--- error_log
516+
lua socket connect timeout: 60000
517+
lua socket send timeout: 102
518+
lua socket write timed out
505519

506520

507521

@@ -537,7 +551,8 @@ GET /t
537551
--- response_body
538552
connected: 1
539553
failed to send: timeout
540-
--- error_log eval
541-
["lua socket send timeout: 102",
542-
"lua socket connect timeout: 60000"]
554+
--- error_log
555+
lua socket send timeout: 102
556+
lua socket connect timeout: 60000
557+
lua socket write timed out
543558

t/067-req-socket.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,5 +363,5 @@ hello world
363363
|failed to receive: closed [d]
364364
)?done
365365
--- no_error_log
366-
[error]
366+
[alert]
367367

t/068-socket-keepalive.t

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,9 @@ received: OK
8282
["[error]",
8383
"lua socket keepalive: free connection pool for "]
8484
--- error_log eval
85-
[
86-
'lua socket get keepalive peer: using connection',
87-
'lua socket keepalive create connection pool for key "127.0.0.1:11211"',
88-
]
85+
qq{lua socket get keepalive peer: using connection
86+
lua socket keepalive create connection pool for key "127.0.0.1:$ENV{TEST_NGINX_MEMCACHED_PORT}"
87+
}
8988

9089

9190

0 commit comments

Comments
 (0)