blob: b27bed9b03fdb0ef7569900ab5c95235c4b0ec06 (
plain)
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
108
109
110
111
112
113
114
|
# vim:set ft= ts=4 sw=4 et fdm=marker:
use Test::Nginx::Socket::Lua::Stream;
#repeat_each(20000);
repeat_each(2);
#master_on();
#workers(1);
#log_level('debug');
#log_level('warn');
#worker_connections(1024);
plan tests => repeat_each() * (blocks() * 3);
$ENV{TEST_NGINX_MEMCACHED_PORT} ||= 11211;
$ENV{TEST_NGINX_MYSQL_PORT} ||= 3306;
our $LuaCpath = $ENV{LUA_CPATH} ||
'/usr/local/openresty-debug/lualib/?.so;/usr/local/openresty/lualib/?.so;;';
#$ENV{LUA_PATH} = $ENV{HOME} . '/work/JSON4Lua-0.9.30/json/?.lua';
no_long_string();
run_tests();
__DATA__
=== TEST 1: throw error
--- stream_server_config
content_by_lua_block { ngx.exit(ngx.ERROR);ngx.say('hi') }
--- stream_response
--- no_error_log
[error]
=== TEST 2: throw error after sending the header and partial body
--- stream_server_config
content_by_lua_block { ngx.say('hi');ngx.exit(ngx.ERROR);ngx.say(', you') }
--- no_error_log
[error]
--- stream_response
hi
=== TEST 3: throw 0
--- stream_server_config
content_by_lua_block { ngx.say('Hi'); ngx.eof(); ngx.exit(0);ngx.say('world') }
--- stream_response
Hi
--- no_error_log
[error]
=== TEST 4: pcall safe
--- stream_server_config
content_by_lua_block {
function f ()
ngx.say("hello")
ngx.exit(200)
end
pcall(f)
ngx.say("world")
}
--- stream_response
hello
--- no_error_log
[error]
=== TEST 5: throw 444 after sending out responses
--- stream_server_config
content_by_lua_block {
ngx.say('ok');
return ngx.exit(444)
}
--- stream_response
ok
--- log_level: debug
--- no_error_log
[error]
=== TEST 6: throw 499 after sending out responses
--- stream_server_config
content_by_lua_block {
ngx.say('ok');
return ngx.exit(499)
}
--- stream_response
ok
--- log_level: debug
--- no_error_log
[error]
=== TEST 7: throw 408 after sending out responses
--- stream_server_config
content_by_lua_block {
ngx.say('ok');
return ngx.exit(408)
}
--- stream_response
ok
--- log_level: debug
--- no_error_log
[error]
|