Skip to content

Commit e846dc4

Browse files
tests: add a test case for balancer.set_keepalive.
1 parent 34a59a7 commit e846dc4

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

t/balancer-keepalive.t

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,3 +1220,53 @@ get keepalive peer
12201220
free keepalive peer
12211221
free keepalive peer
12221222
lua balancer: keepalive not saving connection \S+$/
1223+
1224+
1225+
1226+
=== TEST 28: long hostname
1227+
--- http_upstream
1228+
upstream test_upstream {
1229+
server 0.0.0.1;
1230+
1231+
balancer_by_lua_block {
1232+
local b = require "ngx.balancer"
1233+
1234+
local ip = ngx.var.arg_ip or "127.0.0.1"
1235+
local port = ngx.var.arg_port or $TEST_NGINX_SERVER_SSL_PORT
1236+
local host = ngx.var.arg_cn or "keepalive1.test.host.com"
1237+
1238+
local ok, err = b.set_current_peer(ip, port, host)
1239+
if not ok then
1240+
ngx.log(ngx.ERR, "failed to set current peer: ", err)
1241+
return
1242+
end
1243+
1244+
local ok, err = b.enable_keepalive()
1245+
if not ok then
1246+
ngx.log(ngx.ERR, "failed to set keepalive: ", err)
1247+
return
1248+
end
1249+
}
1250+
}
1251+
--- config eval
1252+
"
1253+
location = /t {
1254+
echo_subrequest GET '/proxy_lua_sni/echo_sni' -q 'ip=127.0.0.1&cn=keepalive1.longname.test.host.com';
1255+
echo_subrequest GET '/proxy_lua_sni/echo_sni' -q 'ip=127.0.0.1&cn=keepalive1.longname.test.host.com';
1256+
echo_subrequest GET '/proxy_lua_sni/echo_sni' -q 'ip=127.0.0.2&cn=keepalive2.longname.test.host.com';
1257+
echo_subrequest GET '/proxy_lua_sni/echo_sni' -q 'ip=127.0.0.2&cn=keepalive2.longname.test.host.com';
1258+
echo_subrequest GET '/proxy_lua_sni/echo_sni' -q 'ip=127.0.0.2&cn=keepalive2.longname.test.host.com&port=$ENV{TEST_NGINX_SERVER_SSL_PORT_2}';
1259+
}
1260+
"
1261+
--- response_body
1262+
SNI=keepalive1.longname.test.host.com
1263+
SNI=keepalive1.longname.test.host.com
1264+
SNI=keepalive2.longname.test.host.com
1265+
SNI=keepalive2.longname.test.host.com
1266+
SNI=keepalive2.longname.test.host.com
1267+
--- grep_error_log eval
1268+
qr/keepalive reusing connection[^\n]*/
1269+
--- grep_error_log_out eval
1270+
qr/keepalive reusing connection [0-9A-F]+, host: 127.0.0.1:\d+, name: keepalive1.longname.test.host.com
1271+
keepalive reusing connection [0-9A-F]+, host: 127.0.0.2:\d+, name: keepalive2.longname.test.host.com
1272+
/

0 commit comments

Comments
 (0)