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



##########
File path: t/admin/plugin-configs.t
##########
@@ -430,3 +430,139 @@ 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)
+        }
+    }
+--- request

Review comment:
       We can remove the duplicate sections which are set in the beginning.

##########
File path: t/admin/plugin-configs.t
##########
@@ -430,3 +430,139 @@ 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)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log

Review comment:
       Ditto

##########
File path: apisix/admin/plugin_config.lua
##########
@@ -100,13 +102,33 @@ end
 
 
 function _M.delete(id)
+    if not id then
+        return 400, {error_msg = "missing plugin config id"}
+    end
+
+    local routes, routes_ver = get_routes()
+    core.log.info("routes: ", core.json.delay_encode(routes, true))

Review comment:
       As the size of Nginx log is limited, we can't log all the routes. Let's 
remove 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to