From 9118fb06ee0892c4722ec75d52e8b1f6f718a183 Mon Sep 17 00:00:00 2001 From: qizhendong Date: Mon, 14 Feb 2022 10:45:55 +0800 Subject: [PATCH] verify clickhouse headers on test cases --- apisix/plugins/clickhouse-logger.lua | 2 +- t/plugin/clickhouse-logger.t | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/apisix/plugins/clickhouse-logger.lua b/apisix/plugins/clickhouse-logger.lua index ef5234b7c8d7..f7b734645334 100644 --- a/apisix/plugins/clickhouse-logger.lua +++ b/apisix/plugins/clickhouse-logger.lua @@ -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 .. "] " diff --git a/t/plugin/clickhouse-logger.t b/t/plugin/clickhouse-logger.t index d6999c33a09a..459099d2e014 100644 --- a/t/plugin/clickhouse-logger.t +++ b/t/plugin/clickhouse-logger.t @@ -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") } } @@ -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 { @@ -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