spacewander commented on code in PR #8205:
URL: https://github.com/apache/apisix/pull/8205#discussion_r1055128624
##########
t/plugin/google-cloud-logging.t:
##########
@@ -31,6 +31,43 @@ add_block_preprocessor(sub {
if (!defined $block->request) {
$block->set_value("request", "GET /t");
}
+ my $http_config = $block->http_config // <<_EOC_;
+server {
+ listen 12001;
+
+ location /google-cloud-logging/test {
+ content_by_lua_block {
+ ngx.req.read_body()
+ local data = ngx.req.get_body_data()
+ ngx.log(ngx.WARN, "google cloud logging request body: ", data)
+ ngx.log(ngx.ERR, data)
+ ngx.say('test-http-logger-response')
+ ngx.log(ngx.WARN, "loggingBody:", data)
Review Comment:
The logging of the data is a bit confusing. The same data here is logged by
three times.
##########
t/plugin/google-cloud-logging.t:
##########
@@ -745,9 +783,58 @@ passed
-=== TEST 25: test route(https file configuration SSL authentication succeed:
ssl_verify = false)
+=== TEST 25: test route (https file configuration SSL authentication succeed:
ssl_verify = false)
--- request
GET /hello
--- wait: 2
--- response_body
hello world
+
+
+
+=== TEST 26: set fetch request body true in configuration
+--- config
+ location /t {
+ content_by_lua_block {
+ local config = {
+ uri = "/google-cloud-logging/test",
+ method = 'POST',
+ upstream = {
+ type = "roundrobin",
+ nodes = {
+ ["127.0.0.1:12001"] = 1
+ }
+ },
+ plugins = {
+ ["google-cloud-logging"] = {
+ auth_file =
"t/plugin/google-cloud-logging/config.json",
+ inactive_timeout = 1,
+ batch_max_size = 1,
+ include_req_body = true,
+ }
+ }
+ }
+ local t = require("lib.test_admin").test
+ local code, body = t('/apisix/admin/routes/1', ngx.HTTP_PUT,
config)
+
+ if code >= 300 then
+ ngx.status = code
+ ngx.say(body)
+ return
+ end
+
+ ngx.say(body)
+ }
+ }
+--- response_body
+passed
+
+
+
+=== TEST 27: check request body included in log entry
+--- request
+POST /google-cloud-logging/test
+{"bodyItem": "something"}
+--- error_log eval
+qr/gcp logs body entries/
Review Comment:
Could we also check if the logged body is exactly the same as `{"bodyItem":
"something"}`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]