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/01/06 03:11:59 UTC
[GitHub] [apisix-dashboard] imjoey opened a new pull request #1218: feat: add create_time/update_time for global_rule
imjoey opened a new pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218
Signed-off-by: imjoey <ma...@gmail.com>
Please answer these questions before submitting a pull request
- Why submit this pull request?
- [ ] Bugfix
- [x] New feature provided
- [ ] Improve performance
- Related issues
Related to #1143 , taking charge of the manager-api part.
___
### New feature or improvement
- Describe the details and related test reports.
As #1143 comes to a conclusion that `create_time` and `update_time` are needed for global_rule entity. This PR is going to add the two fields and relevant test cases.
**Note:**
Cause manager-api will validate the schema defined in `schema.json` right before writing to etcd, current test cases will always fail due to the `additionalProperties` for `GlobalRule` is `false`. This PR can only be marked as ready-to-view util the schema is updated from apache/apisix project.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey commented on a change in pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey commented on a change in pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#discussion_r553756618
##########
File path: api/test/e2e/global_rule_test.go
##########
@@ -282,3 +288,108 @@ func TestGlobalRule(t *testing.T) {
testCaseCheck(tc, t)
}
}
+
+func TestGlobalRule_with_createtime_updatetime(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ Desc: "create global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.0"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
Review comment:
@starsz much appreciated to your kindness. PR renewed and I followed the style of existing code. I would prefer not to discuss the style stuff here. 😄
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey commented on a change in pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey commented on a change in pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#discussion_r553756841
##########
File path: api/test/e2e/global_rule_test.go
##########
@@ -282,3 +288,108 @@ func TestGlobalRule(t *testing.T) {
testCaseCheck(tc, t)
}
}
+
+func TestGlobalRule_with_createtime_updatetime(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ Desc: "create global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.0"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ }
+
+ for _, tc := range tests {
+ testCaseCheck(tc, t)
+ }
+
+ basepath := "http://127.0.0.1:9000/apisix/admin/global_rules/1"
+ time.Sleep(time.Duration(1) * time.Second)
+
+ // get the global_rule, save createtime and updatetime
+ request, _ := http.NewRequest("GET", basepath, nil)
+ request.Header.Add("Authorization", token)
+ resp, err := http.DefaultClient.Do(request)
+ if err != nil {
+ fmt.Printf("server not responding %s", err.Error())
Review comment:
@starsz Done, PR renewed and 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey commented on a change in pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey commented on a change in pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#discussion_r553716682
##########
File path: api/test/e2e/global_rule_test.go
##########
@@ -282,3 +288,108 @@ func TestGlobalRule(t *testing.T) {
testCaseCheck(tc, t)
}
}
+
+func TestGlobalRule_with_createtime_updatetime(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ Desc: "create global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.0"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ }
+
+ for _, tc := range tests {
+ testCaseCheck(tc, t)
+ }
+
+ basepath := "http://127.0.0.1:9000/apisix/admin/global_rules/1"
+ time.Sleep(time.Duration(1) * time.Second)
+
+ // get the global_rule, save createtime and updatetime
+ request, _ := http.NewRequest("GET", basepath, nil)
+ request.Header.Add("Authorization", token)
+ resp, err := http.DefaultClient.Do(request)
+ if err != nil {
+ fmt.Printf("server not responding %s", err.Error())
+ }
+ defer resp.Body.Close()
+ respBody, _ := ioutil.ReadAll(resp.Body)
+ createtime := gjson.Get(string(respBody), "data.create_time")
+ updatetime := gjson.Get(string(respBody), "data.update_time")
+
+ // wait 1 second so the update_time should be different
+ time.Sleep(time.Duration(1) * time.Second)
+
+ tests = []HttpTestCase{
+ {
+ Desc: "update the global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.1"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
Review comment:
@starsz yep, that's right. Will renew it soon. 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#issuecomment-755999242
# [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=h1) Report
> Merging [#1218](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=desc) (3417f18) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/40d8f97de8770187599ff5963617049603020e92?el=desc) (40d8f97) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #1218 +/- ##
=======================================
Coverage 42.44% 42.44%
=======================================
Files 31 31
Lines 1932 1932
=======================================
Hits 820 820
Misses 1001 1001
Partials 111 111
```
| [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [api/internal/core/entity/entity.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1218/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvZW50aXR5L2VudGl0eS5nbw==) | `0.00% <ø> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=footer). Last update [40d8f97...3417f18](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey removed a comment on pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey removed a comment on pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#issuecomment-756013148
@juzhiyuan @nic-chen this is ready for review. Thanks. FE CI seems broken. Hope he can pull through. 😄
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] starsz commented on a change in pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
starsz commented on a change in pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#discussion_r553746543
##########
File path: api/test/e2e/global_rule_test.go
##########
@@ -282,3 +288,108 @@ func TestGlobalRule(t *testing.T) {
testCaseCheck(tc, t)
}
}
+
+func TestGlobalRule_with_createtime_updatetime(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ Desc: "create global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.0"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
Review comment:
Paste it into code is OK. Just make sure that we should use a table rather than space.
Thanks a lot.
See other Code:
https://github.com/apache/apisix-dashboard/blob/40d8f97de8770187599ff5963617049603020e92/api/test/e2e/label_test.go#L56-L69
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] starsz commented on a change in pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
starsz commented on a change in pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#discussion_r553749300
##########
File path: api/test/e2e/global_rule_test.go
##########
@@ -282,3 +288,108 @@ func TestGlobalRule(t *testing.T) {
testCaseCheck(tc, t)
}
}
+
+func TestGlobalRule_with_createtime_updatetime(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ Desc: "create global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.0"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
Review comment:
Sorry, I change my mind. Both are OK, just keep the brackets align.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#issuecomment-755999242
# [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=h1) Report
> Merging [#1218](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=desc) (fbe8f16) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/40d8f97de8770187599ff5963617049603020e92?el=desc) (40d8f97) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #1218 +/- ##
=======================================
Coverage 42.44% 42.44%
=======================================
Files 31 31
Lines 1932 1932
=======================================
Hits 820 820
Misses 1001 1001
Partials 111 111
```
| [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [api/internal/core/entity/entity.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1218/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvZW50aXR5L2VudGl0eS5nbw==) | `0.00% <ø> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=footer). Last update [40d8f97...fbe8f16](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey commented on pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey commented on pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#issuecomment-756506344
@liuxiran thanks for your commit. While IMHO, current format of `schema.json` is not a usual pattern. I refer to other json files with in repository, indentation with two spaces is more common. Of course, we can use your advice in this PR. We can commit another PR just to reformat `schema.json` if we all can reach a consensus.
ping @juzhiyuan @nic-chen for opinions. 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey commented on a change in pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey commented on a change in pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#discussion_r553756712
##########
File path: api/test/e2e/global_rule_test.go
##########
@@ -282,3 +288,108 @@ func TestGlobalRule(t *testing.T) {
testCaseCheck(tc, t)
}
}
+
+func TestGlobalRule_with_createtime_updatetime(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ Desc: "create global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.0"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ }
+
+ for _, tc := range tests {
+ testCaseCheck(tc, t)
+ }
+
+ basepath := "http://127.0.0.1:9000/apisix/admin/global_rules/1"
+ time.Sleep(time.Duration(1) * time.Second)
+
+ // get the global_rule, save createtime and updatetime
+ request, _ := http.NewRequest("GET", basepath, nil)
+ request.Header.Add("Authorization", token)
+ resp, err := http.DefaultClient.Do(request)
+ if err != nil {
+ fmt.Printf("server not responding %s", err.Error())
+ }
+ defer resp.Body.Close()
+ respBody, _ := ioutil.ReadAll(resp.Body)
+ createtime := gjson.Get(string(respBody), "data.create_time")
+ updatetime := gjson.Get(string(respBody), "data.update_time")
+
+ // wait 1 second so the update_time should be different
+ time.Sleep(time.Duration(1) * time.Second)
+
+ tests = []HttpTestCase{
+ {
+ Desc: "update the global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.1"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ }
+
+ for _, tc := range tests {
+ testCaseCheck(tc, t)
+ }
+
+ // get the global rule
+ time.Sleep(time.Duration(1) * time.Second)
+ request, _ = http.NewRequest("GET", basepath, nil)
+ request.Header.Add("Authorization", token)
+ resp, _ = http.DefaultClient.Do(request)
Review comment:
@starsz Done, PR renewed and 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] starsz commented on pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
starsz commented on pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#issuecomment-756606752
@imjoey Thank you very much.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#issuecomment-755999242
# [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=h1) Report
> Merging [#1218](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=desc) (bad6f08) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/40d8f97de8770187599ff5963617049603020e92?el=desc) (40d8f97) will **decrease** coverage by `0.05%`.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #1218 +/- ##
==========================================
- Coverage 42.44% 42.39% -0.06%
==========================================
Files 31 31
Lines 1932 1932
==========================================
- Hits 820 819 -1
- Misses 1001 1002 +1
Partials 111 111
```
| [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [api/internal/core/entity/entity.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1218/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvZW50aXR5L2VudGl0eS5nbw==) | `0.00% <ø> (ø)` | |
| [api/internal/core/store/store.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1218/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvc3RvcmUvc3RvcmUuZ28=) | `79.37% <0.00%> (-0.63%)` | :arrow_down: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=footer). Last update [40d8f97...bad6f08](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] nic-chen commented on a change in pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
nic-chen commented on a change in pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#discussion_r554915637
##########
File path: api/test/e2e/global_rule_test.go
##########
@@ -282,3 +287,109 @@ func TestGlobalRule(t *testing.T) {
testCaseCheck(tc, t)
}
}
+
+func TestGlobalRule_with_createtime_updatetime(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ Desc: "create global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.0"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ }
+
+ for _, tc := range tests {
+ testCaseCheck(tc, t)
+ }
+
+ basepath := "http://127.0.0.1:9000/apisix/admin/global_rules/1"
+ time.Sleep(time.Duration(1) * time.Second)
+
+ // get the global_rule, save createtime and updatetime
+ request, _ := http.NewRequest("GET", basepath, nil)
+ request.Header.Add("Authorization", token)
+ resp, err := http.DefaultClient.Do(request)
+ assert.Nil(t, err)
+ defer resp.Body.Close()
+
+ respBody, _ := ioutil.ReadAll(resp.Body)
+ createtime := gjson.Get(string(respBody), "data.create_time")
+ updatetime := gjson.Get(string(respBody), "data.update_time")
Review comment:
It would be better if you can compare the current timestamp, refer:
https://github.com/apache/apisix-dashboard/blob/master/api/test/e2e/route_with_management_fileds_test.go#L88-L91
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey commented on a change in pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey commented on a change in pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#discussion_r553716644
##########
File path: api/test/e2e/global_rule_test.go
##########
@@ -282,3 +288,108 @@ func TestGlobalRule(t *testing.T) {
testCaseCheck(tc, t)
}
}
+
+func TestGlobalRule_with_createtime_updatetime(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ Desc: "create global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.0"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ }
+
+ for _, tc := range tests {
+ testCaseCheck(tc, t)
+ }
+
+ basepath := "http://127.0.0.1:9000/apisix/admin/global_rules/1"
+ time.Sleep(time.Duration(1) * time.Second)
+
+ // get the global_rule, save createtime and updatetime
+ request, _ := http.NewRequest("GET", basepath, nil)
+ request.Header.Add("Authorization", token)
+ resp, err := http.DefaultClient.Do(request)
+ if err != nil {
+ fmt.Printf("server not responding %s", err.Error())
Review comment:
@starsz Good catch. Will renew it soon. 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey edited a comment on pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey edited a comment on pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#issuecomment-756506344
@liuxiran thanks for your commit. While IMHO, current format of `schema.json`, indentation with 1 tab of 8 spaces, is not a usual pattern. I refer to other json files with in repository, indentation with 2 spaces is more common. Of course, we can use your advice in this PR. We can commit another PR just to reformat `schema.json` if we all can reach a consensus.
ping @juzhiyuan @nic-chen for opinions. 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey commented on a change in pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey commented on a change in pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#discussion_r555043403
##########
File path: api/conf/schema.json
##########
@@ -54,6 +54,9 @@
"global_rule": {
"additionalProperties": false,
"properties": {
+ "create_time": {
Review comment:
> do we sync this schema.json from APISIX project?
@membphis yep, synced from APISIX project, but only the two added properties were kept in this PR, so as not to introduce unexpected 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] codecov-io commented on pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#issuecomment-755999242
# [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=h1) Report
> Merging [#1218](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=desc) (8174215) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/190949ca9c8e36ea4fc9e59112b70138977f2589?el=desc) (190949c) will **decrease** coverage by `0.05%`.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #1218 +/- ##
==========================================
- Coverage 42.44% 42.39% -0.06%
==========================================
Files 31 31
Lines 1932 1932
==========================================
- Hits 820 819 -1
- Misses 1001 1002 +1
Partials 111 111
```
| [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [api/internal/core/entity/entity.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1218/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvZW50aXR5L2VudGl0eS5nbw==) | `0.00% <ø> (ø)` | |
| [api/internal/core/store/store.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1218/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvc3RvcmUvc3RvcmUuZ28=) | `79.37% <0.00%> (-0.63%)` | :arrow_down: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=footer). Last update [190949c...8174215](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#issuecomment-755999242
# [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=h1) Report
> Merging [#1218](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=desc) (13143f2) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/93b9765e3e77c6cefe0487e1657886d5f05d4146?el=desc) (93b9765) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #1218 +/- ##
=======================================
Coverage 42.44% 42.44%
=======================================
Files 31 31
Lines 1932 1932
=======================================
Hits 820 820
Misses 1001 1001
Partials 111 111
```
| [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [api/internal/core/entity/entity.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1218/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvZW50aXR5L2VudGl0eS5nbw==) | `0.00% <ø> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=footer). Last update [93b9765...13143f2](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey edited a comment on pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey edited a comment on pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#issuecomment-756506344
@liuxiran thanks for your commit. While IMHO, current format of `schema.json`, indentation with 1 tab of 8 spaces, is not a usual pattern. I refer to other json files within this repository, indentation with 2 spaces is more common. Of course, we can use your advice in this PR, and then commit another PR just to reformat `schema.json` if we all can reach a consensus.
ping @juzhiyuan @nic-chen for opinions. 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey edited a comment on pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey edited a comment on pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#issuecomment-756506344
@liuxiran thanks for your commit. While IMHO, current format, indentation with 1 tab of 8 spaces of `schema.json` is not a usual pattern. I refer to other json files with in repository, indentation with 2 spaces is more common. Of course, we can use your advice in this PR. We can commit another PR just to reformat `schema.json` if we all can reach a consensus.
ping @juzhiyuan @nic-chen for opinions. 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey commented on pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey commented on pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#issuecomment-756013148
@juzhiyuan @nic-chen this is ready for review. Thanks. FE CI seems broken. Hope he can pull through. 😄
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey commented on pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey commented on pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#issuecomment-756602521
@juzhiyuan @starsz CI passed and ready for review. 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey edited a comment on pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey edited a comment on pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#issuecomment-756506344
@liuxiran thanks for your commit. While IMHO, current format of `schema.json`, indentation with 1 tab of 8 spaces, is not a usual pattern. I refer to other json files within this repository, indentation with 2 spaces is more common. Of course, we can use your advice in this PR. We can commit another PR just to reformat `schema.json` if we all can reach a consensus.
ping @juzhiyuan @nic-chen for opinions. 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey commented on a change in pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey commented on a change in pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#discussion_r553723810
##########
File path: api/test/e2e/global_rule_test.go
##########
@@ -282,3 +288,108 @@ func TestGlobalRule(t *testing.T) {
testCaseCheck(tc, t)
}
}
+
+func TestGlobalRule_with_createtime_updatetime(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ Desc: "create global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.0"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
Review comment:
@starsz current codes mixed spaces and tabs here. So honestly, the existing style only seems good in GitHub pages, but not in VSCode editor. Please see the screenshot below:
<img width="664" alt="image" src="https://user-images.githubusercontent.com/2542401/103971535-d6caca00-51a5-11eb-9130-7d8491549a89.png">
Shall we use `jq` to format the json and paste it into code? Looking forward to your feedback. 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey commented on a change in pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey commented on a change in pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#discussion_r554939154
##########
File path: api/test/e2e/global_rule_test.go
##########
@@ -282,3 +287,109 @@ func TestGlobalRule(t *testing.T) {
testCaseCheck(tc, t)
}
}
+
+func TestGlobalRule_with_createtime_updatetime(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ Desc: "create global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.0"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ }
+
+ for _, tc := range tests {
+ testCaseCheck(tc, t)
+ }
+
+ basepath := "http://127.0.0.1:9000/apisix/admin/global_rules/1"
+ time.Sleep(time.Duration(1) * time.Second)
+
+ // get the global_rule, save createtime and updatetime
+ request, _ := http.NewRequest("GET", basepath, nil)
+ request.Header.Add("Authorization", token)
+ resp, err := http.DefaultClient.Do(request)
+ assert.Nil(t, err)
+ defer resp.Body.Close()
+
+ respBody, _ := ioutil.ReadAll(resp.Body)
+ createtime := gjson.Get(string(respBody), "data.create_time")
+ updatetime := gjson.Get(string(respBody), "data.update_time")
Review comment:
@nic-chen Done and thanks for your 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] juzhiyuan merged pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
juzhiyuan merged pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey commented on a change in pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey commented on a change in pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#discussion_r553717008
##########
File path: api/test/e2e/global_rule_test.go
##########
@@ -282,3 +288,108 @@ func TestGlobalRule(t *testing.T) {
testCaseCheck(tc, t)
}
}
+
+func TestGlobalRule_with_createtime_updatetime(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ Desc: "create global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.0"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ }
+
+ for _, tc := range tests {
+ testCaseCheck(tc, t)
+ }
+
+ basepath := "http://127.0.0.1:9000/apisix/admin/global_rules/1"
+ time.Sleep(time.Duration(1) * time.Second)
+
+ // get the global_rule, save createtime and updatetime
+ request, _ := http.NewRequest("GET", basepath, nil)
+ request.Header.Add("Authorization", token)
+ resp, err := http.DefaultClient.Do(request)
+ if err != nil {
+ fmt.Printf("server not responding %s", err.Error())
+ }
+ defer resp.Body.Close()
+ respBody, _ := ioutil.ReadAll(resp.Body)
+ createtime := gjson.Get(string(respBody), "data.create_time")
+ updatetime := gjson.Get(string(respBody), "data.update_time")
+
+ // wait 1 second so the update_time should be different
+ time.Sleep(time.Duration(1) * time.Second)
+
+ tests = []HttpTestCase{
+ {
+ Desc: "update the global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.1"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ }
+
+ for _, tc := range tests {
+ testCaseCheck(tc, t)
+ }
+
+ // get the global rule
+ time.Sleep(time.Duration(1) * time.Second)
+ request, _ = http.NewRequest("GET", basepath, nil)
+ request.Header.Add("Authorization", token)
+ resp, _ = http.DefaultClient.Do(request)
Review comment:
@starsz OK, will check and keep the alignment. Thank you for reviewing.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey commented on a change in pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey commented on a change in pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#discussion_r553756800
##########
File path: api/test/e2e/global_rule_test.go
##########
@@ -282,3 +288,108 @@ func TestGlobalRule(t *testing.T) {
testCaseCheck(tc, t)
}
}
+
+func TestGlobalRule_with_createtime_updatetime(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ Desc: "create global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.0"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ }
+
+ for _, tc := range tests {
+ testCaseCheck(tc, t)
+ }
+
+ basepath := "http://127.0.0.1:9000/apisix/admin/global_rules/1"
+ time.Sleep(time.Duration(1) * time.Second)
+
+ // get the global_rule, save createtime and updatetime
+ request, _ := http.NewRequest("GET", basepath, nil)
+ request.Header.Add("Authorization", token)
+ resp, err := http.DefaultClient.Do(request)
+ if err != nil {
+ fmt.Printf("server not responding %s", err.Error())
+ }
+ defer resp.Body.Close()
+ respBody, _ := ioutil.ReadAll(resp.Body)
+ createtime := gjson.Get(string(respBody), "data.create_time")
+ updatetime := gjson.Get(string(respBody), "data.update_time")
+
+ // wait 1 second so the update_time should be different
+ time.Sleep(time.Duration(1) * time.Second)
+
+ tests = []HttpTestCase{
+ {
+ Desc: "update the global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.1"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
Review comment:
@starsz Done, PR renewed and 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#issuecomment-755999242
# [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=h1) Report
> Merging [#1218](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=desc) (13143f2) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/93b9765e3e77c6cefe0487e1657886d5f05d4146?el=desc) (93b9765) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #1218 +/- ##
=======================================
Coverage 42.44% 42.44%
=======================================
Files 31 31
Lines 1932 1932
=======================================
Hits 820 820
Misses 1001 1001
Partials 111 111
```
| [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [api/internal/core/entity/entity.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1218/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvZW50aXR5L2VudGl0eS5nbw==) | `0.00% <ø> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=footer). Last update [93b9765...13143f2](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] juzhiyuan commented on a change in pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on a change in pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#discussion_r555016753
##########
File path: api/conf/schema.json
##########
@@ -54,6 +54,9 @@
"global_rule": {
"additionalProperties": false,
"properties": {
+ "create_time": {
Review comment:
ping @imjoey
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey commented on pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey commented on pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#issuecomment-756494988
@juzhiyuan @nic-chen CI passes eventually. 😄 PR ready for review. 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] starsz commented on a change in pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
starsz commented on a change in pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#discussion_r553716134
##########
File path: api/test/e2e/global_rule_test.go
##########
@@ -282,3 +288,108 @@ func TestGlobalRule(t *testing.T) {
testCaseCheck(tc, t)
}
}
+
+func TestGlobalRule_with_createtime_updatetime(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ Desc: "create global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.0"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ }
+
+ for _, tc := range tests {
+ testCaseCheck(tc, t)
+ }
+
+ basepath := "http://127.0.0.1:9000/apisix/admin/global_rules/1"
+ time.Sleep(time.Duration(1) * time.Second)
+
+ // get the global_rule, save createtime and updatetime
+ request, _ := http.NewRequest("GET", basepath, nil)
+ request.Header.Add("Authorization", token)
+ resp, err := http.DefaultClient.Do(request)
+ if err != nil {
+ fmt.Printf("server not responding %s", err.Error())
Review comment:
It looks not good. Maybe assert.Nil(t, err)?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#issuecomment-755999242
# [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=h1) Report
> Merging [#1218](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=desc) (927954a) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/e5e59e2d38f7a799c296ffbdd6cb3ae221acd29b?el=desc) (e5e59e2) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #1218 +/- ##
=======================================
Coverage 42.44% 42.44%
=======================================
Files 31 31
Lines 1932 1932
=======================================
Hits 820 820
Misses 1001 1001
Partials 111 111
```
| [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [api/internal/core/entity/entity.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1218/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvZW50aXR5L2VudGl0eS5nbw==) | `0.00% <ø> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=footer). Last update [e5e59e2...927954a](https://codecov.io/gh/apache/apisix-dashboard/pull/1218?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey commented on a change in pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey commented on a change in pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#discussion_r553717220
##########
File path: api/test/e2e/global_rule_test.go
##########
@@ -282,3 +288,108 @@ func TestGlobalRule(t *testing.T) {
testCaseCheck(tc, t)
}
}
+
+func TestGlobalRule_with_createtime_updatetime(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ Desc: "create global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.0"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
Review comment:
@starsz ok, I will revert the styles here, as well as keep the same afterwards. 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] membphis commented on a change in pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#discussion_r554991812
##########
File path: api/conf/schema.json
##########
@@ -54,6 +54,9 @@
"global_rule": {
"additionalProperties": false,
"properties": {
+ "create_time": {
Review comment:
do we sync this schema.json from APISIX project?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] imjoey commented on a change in pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
imjoey commented on a change in pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#discussion_r553723810
##########
File path: api/test/e2e/global_rule_test.go
##########
@@ -282,3 +288,108 @@ func TestGlobalRule(t *testing.T) {
testCaseCheck(tc, t)
}
}
+
+func TestGlobalRule_with_createtime_updatetime(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ Desc: "create global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.0"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
Review comment:
@starsz current codes https://github.com/apache/apisix-dashboard/blob/40d8f97de8770187599ff5963617049603020e92/api/test/e2e/global_rule_test.go#L58-L69 mixed spaces and tabs here. So honestly, the existing style only seems good in GitHub pages, but not in VSCode editor. Please see the screenshot below:
<img width="664" alt="image" src="https://user-images.githubusercontent.com/2542401/103971535-d6caca00-51a5-11eb-9130-7d8491549a89.png">
Shall we use `jq` to format the json and paste it into code? Looking forward to your feedback. 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] starsz commented on a change in pull request #1218: feat: add create_time/update_time for global_rule
Posted by GitBox <gi...@apache.org>.
starsz commented on a change in pull request #1218:
URL: https://github.com/apache/apisix-dashboard/pull/1218#discussion_r553711830
##########
File path: api/test/e2e/global_rule_test.go
##########
@@ -282,3 +288,108 @@ func TestGlobalRule(t *testing.T) {
testCaseCheck(tc, t)
}
}
+
+func TestGlobalRule_with_createtime_updatetime(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ Desc: "create global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.0"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
Review comment:
Style: the format looks not very good.
##########
File path: api/test/e2e/global_rule_test.go
##########
@@ -282,3 +288,108 @@ func TestGlobalRule(t *testing.T) {
testCaseCheck(tc, t)
}
}
+
+func TestGlobalRule_with_createtime_updatetime(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ Desc: "create global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.0"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ }
+
+ for _, tc := range tests {
+ testCaseCheck(tc, t)
+ }
+
+ basepath := "http://127.0.0.1:9000/apisix/admin/global_rules/1"
+ time.Sleep(time.Duration(1) * time.Second)
+
+ // get the global_rule, save createtime and updatetime
+ request, _ := http.NewRequest("GET", basepath, nil)
+ request.Header.Add("Authorization", token)
+ resp, err := http.DefaultClient.Do(request)
+ if err != nil {
+ fmt.Printf("server not responding %s", err.Error())
+ }
+ defer resp.Body.Close()
+ respBody, _ := ioutil.ReadAll(resp.Body)
+ createtime := gjson.Get(string(respBody), "data.create_time")
+ updatetime := gjson.Get(string(respBody), "data.update_time")
+
+ // wait 1 second so the update_time should be different
+ time.Sleep(time.Duration(1) * time.Second)
+
+ tests = []HttpTestCase{
+ {
+ Desc: "update the global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.1"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ }
+
+ for _, tc := range tests {
+ testCaseCheck(tc, t)
+ }
+
+ // get the global rule
+ time.Sleep(time.Duration(1) * time.Second)
+ request, _ = http.NewRequest("GET", basepath, nil)
+ request.Header.Add("Authorization", token)
+ resp, _ = http.DefaultClient.Do(request)
Review comment:
Why not keep the same as before? Check the err and close the resp.Body
##########
File path: api/test/e2e/global_rule_test.go
##########
@@ -282,3 +288,108 @@ func TestGlobalRule(t *testing.T) {
testCaseCheck(tc, t)
}
}
+
+func TestGlobalRule_with_createtime_updatetime(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ Desc: "create global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.0"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ }
+
+ for _, tc := range tests {
+ testCaseCheck(tc, t)
+ }
+
+ basepath := "http://127.0.0.1:9000/apisix/admin/global_rules/1"
+ time.Sleep(time.Duration(1) * time.Second)
+
+ // get the global_rule, save createtime and updatetime
+ request, _ := http.NewRequest("GET", basepath, nil)
+ request.Header.Add("Authorization", token)
+ resp, err := http.DefaultClient.Do(request)
+ if err != nil {
+ fmt.Printf("server not responding %s", err.Error())
+ }
+ defer resp.Body.Close()
+ respBody, _ := ioutil.ReadAll(resp.Body)
+ createtime := gjson.Get(string(respBody), "data.create_time")
+ updatetime := gjson.Get(string(respBody), "data.update_time")
+
+ // wait 1 second so the update_time should be different
+ time.Sleep(time.Duration(1) * time.Second)
+
+ tests = []HttpTestCase{
+ {
+ Desc: "update the global rule",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/global_rules/1",
+ Method: http.MethodPut,
+ Body: `{
+ "plugins": {
+ "response-rewrite": {
+ "headers": {
+ "X-VERSION":"1.1"
+ }
+ },
+ "uri-blocker": {
+ "block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+ }
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
Review comment:
The sleepTime stands for sleep before request. You can check it in base.go.
I think there is no need to sleep for you had sleep 1s before.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org