Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

balancer.t conversion to blackbox #1416

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 25 additions & 14 deletions t/balancer.t
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
use lib 't';
use Test::APIcast 'no_plan';
use Test::APIcast::Blackbox '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
--- configuration
{
"services": [
{
"id": 42,
"backend_version": 1,
"backend_authentication_type": "service_token",
"backend_authentication_value": "token-value",
"proxy": {
"api_backend": "http://test:$TEST_NGINX_SERVER_PORT/",
"proxy_rules": [ { "pattern" : "/", "http_method" : "GET",
"metric_system_name" : "hits", "delta" : 2 } ]
}
}
]
}
--- backend
location /transactions/authrep.xml {
content_by_lua_block {
ngx.exit(200)
}
}
--- config
--- upstream
location = /t {
content_by_lua_block {
require('resty.balancer.round_robin').cache_size = 1
local round_robin = require('resty.balancer.round_robin')
local balancer = round_robin.new()

Expand All @@ -32,6 +43,6 @@ Balancing different hosts does not leak memory.
}
}
--- pipelined_requests eval
[ "GET /t", "GET /t" ]
[ "GET /t?user_key=value", "GET /t?user_key=value" ]
--- response_body eval
[ "1", "1" ]
Loading