You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/07/08 08:10:49 UTC

[GitHub] [apisix] arthur-zhang opened a new pull request #4563: feat(batch-requests): allow customizing uri in batch-requests

arthur-zhang opened a new pull request #4563:
URL: https://github.com/apache/apisix/pull/4563


   ### What this PR does / why we need it:
   Support  customizing uri in batch-requests
   
   ### Pre-submission checklist:
   
   * [x] Did you explain what problem does this PR solve? Or what new features have been added?
   * [x] Have you added corresponding test cases?
   * [x] Have you modified the corresponding document?
   * [x] Is this PR backward compatible? **If it is not backward compatible, please discuss on the [mailing list](https://github.com/apache/apisix/tree/master#community) first**
   


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] arthur-zhang commented on pull request #4563: feat(batch-requests): allow customizing uri in batch-requests

Posted by GitBox <gi...@apache.org>.
arthur-zhang commented on pull request #4563:
URL: https://github.com/apache/apisix/pull/4563#issuecomment-876398835


   > @arthur-zhang Need to check out the CI problems.
   
   all done
   


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander commented on a change in pull request #4563: feat(batch-requests): allow customizing uri in batch-requests

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #4563:
URL: https://github.com/apache/apisix/pull/4563#discussion_r667304979



##########
File path: t/plugin/batch-requests2.t
##########
@@ -0,0 +1,222 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+log_level("debug");

Review comment:
       We don't need to set log level to debug

##########
File path: t/plugin/batch-requests2.t
##########
@@ -0,0 +1,222 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+log_level("debug");
+
+add_block_preprocessor(sub {
+    my ($block) = @_;
+
+    if (!$block->request) {
+        $block->set_value("request", "GET /t");
+    }
+
+    if (!$block->no_error_log && !$block->error_log) {
+        $block->set_value("no_error_log", "[error]\n[alert]");
+    }
+});
+
+run_tests;
+
+__DATA__
+
+=== TEST 1: customize uri, not found
+--- yaml_config
+plugin_attr:
+    batch-requests:
+        uri: "/foo/bar"
+--- config
+    location = /t {
+        content_by_lua_block {
+            local core = require("apisix.core")
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/batch-requests',
+                ngx.HTTP_POST,
+                [=[{
+                    "timeout": 100,
+                    "pipeline":[
+                    {
+                        "path": "/a"
+                    }]
+                }]=],
+                [=[[
+                {
+                    "status": 200
+                }
+                ]]=]
+                )
+
+            ngx.status = code
+            ngx.say(body)
+        }
+    }
+
+    location = /a {
+        content_by_lua_block {
+            ngx.status = 200
+        }
+    }
+--- request
+GET /t

Review comment:
       The `GET /t` is already set.




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tokers commented on pull request #4563: feat(batch-requests): allow customizing uri in batch-requests

Posted by GitBox <gi...@apache.org>.
tokers commented on pull request #4563:
URL: https://github.com/apache/apisix/pull/4563#issuecomment-876351156


   @arthur-zhang Need to check out the CI problems.


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] Yiyiyimu commented on a change in pull request #4563: feat(batch-requests): allow customizing uri in batch-requests

Posted by GitBox <gi...@apache.org>.
Yiyiyimu commented on a change in pull request #4563:
URL: https://github.com/apache/apisix/pull/4563#discussion_r666379046



##########
File path: t/plugin/batch-requests.t
##########
@@ -1017,3 +1017,204 @@ GET /t
 passed
 --- no_error_log
 [error]
+
+
+
+=== TEST 24: customize uri, not found
+--- yaml_config
+plugin_attr:
+    batch-requests:
+        uri: "/foo/bar"
+--- config
+    location = /aggregate {

Review comment:
       We used to name it `/t`

##########
File path: docs/en/latest/plugins/batch-requests.md
##########
@@ -109,6 +109,22 @@ Response is `Array` of [HttpResponse](#httpresponse).
 | body    | string  | http response body    |
 | headers | object  | http response headers |
 
+## How to specify custom uri
+
+We can change the default uri in the `plugin_attr` section of `conf/config.yaml`.
+
+| Name       | Type   | Default                      | Description                       |

Review comment:
       Could you also add column `Requirement` like http://apisix.apache.org/docs/apisix/plugins/proxy-rewrite/#attributes

##########
File path: t/plugin/batch-requests.t
##########
@@ -1017,3 +1017,204 @@ GET /t
 passed
 --- no_error_log
 [error]
+
+
+
+=== TEST 24: customize uri, not found
+--- yaml_config
+plugin_attr:
+    batch-requests:
+        uri: "/foo/bar"
+--- config
+    location = /aggregate {
+        content_by_lua_block {
+            local core = require("apisix.core")
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/batch-requests',
+                ngx.HTTP_POST,
+                [=[{
+                    "timeout": 100,
+                    "pipeline":[
+                    {
+                        "path": "/a"
+                    }]
+                }]=],
+                [=[[
+                {
+                    "status": 200
+                }
+                ]]=]
+                )
+
+            ngx.status = code
+            ngx.say(body)
+        }
+    }
+
+    location = /a {
+        content_by_lua_block {
+            ngx.status = 200
+        }
+    }
+--- request
+GET /aggregate
+--- error_code: 404
+--- no_error_log
+[error]
+
+
+
+=== TEST 25: customize uri, found
+--- yaml_config
+plugin_attr:
+    batch-requests:
+        uri: "/foo/bar"
+--- config
+    location = /aggregate {
+        content_by_lua_block {
+            local core = require("apisix.core")
+            local t = require("lib.test_admin").test
+            local code, body = t('/foo/bar',
+                ngx.HTTP_POST,
+                [=[{
+                    "timeout": 100,
+                    "pipeline":[
+                    {
+                        "path": "/b",
+                        "headers": {
+                            "Header1": "hello",
+                            "Header2": "world"
+                        }
+                    },{
+                        "path": "/c",
+                        "method": "PUT"
+                    },{
+                        "path": "/d"
+                    }]
+                }]=],
+                [=[[
+                {
+                    "status": 200
+                },
+                {
+                    "status": 201
+                },
+                {
+                    "status": 202
+                }
+                ]]=]
+                )
+
+            ngx.status = code
+            ngx.say(body)
+        }
+    }
+
+    location = /b {
+        content_by_lua_block {
+            ngx.status = 200
+        }
+    }
+    location = /c {
+        content_by_lua_block {
+            ngx.status = 201
+        }
+    }
+    location = /d {
+        content_by_lua_block {
+            ngx.status = 202
+        }
+    }
+--- request
+GET /aggregate
+--- error_code: 200
+--- no_error_log
+[error]
+
+
+
+=== TEST 26: customize uri, missing plugin, use default
+--- yaml_config
+plugin_attr:
+    x:
+      xyz: "/foo/bar"

Review comment:
       ```suggestion
         uri: "/foo/bar"
   ```




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander commented on a change in pull request #4563: feat(batch-requests): allow customizing uri in batch-requests

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #4563:
URL: https://github.com/apache/apisix/pull/4563#discussion_r667286316



##########
File path: t/plugin/batch-requests.t
##########
@@ -1017,3 +1017,204 @@ GET /t
 passed
 --- no_error_log
 [error]
+
+
+
+=== TEST 24: customize uri, not found
+--- yaml_config
+plugin_attr:
+    batch-requests:
+        uri: "/foo/bar"
+--- config
+    location = /t {
+        content_by_lua_block {
+            local core = require("apisix.core")
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/batch-requests',
+                ngx.HTTP_POST,
+                [=[{
+                    "timeout": 100,
+                    "pipeline":[
+                    {
+                        "path": "/a"
+                    }]
+                }]=],
+                [=[[
+                {
+                    "status": 200
+                }
+                ]]=]
+                )
+
+            ngx.status = code
+            ngx.say(body)
+        }
+    }
+
+    location = /a {
+        content_by_lua_block {
+            ngx.status = 200
+        }
+    }
+--- request
+GET /t
+--- error_code: 404
+--- no_error_log
+[error]
+
+
+
+=== TEST 25: customize uri, found

Review comment:
       The `t/plugin/batch-requests.t` is long enough. Let's add test in a new file `t/plugin/batch-requests2.t`.
   




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] arthur-zhang commented on a change in pull request #4563: feat(batch-requests): allow customizing uri in batch-requests

Posted by GitBox <gi...@apache.org>.
arthur-zhang commented on a change in pull request #4563:
URL: https://github.com/apache/apisix/pull/4563#discussion_r666569716



##########
File path: docs/en/latest/plugins/batch-requests.md
##########
@@ -109,6 +109,22 @@ Response is `Array` of [HttpResponse](#httpresponse).
 | body    | string  | http response body    |
 | headers | object  | http response headers |
 
+## How to specify custom uri
+
+We can change the default uri in the `plugin_attr` section of `conf/config.yaml`.
+
+| Name       | Type   | Default                      | Description                       |

Review comment:
       good suggestion




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tokers commented on a change in pull request #4563: feat(batch-requests): allow customizing uri in batch-requests

Posted by GitBox <gi...@apache.org>.
tokers commented on a change in pull request #4563:
URL: https://github.com/apache/apisix/pull/4563#discussion_r667286122



##########
File path: docs/zh/latest/plugins/batch-requests.md
##########
@@ -114,6 +114,22 @@ curl http://127.0.0.1:9080/apisix/admin/plugin_metadata/batch-requests -H 'X-API
 | body    | string  | Http 请求的响应体   |
 | headers | object  | Http 请求的响应头   |
 
+## 如何修改自定义 uri
+
+我们可以在 `conf/config.yaml` 的 `plugin_attr` 修改默认的 `uri`

Review comment:
       ```suggestion
   我们可以在 `conf/config.yaml` 的 `plugin_attr` 配置项中修改默认的 `uri`
   ```




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander commented on a change in pull request #4563: feat(batch-requests): allow customizing uri in batch-requests

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #4563:
URL: https://github.com/apache/apisix/pull/4563#discussion_r667286593



##########
File path: t/plugin/batch-requests.t
##########
@@ -1017,3 +1017,204 @@ GET /t
 passed
 --- no_error_log
 [error]
+
+
+
+=== TEST 24: customize uri, not found
+--- yaml_config
+plugin_attr:
+    batch-requests:
+        uri: "/foo/bar"
+--- config
+    location = /t {
+        content_by_lua_block {
+            local core = require("apisix.core")
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/batch-requests',
+                ngx.HTTP_POST,
+                [=[{
+                    "timeout": 100,
+                    "pipeline":[
+                    {
+                        "path": "/a"
+                    }]
+                }]=],
+                [=[[
+                {
+                    "status": 200
+                }
+                ]]=]
+                )
+
+            ngx.status = code
+            ngx.say(body)
+        }
+    }
+
+    location = /a {
+        content_by_lua_block {
+            ngx.status = 200
+        }
+    }
+--- request
+GET /t
+--- error_code: 404
+--- no_error_log
+[error]
+
+
+
+=== TEST 25: customize uri, found
+--- yaml_config
+plugin_attr:
+    batch-requests:
+        uri: "/foo/bar"
+--- config
+    location = /aggregate {
+        content_by_lua_block {
+            local core = require("apisix.core")
+            local t = require("lib.test_admin").test
+            local code, body = t('/foo/bar',
+                ngx.HTTP_POST,
+                [=[{
+                    "timeout": 100,
+                    "pipeline":[
+                    {
+                        "path": "/b",
+                        "headers": {
+                            "Header1": "hello",
+                            "Header2": "world"
+                        }
+                    },{
+                        "path": "/c",
+                        "method": "PUT"
+                    },{
+                        "path": "/d"
+                    }]
+                }]=],
+                [=[[
+                {
+                    "status": 200
+                },
+                {
+                    "status": 201
+                },
+                {
+                    "status": 202
+                }
+                ]]=]
+                )
+
+            ngx.status = code
+            ngx.say(body)
+        }
+    }
+
+    location = /b {
+        content_by_lua_block {
+            ngx.status = 200
+        }
+    }
+    location = /c {
+        content_by_lua_block {
+            ngx.status = 201
+        }
+    }
+    location = /d {
+        content_by_lua_block {
+            ngx.status = 202
+        }
+    }
+--- request
+GET /aggregate
+--- error_code: 200
+--- no_error_log

Review comment:
       We can avoid repeating it via https://github.com/apache/apisix/blob/42ab6149272920bbab66985b90e2754a7c6cb747/t/admin/upstream2.t#L32




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] arthur-zhang commented on pull request #4563: feat(batch-requests): allow customizing uri in batch-requests

Posted by GitBox <gi...@apache.org>.
arthur-zhang commented on pull request #4563:
URL: https://github.com/apache/apisix/pull/4563#issuecomment-876375474


   > @arthur-zhang Need to check out the CI problems.
   
   I am working on it.


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander merged pull request #4563: feat(batch-requests): allow customizing uri in batch-requests

Posted by GitBox <gi...@apache.org>.
spacewander merged pull request #4563:
URL: https://github.com/apache/apisix/pull/4563


   


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org