doc: ngx.worker.count() is available in the init_worker_by_lua* context.
[lua-nginx-module.git] / t / 133-worker-count.t
blob3e03ecc843564db14506ef821e66f1752b7c6bc9
1 # vim:set ft= ts=4 sw=4 et fdm=marker:
3 use Test::Nginx::Socket::Lua;
5 #worker_connections(1014);
6 #master_on();
7 #workers(2);
8 #log_level('warn');
10 repeat_each(2);
12 plan tests => repeat_each() * (blocks() * 3);
14 #no_diff();
15 #no_long_string();
16 run_tests();
18 __DATA__
20 === TEST 1: content_by_lua
21 --- config
22     location /lua {
23         content_by_lua_block {
24             ngx.say("workers: ", ngx.worker.count())
25         }
26     }
27 --- request
28 GET /lua
29 --- response_body
30 workers: 1
31 --- no_error_log
32 [error]
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]
56 === TEST 3: init_worker_by_lua
57 --- http_config
58     init_worker_by_lua_block {
59         init_worker_count = ngx.worker.count()
60     }
61 --- config
62     location /lua {
63         content_by_lua_block {
64             ngx.say("workers: ", init_worker_count)
65         }
66     }
67 --- request
68 GET /lua
69 --- response_body
70 workers: 1
71 --- no_error_log
72 [error]