forked from 3scale/APIcast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbalancer.t
37 lines (31 loc) · 843 Bytes
/
balancer.t
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
use lib 't';
use Test::APIcast 'no_plan';
$ENV{TEST_NGINX_HTTP_CONFIG} = "$Test::APIcast::path/http.d/*.conf";
$ENV{RESOLVER} = '127.0.1.1:5353';
env_to_nginx(
'RESOLVER'
);
master_on();
run_tests();
__DATA__
=== TEST 1: round robin does not leak memory
Balancing different hosts does not leak memory.
--- http_config
lua_package_path "$TEST_NGINX_LUA_PATH";
init_by_lua_block {
require('resty.balancer.round_robin').cache_size = 1
}
--- config
location = /t {
content_by_lua_block {
local round_robin = require('resty.balancer.round_robin')
local balancer = round_robin.new()
local peers = { hash = ngx.var.request_id, cur = 1, 1, 2 }
local peer = round_robin.call(peers)
ngx.print(peer)
}
}
--- pipelined_requests eval
[ "GET /t", "GET /t" ]
--- response_body eval
[ "1", "1" ]