Skip to content

Commit 2aa42d5

Browse files
committed
tests: added passing tests for using ngx.worker.count() in the context of init_by_lua*.
1 parent 5231d5f commit 2aa42d5

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

t/133-worker-count.t

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,23 @@ GET /lua
3030
workers: 1
3131
--- no_error_log
3232
[error]
33+
34+
35+
36+
=== TEST 2: init_by_lua
37+
--- http_config
38+
init_by_lua_block {
39+
package.loaded.count = ngx.worker.count()
40+
}
41+
--- config
42+
location /lua {
43+
content_by_lua_block {
44+
ngx.say("workers: ", package.loaded.count)
45+
}
46+
}
47+
--- request
48+
GET /lua
49+
--- response_body
50+
workers: 1
51+
--- no_error_log
52+
[error]

t/134-worker-count-5.t

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,23 @@ GET /lua
3030
worker count: 5
3131
--- no_error_log
3232
[error]
33+
34+
35+
36+
=== TEST 2: init_by_lua
37+
--- http_config
38+
init_by_lua_block {
39+
package.loaded.count = ngx.worker.count()
40+
}
41+
--- config
42+
location /lua {
43+
content_by_lua_block {
44+
ngx.say("workers: ", package.loaded.count)
45+
}
46+
}
47+
--- request
48+
GET /lua
49+
--- response_body
50+
workers: 5
51+
--- no_error_log
52+
[error]

0 commit comments

Comments
 (0)