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/04/02 09:46:42 UTC

[GitHub] [apisix-dashboard] bisakhmondal opened a new pull request #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

bisakhmondal opened a new pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704


   Please answer these questions before submitting a pull request, **or your PR will get closed**.
   
   **Why submit this pull request?**
   
   - [ ] Bugfix
   - [x] New feature provided
   - [ ] Improve performance
   - [ ] Backport patches
   
   **Related issues**
   
   #1500 
   
   **Checklist:**
   
   - [ ] Did you explain what problem does this PR solve? Or what new features have been added?
   - [x] Have you added corresponding test cases?
   - [ ] Have you modified the corresponding document?
   - [x] Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list 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.

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



[GitHub] [apisix-dashboard] codecov-io commented on pull request #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#issuecomment-813596875


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1704?src=pr&el=h1) Report
   > Merging [#1704](https://codecov.io/gh/apache/apisix-dashboard/pull/1704?src=pr&el=desc) (85b01da) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/9cf91b756f33cbddeac1adb912177f5b7762def6?el=desc) (9cf91b7) will **decrease** coverage by `20.33%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/1704/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/1704?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff             @@
   ##           master    #1704       +/-   ##
   ===========================================
   - Coverage   72.63%   52.29%   -20.34%     
   ===========================================
     Files         133       38       -95     
     Lines        5740     2660     -3080     
     Branches      666        0      -666     
   ===========================================
   - Hits         4169     1391     -2778     
   + Misses       1327     1081      -246     
   + Partials      244      188       -56     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | backend-e2e-test | `?` | |
   | backend-e2e-test-ginkgo | `?` | |
   | backend-unit-test | `52.29% <ø> (+0.03%)` | :arrow_up: |
   | frontend-e2e-test | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/1704?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [api/internal/utils/version.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1704/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL3V0aWxzL3ZlcnNpb24uZ28=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [api/internal/filter/request\_id.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1704/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2ZpbHRlci9yZXF1ZXN0X2lkLmdv) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [api/internal/core/entity/entity.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1704/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvZW50aXR5L2VudGl0eS5nbw==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [api/internal/core/store/storehub.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1704/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvc3RvcmUvc3RvcmVodWIuZ28=) | `0.00% <0.00%> (-71.03%)` | :arrow_down: |
   | [api/internal/filter/cors.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1704/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2ZpbHRlci9jb3JzLmdv) | `0.00% <0.00%> (-66.67%)` | :arrow_down: |
   | [api/internal/filter/schema.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1704/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2ZpbHRlci9zY2hlbWEuZ28=) | `0.00% <0.00%> (-55.47%)` | :arrow_down: |
   | [api/internal/utils/consts/api\_error.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1704/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL3V0aWxzL2NvbnN0cy9hcGlfZXJyb3IuZ28=) | `0.00% <0.00%> (-50.00%)` | :arrow_down: |
   | [api/internal/handler/data\_loader/route\_import.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1704/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2hhbmRsZXIvZGF0YV9sb2FkZXIvcm91dGVfaW1wb3J0Lmdv) | `27.41% <0.00%> (-37.50%)` | :arrow_down: |
   | [api/internal/handler/handler.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1704/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2hhbmRsZXIvaGFuZGxlci5nbw==) | `42.59% <0.00%> (-35.19%)` | :arrow_down: |
   | [api/internal/handler/schema/schema.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1704/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2hhbmRsZXIvc2NoZW1hL3NjaGVtYS5nbw==) | `66.66% <0.00%> (-33.34%)` | :arrow_down: |
   | ... and [119 more](https://codecov.io/gh/apache/apisix-dashboard/pull/1704/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1704?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/1704?src=pr&el=footer). Last update [9cf91b7...85b01da](https://codecov.io/gh/apache/apisix-dashboard/pull/1704?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] bisakhmondal commented on a change in pull request #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
bisakhmondal commented on a change in pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#discussion_r608681003



##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,461 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return

Review comment:
       yeah sure. Good catch.




-- 
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] bisakhmondal commented on a change in pull request #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
bisakhmondal commented on a change in pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#discussion_r607280749



##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,458 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return
+		}
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			Sleep:        time.Duration(2) * time.Second,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+	)
+
+	ginkgo.It("get the updated route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, _ := http.DefaultClient.Do(request)
+		respBody, _ := ioutil.ReadAll(resp.Body)
+		createtime2 := gjson.Get(string(respBody), "data.create_time")
+		updatetime2 := gjson.Get(string(respBody), "data.update_time")
+		//verify the route and compare result
+		gomega.Expect(gjson.Get(string(respBody), "data.name").String()).To(gomega.Equal("new jack"))
+		gomega.Expect(gjson.Get(string(respBody), "data.desc").String()).To(gomega.Equal("new desc"))
+		gomega.Expect(createtime2.String()).To(gomega.Equal(createtime.String()))
+		gomega.Expect(updatetime2.String()).NotTo(gomega.Equal(updatetime.String()))
+	})
+
+	ginkgo.It("delete the route (r1)", func() {
+		base.RunTestCase(base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		})
+	})
+
+	ginkgo.It("verify delete route (r1) success", func() {
+		base.RunTestCase(base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusNotFound,

Review comment:
       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.

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



[GitHub] [apisix-dashboard] bisakhmondal commented on a change in pull request #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
bisakhmondal commented on a change in pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#discussion_r608775272



##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,464 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectCode:   0,
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		gomega.Expect(err).Should(gomega.BeNil())
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectCode:   0,
+			Sleep:        time.Duration(2) * time.Second,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+	)
+
+	ginkgo.It("get the updated route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, _ := http.DefaultClient.Do(request)
+		respBody, _ := ioutil.ReadAll(resp.Body)
+		createtime2 := gjson.Get(string(respBody), "data.create_time")
+		updatetime2 := gjson.Get(string(respBody), "data.update_time")
+		//verify the route and compare result
+		gomega.Expect(gjson.Get(string(respBody), "data.name").String()).To(gomega.Equal("new jack"))
+		gomega.Expect(gjson.Get(string(respBody), "data.desc").String()).To(gomega.Equal("new desc"))
+		gomega.Expect(createtime2.String()).To(gomega.Equal(createtime.String()))
+		gomega.Expect(updatetime2.String()).NotTo(gomega.Equal(updatetime.String()))
+	})
+
+	ginkgo.It("delete the route (r1)", func() {
+		base.RunTestCase(base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		})
+	})
+
+	ginkgo.It("verify delete route (r1) success", func() {
+		base.RunTestCase(base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusNotFound,
+			ExpectBody:   `{"error_msg":"404 Route Not Found"}`,
+			Sleep:        base.SleepTime,
+		})
+	})
+})
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	table.DescribeTable("test route with label",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with labels (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"labels": {
+						"build":"16",
+						"env":"production",
+						"version":"v2"
+					},
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectCode:   0,
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("verify the route's detail (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(), ExpectCode: 0,

Review comment:
       Hehe🤡. Mishap from last commit.
   Lesson learnt: Never push commits while using public transport 😂😬.
   Anyway, fixing asap😅




-- 
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] bisakhmondal commented on a change in pull request #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
bisakhmondal commented on a change in pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#discussion_r606797915



##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,457 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",

Review comment:
       Thanks. Done :heavy_check_mark: 




-- 
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] bisakhmondal commented on a change in pull request #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
bisakhmondal commented on a change in pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#discussion_r608878778



##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,461 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return
+		}
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			Sleep:        time.Duration(2) * time.Second,

Review comment:
       Now, all tests with PUT request have been updated.




-- 
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] bisakhmondal commented on a change in pull request #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
bisakhmondal commented on a change in pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#discussion_r608878063



##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,464 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectCode:   0,
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		gomega.Expect(err).Should(gomega.BeNil())
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectCode:   0,
+			Sleep:        time.Duration(2) * time.Second,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+	)
+
+	ginkgo.It("get the updated route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, _ := http.DefaultClient.Do(request)
+		respBody, _ := ioutil.ReadAll(resp.Body)
+		createtime2 := gjson.Get(string(respBody), "data.create_time")
+		updatetime2 := gjson.Get(string(respBody), "data.update_time")
+		//verify the route and compare result
+		gomega.Expect(gjson.Get(string(respBody), "data.name").String()).To(gomega.Equal("new jack"))
+		gomega.Expect(gjson.Get(string(respBody), "data.desc").String()).To(gomega.Equal("new desc"))
+		gomega.Expect(createtime2.String()).To(gomega.Equal(createtime.String()))
+		gomega.Expect(updatetime2.String()).NotTo(gomega.Equal(updatetime.String()))
+	})
+
+	ginkgo.It("delete the route (r1)", func() {
+		base.RunTestCase(base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		})
+	})
+
+	ginkgo.It("verify delete route (r1) success", func() {
+		base.RunTestCase(base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusNotFound,
+			ExpectBody:   `{"error_msg":"404 Route Not Found"}`,
+			Sleep:        base.SleepTime,
+		})
+	})
+})
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	table.DescribeTable("test route with label",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with labels (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"labels": {
+						"build":"16",
+						"env":"production",
+						"version":"v2"
+					},
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectCode:   0,
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("verify the route's detail (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(), ExpectCode: 0,

Review comment:
       fixed :)




-- 
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] bisakhmondal commented on a change in pull request #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
bisakhmondal commented on a change in pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#discussion_r608710687



##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,461 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return
+		}
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			Sleep:        time.Duration(2) * time.Second,

Review comment:
       Hi Nic, just to make sure, the response body contains dynamic information like timestamp, do we really have to check the body?
   However, I have added `ExpectCode` as somewhat an alternative😄.
   eg.
   ```json
   {
       "code": 0,
       "message": "",
       "data": {
           "id": "r1",
           "create_time": 1617804834,
           "update_time": 1617804834,
           "uri": "/hello",
           "name": "new jack",
           "desc": "new desc",
           "upstream": {
               "nodes": {
                   "172.16.238.20:1980": 1
               },
               "type": "roundrobin"
           },
           "status": 1
       },
       "request_id": "22fbd110-3e00-4e2b-b267-528bdef67fd5"
   }
   ```




-- 
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 #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
nic-chen commented on a change in pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#discussion_r606872196



##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,458 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return
+		}
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			Sleep:        time.Duration(2) * time.Second,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+	)
+
+	ginkgo.It("get the updated route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, _ := http.DefaultClient.Do(request)
+		respBody, _ := ioutil.ReadAll(resp.Body)
+		createtime2 := gjson.Get(string(respBody), "data.create_time")
+		updatetime2 := gjson.Get(string(respBody), "data.update_time")
+		//verify the route and compare result
+		gomega.Expect(gjson.Get(string(respBody), "data.name").String()).To(gomega.Equal("new jack"))
+		gomega.Expect(gjson.Get(string(respBody), "data.desc").String()).To(gomega.Equal("new desc"))
+		gomega.Expect(createtime2.String()).To(gomega.Equal(createtime.String()))
+		gomega.Expect(updatetime2.String()).NotTo(gomega.Equal(updatetime.String()))
+	})
+
+	ginkgo.It("delete the route (r1)", func() {
+		base.RunTestCase(base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		})
+	})
+
+	ginkgo.It("verify delete route (r1) success", func() {
+		base.RunTestCase(base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusNotFound,

Review comment:
       better to check respond body for each case




-- 
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] bisakhmondal commented on a change in pull request #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
bisakhmondal commented on a change in pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#discussion_r607510723



##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,461 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return
+		}
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			Sleep:        time.Duration(2) * time.Second,

Review comment:
       okay. Just for this one or all other PUTs too




-- 
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 #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
starsz commented on a change in pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#discussion_r608279995



##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,461 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return

Review comment:
       Maybe we can use `gomega` to assert the err is nil.




-- 
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] bisakhmondal commented on a change in pull request #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
bisakhmondal commented on a change in pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#discussion_r607510723



##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,461 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return
+		}
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			Sleep:        time.Duration(2) * time.Second,

Review comment:
       okay. Just for this one or all PUT requests




-- 
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 #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
nic-chen commented on a change in pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#discussion_r607498594



##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,461 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return
+		}
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			Sleep:        time.Duration(2) * time.Second,

Review comment:
       need to check body too




-- 
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] bisakhmondal commented on a change in pull request #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
bisakhmondal commented on a change in pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#discussion_r608776178



##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,461 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return
+		}
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			Sleep:        time.Duration(2) * time.Second,

Review comment:
       Cool. Adding changes.




-- 
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 #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
starsz commented on a change in pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#discussion_r608760309



##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,464 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectCode:   0,
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		gomega.Expect(err).Should(gomega.BeNil())
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectCode:   0,
+			Sleep:        time.Duration(2) * time.Second,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+	)
+
+	ginkgo.It("get the updated route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, _ := http.DefaultClient.Do(request)
+		respBody, _ := ioutil.ReadAll(resp.Body)
+		createtime2 := gjson.Get(string(respBody), "data.create_time")
+		updatetime2 := gjson.Get(string(respBody), "data.update_time")
+		//verify the route and compare result
+		gomega.Expect(gjson.Get(string(respBody), "data.name").String()).To(gomega.Equal("new jack"))
+		gomega.Expect(gjson.Get(string(respBody), "data.desc").String()).To(gomega.Equal("new desc"))
+		gomega.Expect(createtime2.String()).To(gomega.Equal(createtime.String()))
+		gomega.Expect(updatetime2.String()).NotTo(gomega.Equal(updatetime.String()))
+	})
+
+	ginkgo.It("delete the route (r1)", func() {
+		base.RunTestCase(base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		})
+	})
+
+	ginkgo.It("verify delete route (r1) success", func() {
+		base.RunTestCase(base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusNotFound,
+			ExpectBody:   `{"error_msg":"404 Route Not Found"}`,
+			Sleep:        base.SleepTime,
+		})
+	})
+})
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	table.DescribeTable("test route with label",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with labels (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"labels": {
+						"build":"16",
+						"env":"production",
+						"version":"v2"
+					},
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectCode:   0,
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("verify the route's detail (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(), ExpectCode: 0,

Review comment:
       The style looks strange.




-- 
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 #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
juzhiyuan merged pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704


   


-- 
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 #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
nic-chen commented on a change in pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#discussion_r608740718



##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,461 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return
+		}
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			Sleep:        time.Duration(2) * time.Second,

Review comment:
       We can test the fixed part, example:
   
   ```go
   ExpectBody: []string{`"code":0`, `"name":"new jack"`},
   ```
   
   




-- 
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] Jaycean commented on a change in pull request #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
Jaycean commented on a change in pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#discussion_r606794087



##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,457 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",

Review comment:
       nodes host please use the base.UpstreamIp
   ```
   "nodes": {
   			"` + base.UpstreamIp + `:1980": 1
   		}
   ```

##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,457 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return
+		}
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			Sleep:        time.Duration(2) * time.Second,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+	)
+
+	ginkgo.It("get the updated route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, _ := http.DefaultClient.Do(request)
+		respBody, _ := ioutil.ReadAll(resp.Body)
+		createtime2 := gjson.Get(string(respBody), "data.create_time")
+		updatetime2 := gjson.Get(string(respBody), "data.update_time")
+		//verify the route and compare result
+		gomega.Expect(gjson.Get(string(respBody), "data.name").String()).To(gomega.Equal("new jack"))
+		gomega.Expect(gjson.Get(string(respBody), "data.desc").String()).To(gomega.Equal("new desc"))
+		gomega.Expect(createtime2.String()).To(gomega.Equal(createtime.String()))
+		gomega.Expect(updatetime2.String()).NotTo(gomega.Equal(updatetime.String()))
+	})
+
+	ginkgo.It("delete the route (r1)", func() {
+		base.RunTestCase(base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		})
+	})
+})
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	table.DescribeTable("test route with label",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with labels (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"labels": {
+						"build":"16",
+						"env":"production",
+						"version":"v2"
+					},
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("verify the route's detail (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"labels\":{\"build\":\"16\",\"env\":\"production\",\"version\":\"v2\"",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("delete the route (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route after delete it", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusNotFound,
+			Sleep:        base.SleepTime,
+		}),
+	)
+})
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	table.DescribeTable("test route search with label",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with labels (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"labels": {
+						"build":"16",
+						"env":"production",
+						"version":"v2"
+					},
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",

Review comment:
       ditto

##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,457 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return
+		}
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",

Review comment:
       ditto

##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,457 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return
+		}
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			Sleep:        time.Duration(2) * time.Second,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+	)
+
+	ginkgo.It("get the updated route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, _ := http.DefaultClient.Do(request)
+		respBody, _ := ioutil.ReadAll(resp.Body)
+		createtime2 := gjson.Get(string(respBody), "data.create_time")
+		updatetime2 := gjson.Get(string(respBody), "data.update_time")
+		//verify the route and compare result
+		gomega.Expect(gjson.Get(string(respBody), "data.name").String()).To(gomega.Equal("new jack"))
+		gomega.Expect(gjson.Get(string(respBody), "data.desc").String()).To(gomega.Equal("new desc"))
+		gomega.Expect(createtime2.String()).To(gomega.Equal(createtime.String()))
+		gomega.Expect(updatetime2.String()).NotTo(gomega.Equal(updatetime.String()))
+	})
+
+	ginkgo.It("delete the route (r1)", func() {
+		base.RunTestCase(base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		})
+	})
+})
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	table.DescribeTable("test route with label",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with labels (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"labels": {
+						"build":"16",
+						"env":"production",
+						"version":"v2"
+					},
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("verify the route's detail (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"labels\":{\"build\":\"16\",\"env\":\"production\",\"version\":\"v2\"",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("delete the route (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route after delete it", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusNotFound,
+			Sleep:        base.SleepTime,
+		}),
+	)
+})
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	table.DescribeTable("test route search with label",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with labels (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"labels": {
+						"build":"16",
+						"env":"production",
+						"version":"v2"
+					},
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("config route with labels (r2)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r2",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route2",
+					"uri": "/hello2",
+					"labels": {
+						"build":"17",
+						"env":"dev",
+						"version":"v2",
+						"extra": "test"
+					},
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",

Review comment:
       ditto

##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,457 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return
+		}
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			Sleep:        time.Duration(2) * time.Second,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+	)
+
+	ginkgo.It("get the updated route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, _ := http.DefaultClient.Do(request)
+		respBody, _ := ioutil.ReadAll(resp.Body)
+		createtime2 := gjson.Get(string(respBody), "data.create_time")
+		updatetime2 := gjson.Get(string(respBody), "data.update_time")
+		//verify the route and compare result
+		gomega.Expect(gjson.Get(string(respBody), "data.name").String()).To(gomega.Equal("new jack"))
+		gomega.Expect(gjson.Get(string(respBody), "data.desc").String()).To(gomega.Equal("new desc"))
+		gomega.Expect(createtime2.String()).To(gomega.Equal(createtime.String()))
+		gomega.Expect(updatetime2.String()).NotTo(gomega.Equal(updatetime.String()))
+	})
+
+	ginkgo.It("delete the route (r1)", func() {
+		base.RunTestCase(base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		})
+	})
+})
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	table.DescribeTable("test route with label",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with labels (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"labels": {
+						"build":"16",
+						"env":"production",
+						"version":"v2"
+					},
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("verify the route's detail (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"labels\":{\"build\":\"16\",\"env\":\"production\",\"version\":\"v2\"",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("delete the route (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route after delete it", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusNotFound,
+			Sleep:        base.SleepTime,
+		}),
+	)
+})
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	table.DescribeTable("test route search with label",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with labels (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"labels": {
+						"build":"16",
+						"env":"production",
+						"version":"v2"
+					},
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("config route with labels (r2)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r2",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route2",
+					"uri": "/hello2",
+					"labels": {
+						"build":"17",
+						"env":"dev",
+						"version":"v2",
+						"extra": "test"
+					},
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("verify the route's detail (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"labels\":{\"build\":\"16\",\"env\":\"production\",\"version\":\"v2\"",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("search the route by label", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes",
+			Query:        "label=build:16",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"labels\":{\"build\":\"16\",\"env\":\"production\",\"version\":\"v2\"",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("search the route by label (only key)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes",
+			Query:        "label=extra",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"labels\":{\"build\":\"17\",\"env\":\"dev\",\"extra\":\"test\",\"version\":\"v2\"",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("search the route by label (combination)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes",
+			Query:        "label=extra,build:16",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"total_size\":2",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("search the route by label (combination)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes",
+			Query:        "label=build:16,build:17",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"total_size\":2",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("delete the route (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("delete the route (r2)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r2",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route after delete it", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusNotFound,
+			Sleep:        base.SleepTime,
+		}),
+	)
+})
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	table.DescribeTable("test route search with create time",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("create route with create_time", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+				"name": "route1",
+				"uri": "/hello",
+				"create_time": 1608792721,
+				"upstream": {
+					"nodes": {
+						"172.16.238.20:1980": 1
+					},
+					"type": "roundrobin"
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+		}),
+		table.Entry("create route with update_time", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+				"name": "route1",
+				"uri": "/hello",
+				"update_time": 1608792721,
+				"upstream": {
+					"nodes": {
+						"172.16.238.20:1980": 1
+					},
+					"type": "roundrobin"
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+		}),
+		table.Entry("create route with create_time and update_time", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+				"name": "route1",
+				"uri": "/hello",
+				"create_time": 1608792721,
+				"update_time": 1608792721,
+				"upstream": {
+					"nodes": {
+						"172.16.238.20:1980": 1

Review comment:
       ditto

##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,457 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return
+		}
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			Sleep:        time.Duration(2) * time.Second,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+	)
+
+	ginkgo.It("get the updated route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, _ := http.DefaultClient.Do(request)
+		respBody, _ := ioutil.ReadAll(resp.Body)
+		createtime2 := gjson.Get(string(respBody), "data.create_time")
+		updatetime2 := gjson.Get(string(respBody), "data.update_time")
+		//verify the route and compare result
+		gomega.Expect(gjson.Get(string(respBody), "data.name").String()).To(gomega.Equal("new jack"))
+		gomega.Expect(gjson.Get(string(respBody), "data.desc").String()).To(gomega.Equal("new desc"))
+		gomega.Expect(createtime2.String()).To(gomega.Equal(createtime.String()))
+		gomega.Expect(updatetime2.String()).NotTo(gomega.Equal(updatetime.String()))
+	})
+
+	ginkgo.It("delete the route (r1)", func() {
+		base.RunTestCase(base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		})
+	})

Review comment:
       After the route is deleted, we need to check whether the route is deleted.

##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,457 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return
+		}
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			Sleep:        time.Duration(2) * time.Second,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+	)
+
+	ginkgo.It("get the updated route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, _ := http.DefaultClient.Do(request)
+		respBody, _ := ioutil.ReadAll(resp.Body)
+		createtime2 := gjson.Get(string(respBody), "data.create_time")
+		updatetime2 := gjson.Get(string(respBody), "data.update_time")
+		//verify the route and compare result
+		gomega.Expect(gjson.Get(string(respBody), "data.name").String()).To(gomega.Equal("new jack"))
+		gomega.Expect(gjson.Get(string(respBody), "data.desc").String()).To(gomega.Equal("new desc"))
+		gomega.Expect(createtime2.String()).To(gomega.Equal(createtime.String()))
+		gomega.Expect(updatetime2.String()).NotTo(gomega.Equal(updatetime.String()))
+	})
+
+	ginkgo.It("delete the route (r1)", func() {
+		base.RunTestCase(base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		})
+	})
+})
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	table.DescribeTable("test route with label",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with labels (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"labels": {
+						"build":"16",
+						"env":"production",
+						"version":"v2"
+					},
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("verify the route's detail (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"labels\":{\"build\":\"16\",\"env\":\"production\",\"version\":\"v2\"",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("delete the route (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route after delete it", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusNotFound,
+			Sleep:        base.SleepTime,
+		}),
+	)
+})
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	table.DescribeTable("test route search with label",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with labels (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"labels": {
+						"build":"16",
+						"env":"production",
+						"version":"v2"
+					},
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("config route with labels (r2)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r2",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route2",
+					"uri": "/hello2",
+					"labels": {
+						"build":"17",
+						"env":"dev",
+						"version":"v2",
+						"extra": "test"
+					},
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("verify the route's detail (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"labels\":{\"build\":\"16\",\"env\":\"production\",\"version\":\"v2\"",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("search the route by label", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes",
+			Query:        "label=build:16",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"labels\":{\"build\":\"16\",\"env\":\"production\",\"version\":\"v2\"",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("search the route by label (only key)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes",
+			Query:        "label=extra",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"labels\":{\"build\":\"17\",\"env\":\"dev\",\"extra\":\"test\",\"version\":\"v2\"",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("search the route by label (combination)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes",
+			Query:        "label=extra,build:16",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"total_size\":2",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("search the route by label (combination)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes",
+			Query:        "label=build:16,build:17",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"total_size\":2",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("delete the route (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("delete the route (r2)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r2",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route after delete it", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusNotFound,
+			Sleep:        base.SleepTime,
+		}),
+	)
+})
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	table.DescribeTable("test route search with create time",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("create route with create_time", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+				"name": "route1",
+				"uri": "/hello",
+				"create_time": 1608792721,
+				"upstream": {
+					"nodes": {
+						"172.16.238.20:1980": 1

Review comment:
       ditto

##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,457 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return
+		}
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			Sleep:        time.Duration(2) * time.Second,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+	)
+
+	ginkgo.It("get the updated route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, _ := http.DefaultClient.Do(request)
+		respBody, _ := ioutil.ReadAll(resp.Body)
+		createtime2 := gjson.Get(string(respBody), "data.create_time")
+		updatetime2 := gjson.Get(string(respBody), "data.update_time")
+		//verify the route and compare result
+		gomega.Expect(gjson.Get(string(respBody), "data.name").String()).To(gomega.Equal("new jack"))
+		gomega.Expect(gjson.Get(string(respBody), "data.desc").String()).To(gomega.Equal("new desc"))
+		gomega.Expect(createtime2.String()).To(gomega.Equal(createtime.String()))
+		gomega.Expect(updatetime2.String()).NotTo(gomega.Equal(updatetime.String()))
+	})
+
+	ginkgo.It("delete the route (r1)", func() {
+		base.RunTestCase(base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		})
+	})
+})
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	table.DescribeTable("test route with label",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with labels (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"labels": {
+						"build":"16",
+						"env":"production",
+						"version":"v2"
+					},
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",

Review comment:
       ditto




-- 
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 pull request #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#issuecomment-813049920


   > ci fails to pull docker images
   > cc @Jaycean, @juzhiyuan, @nic-chen
   
   ok, just retrigger


-- 
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] bisakhmondal commented on pull request #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
bisakhmondal commented on pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#issuecomment-813028792


   ci fails to pull docker images
   cc @Jaycean, @juzhiyuan, @nic-chen 


-- 
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] bisakhmondal commented on a change in pull request #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
bisakhmondal commented on a change in pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#discussion_r606797818



##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,457 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return
+		}
+		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")
+		gomega.Expect(createtime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+
+		gomega.Expect(updatetime.Int()).To(gomega.SatisfyAll(
+			gomega.BeNumerically(">=", time.Now().Unix()-1),
+			gomega.BeNumerically("<=", time.Now().Unix()+1),
+		))
+	})
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("update the route (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "new jack",
+					"desc": "new desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": [{
+							"host": "172.16.238.20",
+							"port": 1980,
+							"weight": 1
+						}]
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			Sleep:        time.Duration(2) * time.Second,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+	)
+
+	ginkgo.It("get the updated route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, _ := http.DefaultClient.Do(request)
+		respBody, _ := ioutil.ReadAll(resp.Body)
+		createtime2 := gjson.Get(string(respBody), "data.create_time")
+		updatetime2 := gjson.Get(string(respBody), "data.update_time")
+		//verify the route and compare result
+		gomega.Expect(gjson.Get(string(respBody), "data.name").String()).To(gomega.Equal("new jack"))
+		gomega.Expect(gjson.Get(string(respBody), "data.desc").String()).To(gomega.Equal("new desc"))
+		gomega.Expect(createtime2.String()).To(gomega.Equal(createtime.String()))
+		gomega.Expect(updatetime2.String()).NotTo(gomega.Equal(updatetime.String()))
+	})
+
+	ginkgo.It("delete the route (r1)", func() {
+		base.RunTestCase(base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		})
+	})

Review comment:
       Done :heavy_check_mark: 




-- 
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 #1704: feat: rewrite e2e test(test-e2e-route-with-management-fields) using ginkgo

Posted by GitBox <gi...@apache.org>.
starsz commented on a change in pull request #1704:
URL: https://github.com/apache/apisix-dashboard/pull/1704#discussion_r608757527



##########
File path: api/test/e2enew/route/route_with_management_fields_test.go
##########
@@ -0,0 +1,461 @@
+/*
+ * 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.
+ */
+package route
+
+import (
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"github.com/onsi/gomega"
+	"github.com/tidwall/gjson"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with management fields", func() {
+	var (
+		createtime, updatetime gjson.Result
+	)
+
+	table.DescribeTable("test for route with name description",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("config route with name and desc (r1)", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/routes/r1",
+			Method: http.MethodPut,
+			Body: `{
+					"name": "route1",
+					"uri": "/hello",
+					"name": "jack",
+					"desc": "config route with name and desc",
+					"upstream": {
+						"type": "roundrobin",
+						"nodes": {
+							"` + base.UpstreamIp + `:1980": 1
+						}
+					}
+				}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("check route exists by name", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusBadRequest,
+			ExpectBody:   "Route name is reduplicate",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("check route exists by name (exclude it self)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/notexist/routes",
+			Query:        "name=jack&exclude=r1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("access the route's uri (r1)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify the route's content (r1)", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+		}),
+	)
+
+	ginkgo.It("get the route information", func() {
+		time.Sleep(time.Duration(100) * time.Millisecond)
+		basepath := base.ManagerAPIHost + "/apisix/admin/routes"
+		request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+		request.Header.Add("Authorization", base.GetToken())
+		resp, err := http.DefaultClient.Do(request)
+		if err != nil {
+			return

Review comment:
       Well done.Thank you for your contribution.




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