blob: c00773e1f0ee343facca79effce004b9cdfd4bab (
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
|
# vim:set ft= ts=4 sw=4 et fdm=marker:
use Test::Nginx::Socket::Lua::Stream;
#worker_connections(1014);
#master_process_enabled(1);
#log_level('warn');
repeat_each(2);
plan tests => repeat_each() * (blocks() * 2 + 2);
#no_diff();
#no_long_string();
run_tests();
__DATA__
=== TEST 1: get_phase in init_by_lua
--- stream_config
init_by_lua_block { phase = ngx.get_phase() }
--- stream_server_config
content_by_lua_block {
ngx.say(phase)
}
--- stream_response
init
=== TEST 2: get_phase in access_by_lua
TODO
--- SKIP
--- stream_server_config
access_by_lua_block {
ngx.say(ngx.get_phase())
ngx.exit(200)
}
--- stream_response
access
=== TEST 3: get_phase in content_by_lua
--- stream_server_config
content_by_lua_block {
ngx.say(ngx.get_phase())
}
--- stream_response
content
=== TEST 4: get_phase in log_by_lua_block
TODO
--- SKIP
--- stream_server_config
echo "OK";
log_by_lua_block {
ngx.log(ngx.ERR, ngx.get_phase())
}
--- error_log
log
=== TEST 5: get_phase in ngx.timer callback
--- stream_server_config
content_by_lua_block {
local function f()
ngx.log(ngx.WARN, "current phase: ", ngx.get_phase())
end
local ok, err = ngx.timer.at(0, f)
if not ok then
ngx.log(ngx.ERR, "failed to add timer: ", err)
end
}
--- no_error_log
[error]
--- error_log
current phase: timer
=== TEST 6: get_phase in init_worker_by_lua
--- stream_config
init_worker_by_lua_block { phase = ngx.get_phase() }
--- stream_server_config
content_by_lua_block {
ngx.say(phase)
}
--- stream_response
init_worker
--- no_error_log
[error]
|