-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(plugin config): add dependency for delete plugin config #6092
Merged
spacewander
merged 8 commits into
apache:master
from
zaunist:feat/delete_plugin_dependency
Jan 18, 2022
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
65b7d29
feat(plugin config): add dependency for delete plugin config
zaunist 0b2a23e
test: add test case and fix ci failed
zaunist 311efe2
fix: move delete_*.t to plugin_configs.t
zaunist 781080c
fix: remove core.log.info
zaunist 6eada5d
fix: ci failed
zaunist 3ef015e
Merge remote-tracking branch 'remotes/upstream/master' into feat/dele…
zaunist f333b2e
fix: ci failed
zaunist 2dc9ba6
chore: code style
zaunist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
} | ||
}]] | ||
) | ||
if code >= 300 then | ||
ngx.status = code | ||
end | ||
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, body = t('/apisix/admin/plugin_configs/1', | ||
ngx.HTTP_DELETE, | ||
nil, | ||
[[{"action": "delete"}]] | ||
) | ||
ngx.print(body) | ||
} | ||
} | ||
--- response_body | ||
{"error_msg":"can not delete this plugin config, route [1] is still using it now"} | ||
|
||
|
||
|
||
=== TEST 13: delete route(id: 1) | ||
--- config | ||
location /t { | ||
content_by_lua_block { | ||
ngx.sleep(0.3) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
local t = require("lib.test_admin").test | ||
local code, body = t('/apisix/admin/routes/1', | ||
ngx.HTTP_DELETE, | ||
nil, | ||
[[{"action": "delete"}]] | ||
) | ||
ngx.say(body) | ||
} | ||
} | ||
--- response_body | ||
passed | ||
|
||
|
||
|
||
=== TEST 14: delete plugin-configs(id: 1) | ||
--- config | ||
location /t { | ||
content_by_lua_block { | ||
ngx.sleep(0.3) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
local t = require("lib.test_admin").test | ||
local code, body = t('/apisix/admin/plugin_configs/1', | ||
ngx.HTTP_DELETE, | ||
nil, | ||
[[{"action": "delete"}]] | ||
) | ||
ngx.say(body) | ||
} | ||
} | ||
--- response_body | ||
passed |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, is there any reason for which we need to add this 0.3-sec sleep?
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current step depends on the previous steps, so set a short time for etcd to sync data.