From cbb5f53ead8c8307835888935bd1140c39fcfdb9 Mon Sep 17 00:00:00 2001 From: qizhendong Date: Fri, 11 Feb 2022 09:22:39 +0800 Subject: [PATCH] fix test cases --- t/plugin/error-log-logger-clickhouse.t | 37 ++++++++++++++++++-------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/t/plugin/error-log-logger-clickhouse.t b/t/plugin/error-log-logger-clickhouse.t index 09663f1e5a49c..0601eb4811361 100644 --- a/t/plugin/error-log-logger-clickhouse.t +++ b/t/plugin/error-log-logger-clickhouse.t @@ -40,7 +40,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 error body: ", data) + ngx.log(ngx.WARN, "clickhouse error log body: ", data) + for k, v in pairs(headers) do + ngx.log(ngx.WARN, "clickhouse headers: " .. k .. ":" .. v) + end ngx.say("ok") } } @@ -121,7 +124,11 @@ plugins: GET /tg --- response_body --- grep_error_log_out -clickhouse error body: +"this is a warning message for test2." +"clickhouse error log 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: 3 @@ -160,7 +167,11 @@ plugins: GET /tg --- response_body --- grep_error_log_out -this is an error message for test3. +"this is an error message for test3." +"clickhouse error log 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 @@ -183,8 +194,12 @@ plugins: GET /tg --- response_body --- grep_error_log_out -clickhouse body: -this is a warning message for test4. +"this is a warning message for test4." +"clickhouse error log 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 @@ -200,7 +215,6 @@ plugins: location /tg { content_by_lua_block { local core = require("apisix.core") - core.log.error("this is an error message for test5.") core.log.warn("this is a warning message for test5.") } } @@ -208,9 +222,11 @@ plugins: GET /tg --- response_body --- grep_error_log_out -clickhouse body: ---- error_log eval -this is an error message for test5. +"this is a warning message for test5." +"clickhouse error log 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 @@ -233,8 +249,7 @@ plugins: GET /tg --- response_body --- grep_error_log_out -clickhouse body: -this is an info message for test6. +clickhouse error log body: --- wait: 5