Skip to content

Commit

Permalink
verify clickhouse headers on test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
qizhendong committed Feb 14, 2022
1 parent 34f3dcb commit 9118fb0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apisix/plugins/clickhouse-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ local function send_http_data(conf, log_message)
.. tostring(port) .. "] " .. err
end

if url_decoded.scheme == "https" and conf.ssl_verify then
if url_decoded.scheme == "https" then
ok, err = httpc:ssl_handshake(true, host, conf.ssl_verify)
if not ok then
return false, "failed to perform SSL with host[" .. host .. "] "
Expand Down
15 changes: 9 additions & 6 deletions t/plugin/clickhouse-logger.t
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ add_block_preprocessor(sub {
ngx.req.read_body()
local data = ngx.req.get_body_data()
local headers = ngx.req.get_headers()
ngx.log(ngx.ERR, "clickhouse body: ", data)
ngx.log(ngx.WARN, "clickhouse body: ", data)
for k, v in pairs(headers) do
ngx.log(ngx.WARN, "clickhouse headers: " .. k .. ":" .. v)
end
ngx.say("ok")
}
}
Expand Down Expand Up @@ -133,9 +136,6 @@ property "endpoint_addr" is required
=== TEST 4: add plugin on routes
apisix:
node_listen: 1984
admin_key: null
--- config
location /t {
content_by_lua_block {
Expand Down Expand Up @@ -211,6 +211,9 @@ passed
GET /opentracing
--- response_body
opentracing
--- grep_error_log_out
"clickhouse body: INSERT INTO t FORMAT JSONEachRow"
--- error_log
clickhouse body: INSERT INTO t FORMAT JSONEachRow
clickhouse headers: X-ClickHouse-Key:a
clickhouse headers: X-ClickHouse-User:default
clickhouse headers: X-ClickHouse-Database:default
--- wait: 5

0 comments on commit 9118fb0

Please sign in to comment.