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 2022/01/17 04:54:54 UTC

[GitHub] [apisix] bisakhmondal commented on a change in pull request #6092: feat(plugin config): add dependency for delete plugin config

bisakhmondal commented on a change in pull request #6092:
URL: https://github.com/apache/apisix/pull/6092#discussion_r785635111



##########
File path: t/admin/plugin-configs.t
##########
@@ -430,3 +430,124 @@ passed
 --- response_body
 {"error_msg":"invalid configuration: property \"labels\" validation failed: wrong type: expected object, got string"}
 --- error_code: 400
+
+
+
+=== TEST 10: set plugin-configs(id: 1)
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local etcd = require("apisix.core.etcd")
+            local code, body = t('/apisix/admin/plugin_configs/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "plugins": {
+                        "limit-count": {
+                            "count": 2,
+                            "time_window": 60,
+                            "rejected_code": 503,
+                            "key": "remote_addr"
+                        }
+                    }
+                }]]
+                )
+
+            ngx.status = code
+            ngx.say(body)
+
+            local res = assert(etcd.get('/plugin_configs/1'))
+            local create_time = res.body.node.value.create_time
+            assert(create_time ~= nil, "create_time is nil")
+            local update_time = res.body.node.value.update_time
+            assert(update_time ~= nil, "update_time is nil")
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 11: set route(id: 1)
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                 ngx.HTTP_PUT,
+                 [[{
+                    "plugin_config_id": 1,
+                    "uri": "/index.html",
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:8080": 1
+                        },
+                        "type": "roundrobin"
+                    }
+                }]]
+                )
+
+            ngx.status = code
+            ngx.say(body)
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 12: delete-plugin configs failed(id: 1)
+--- config
+    location /t {
+        content_by_lua_block {
+            ngx.sleep(0.3)
+            local t = require("lib.test_admin").test
+            local code, message = t('/apisix/admin/plugin_configs/1',
+                 ngx.HTTP_DELETE,
+                 nil,
+                 [[{"action": "delete"}]]
+                )
+            ngx.print("[delete] code: ", code, " message: ", message)
+        }
+    }
+--- response_body
+{"error_msg":"can not delete this plugin config, route [1] is still using it now"}
+--- error_code: 400
+
+
+
+=== TEST 13: delete route(id: 1)
+--- config
+    location /t {
+        content_by_lua_block {
+            ngx.sleep(0.3)
+            local t = require("lib.test_admin").test
+            local code, message = t('/apisix/admin/routes/1',
+                 ngx.HTTP_DELETE,
+                 nil,
+                 [[{"action": "delete"}]]
+                )
+            ngx.say("[delete] code: ", code, " message: ", message)
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 14: delete plugin-configs(id: 1)
+--- config
+    location /t {
+        content_by_lua_block {
+            ngx.sleep(0.3)

Review comment:
       ditto

##########
File path: t/admin/plugin-configs.t
##########
@@ -430,3 +430,124 @@ passed
 --- response_body
 {"error_msg":"invalid configuration: property \"labels\" validation failed: wrong type: expected object, got string"}
 --- error_code: 400
+
+
+
+=== TEST 10: set plugin-configs(id: 1)
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local etcd = require("apisix.core.etcd")
+            local code, body = t('/apisix/admin/plugin_configs/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "plugins": {
+                        "limit-count": {
+                            "count": 2,
+                            "time_window": 60,
+                            "rejected_code": 503,
+                            "key": "remote_addr"
+                        }
+                    }
+                }]]
+                )
+
+            ngx.status = code
+            ngx.say(body)
+
+            local res = assert(etcd.get('/plugin_configs/1'))
+            local create_time = res.body.node.value.create_time
+            assert(create_time ~= nil, "create_time is nil")
+            local update_time = res.body.node.value.update_time
+            assert(update_time ~= nil, "update_time is nil")
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 11: set route(id: 1)
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                 ngx.HTTP_PUT,
+                 [[{
+                    "plugin_config_id": 1,
+                    "uri": "/index.html",
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:8080": 1
+                        },
+                        "type": "roundrobin"
+                    }
+                }]]
+                )
+
+            ngx.status = code
+            ngx.say(body)
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 12: delete-plugin configs failed(id: 1)
+--- config
+    location /t {
+        content_by_lua_block {
+            ngx.sleep(0.3)
+            local t = require("lib.test_admin").test
+            local code, message = t('/apisix/admin/plugin_configs/1',
+                 ngx.HTTP_DELETE,
+                 nil,
+                 [[{"action": "delete"}]]
+                )
+            ngx.print("[delete] code: ", code, " message: ", message)
+        }
+    }
+--- response_body
+{"error_msg":"can not delete this plugin config, route [1] is still using it now"}
+--- error_code: 400
+
+
+
+=== TEST 13: delete route(id: 1)
+--- config
+    location /t {
+        content_by_lua_block {
+            ngx.sleep(0.3)

Review comment:
       ditto

##########
File path: t/admin/plugin-configs.t
##########
@@ -430,3 +430,124 @@ passed
 --- response_body
 {"error_msg":"invalid configuration: property \"labels\" validation failed: wrong type: expected object, got string"}
 --- error_code: 400
+
+
+
+=== TEST 10: set plugin-configs(id: 1)
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local etcd = require("apisix.core.etcd")
+            local code, body = t('/apisix/admin/plugin_configs/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "plugins": {
+                        "limit-count": {
+                            "count": 2,
+                            "time_window": 60,
+                            "rejected_code": 503,
+                            "key": "remote_addr"
+                        }
+                    }
+                }]]
+                )
+
+            ngx.status = code
+            ngx.say(body)
+
+            local res = assert(etcd.get('/plugin_configs/1'))
+            local create_time = res.body.node.value.create_time
+            assert(create_time ~= nil, "create_time is nil")
+            local update_time = res.body.node.value.update_time
+            assert(update_time ~= nil, "update_time is nil")
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 11: set route(id: 1)
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                 ngx.HTTP_PUT,
+                 [[{
+                    "plugin_config_id": 1,
+                    "uri": "/index.html",
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:8080": 1
+                        },
+                        "type": "roundrobin"
+                    }
+                }]]
+                )
+
+            ngx.status = code
+            ngx.say(body)
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 12: delete-plugin configs failed(id: 1)
+--- config
+    location /t {
+        content_by_lua_block {
+            ngx.sleep(0.3)

Review comment:
       Hi, is there any reason for which we need to add this 0.3-sec sleep?
   Thanks.




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