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 1 commit
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
34 changes: 21 additions & 13 deletions t/balancer.t
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
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();
repeat_each(1);
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": [
{
"proxy": {
"policy_chain": [
{ "name": "apicast.policy.upstream",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of upstream poilicy, maybe better "api_backend": "http://test:$TEST_NGINX_SERVER_PORT/", ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it, with authentication as I did not find a straightforward way to use "api_backend" w/o authentication in other blackbox enabled tests. Is there a way to disable authentication as it does not seem to be needed for this test?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to disable authentication as it does not seem to be needed for this test?

You can add a policy in the policy chain called default_credentials. However, it is not a big deal to add ?user_key=value as you did. I think it is ok like that

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, having unauthenticated requests is not a common use case. Thank you @eguzki !

"configuration":
{
"rules": [ { "regex": "/", "http_method": "GET",
"url": "http://test:$TEST_NGINX_SERVER_PORT" } ]
}
}
]
}
}
]
}
--- 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 Down