Skip to content

Commit

Permalink
test(clickhouse-logger): to show that different endpoints will be cho…
Browse files Browse the repository at this point in the history
…sen randomly (#8777)
  • Loading branch information
xiaoxuanzi authored Oct 27, 2023
1 parent 5911211 commit f1d4168
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions t/plugin/clickhouse-logger.t
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ passed
"database": "default",
"logtable": "test",
"endpoint_addrs": ["http://127.0.0.1:8123",
"http://127.0.0.1:8124"]
"http://127.0.0.1:8124"],
"batch_max_size":1,
"inactive_timeout":1
}
},
"upstream": {
Expand Down Expand Up @@ -229,7 +231,38 @@ echo "select * from default.test" | curl 'http://localhost:8124/' --data-binary
=== TEST 8: use single clickhouse server
=== TEST 8: to show that different endpoints will be chosen randomly
--- config
location /t {
content_by_lua_block {
local code_count = {}
local t = require("lib.test_admin").test
for i = 1, 12 do
local code, body = t('/opentracing', ngx.HTTP_GET)
if code ~= 200 then
ngx.say("code: ", code, " body: ", body)
end
code_count[code] = (code_count[code] or 0) + 1
end
local code_arr = {}
for code, count in pairs(code_count) do
table.insert(code_arr, {code = code, count = count})
end
ngx.say(require("toolkit.json").encode(code_arr))
ngx.exit(200)
}
}
--- response_body
[{"code":200,"count":12}]
--- error_log
sending a batch logs to http://127.0.0.1:8123
sending a batch logs to http://127.0.0.1:8124
=== TEST 9: use single clickhouse server
--- config
location /t {
content_by_lua_block {
Expand Down Expand Up @@ -267,15 +300,15 @@ passed
=== TEST 9: hit route
=== TEST 10: hit route
--- request
GET /opentracing
--- error_code: 200
--- wait: 5
=== TEST 10: get log
=== TEST 11: get log
--- exec
echo "select * from default.test" | curl 'http://localhost:8123/' --data-binary @-
--- response_body_like
Expand Down

0 comments on commit f1d4168

Please sign in to comment.