Skip to content

Commit

Permalink
fix test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
qizhendong committed Feb 14, 2022
1 parent b69cea1 commit cbb5f53
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions t/plugin/error-log-logger-clickhouse.t
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -200,17 +215,18 @@ 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.")
}
}
--- request
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
Expand All @@ -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
Expand Down

0 comments on commit cbb5f53

Please sign in to comment.