@@ -908,3 +908,75 @@ true
908908true
909909--- no_error_log
910910[alert]
911+
912+
913+
914+ === TEST 22: http bulk sends each batch with its own conf (regression)
915+ --- http_config
916+ server {
917+ listen 10420;
918+
919+ location ~ ^/loggly/bulk/(?<token>[^/]+)/tag/bulk$ {
920+ content_by_lua_block {
921+ ngx.req.read_body()
922+ local headers = ngx.req.get_headers()
923+ ngx.log(ngx.ERR, "loggly-recv token: ", ngx.var.token,
924+ " tags: ", require("toolkit.json").encode(headers["X-LOGGLY-TAG"]))
925+ ngx.say("ok")
926+ }
927+ }
928+ }
929+ --- config
930+ location /t {
931+ content_by_lua_block {
932+ local t = require("lib.test_admin").test
933+
934+ local code = t('/apisix/admin/plugin_metadata/loggly', ngx.HTTP_PUT, [[{
935+ "host": "127.0.0.1:10420/loggly",
936+ "protocol": "http"
937+ }]])
938+ if code >= 300 then ngx.say("metadata failed: ", code); return end
939+
940+ local code = t('/apisix/admin/routes/1', ngx.HTTP_PUT, [[{
941+ "plugins": {
942+ "loggly": {
943+ "customer_token": "token-a",
944+ "tags": ["aaa"],
945+ "inactive_timeout": 1
946+ }
947+ },
948+ "upstream": {"nodes": {"127.0.0.1:1980": 1}, "type": "roundrobin"},
949+ "host": "127.0.0.1",
950+ "uri": "/route_a"
951+ }]])
952+ if code >= 300 then ngx.say("route_a failed: ", code); return end
953+
954+ local code = t('/apisix/admin/routes/2', ngx.HTTP_PUT, [[{
955+ "plugins": {
956+ "loggly": {
957+ "customer_token": "token-b",
958+ "tags": ["bbb"],
959+ "inactive_timeout": 1
960+ }
961+ },
962+ "upstream": {"nodes": {"127.0.0.1:1980": 1}, "type": "roundrobin"},
963+ "host": "127.0.0.1",
964+ "uri": "/route_b"
965+ }]])
966+ if code >= 300 then ngx.say("route_b failed: ", code); return end
967+
968+ -- buffer one entry per config before either batch flushes, so the
969+ -- old shared closure would send both with the last conf's token
970+ t("/route_a", ngx.HTTP_GET)
971+ t("/route_b", ngx.HTTP_GET)
972+ ngx.say("done")
973+ }
974+ }
975+ --- wait: 3
976+ --- response_body
977+ done
978+ --- error_log
979+ loggly-recv token: token-a tags: "aaa"
980+ loggly-recv token: token-b tags: "bbb"
981+ --- no_error_log
982+ [alert]
0 commit comments