Baoyuantop commented on code in PR #12779:
URL: https://github.com/apache/apisix/pull/12779#discussion_r2567083145


##########
t/plugin/batch-requests2.t:
##########
@@ -444,3 +444,52 @@ POST /apisix/batch-requests
 }
 --- response_headers
 Content-Type: application/json
+
+
+=== TEST 11: Ensure sub_responses count matches sub_requests on timed out 
sub_request (contains no empty json object like '{}' in batch response)
+--- config
+    location = /aggregate {
+        content_by_lua_block {
+            local cjson = require("cjson.safe")
+            local core = require("apisix.core")
+            local t = require("lib.test_admin").test
+            local code, body, res_body, res_header = 
t('/apisix/batch-requests',
+                 ngx.HTTP_POST,
+                 [=[{
+                    "headers": {
+                    },
+                    "timeout": 200,
+                    "pipeline":[
+                    {
+                        "path": "/ok",
+                        "method": "GET"
+                    },{
+                      "path": "/timeout",
+                      "method": "GET"
+                    }]
+                }]=])
+            -- core.log.warn("res_body:", res_body)

Review Comment:
   Do we need this line?



##########
t/plugin/batch-requests2.t:
##########
@@ -444,3 +444,52 @@ POST /apisix/batch-requests
 }
 --- response_headers
 Content-Type: application/json
+
+
+=== TEST 11: Ensure sub_responses count matches sub_requests on timed out 
sub_request (contains no empty json object like '{}' in batch response)
+--- config
+    location = /aggregate {
+        content_by_lua_block {
+            local cjson = require("cjson.safe")
+            local core = require("apisix.core")
+            local t = require("lib.test_admin").test
+            local code, body, res_body, res_header = 
t('/apisix/batch-requests',
+                 ngx.HTTP_POST,
+                 [=[{
+                    "headers": {
+                    },
+                    "timeout": 200,
+                    "pipeline":[
+                    {
+                        "path": "/ok",
+                        "method": "GET"
+                    },{
+                      "path": "/timeout",
+                      "method": "GET"
+                    }]
+                }]=])
+            -- core.log.warn("res_body:", res_body)
+            ngx.status = code
+            -- print the number of sub-responses.
+            -- the number is expected to be the same as that of the 
sub-requests.
+            ngx.say(#cjson.decode(res_body))
+        }
+    }
+
+    location = /ok {
+        content_by_lua_block {
+            ngx.print("ok")
+        }
+    }
+    location = /timeout {
+        content_by_lua_block {
+            ngx.sleep(1)
+            ngx.print("timeout")
+        }
+    }
+--- request
+GET /aggregate
+--- error_log
+timeout
+--- response_body
+2

Review Comment:
   It is recommended to check the specific content, such as the status.



-- 
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]

Reply via email to