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 2020/12/02 02:50:03 UTC

[GitHub] [apisix-dashboard] idbeta opened a new pull request #945: test: config route with management fileds (E2E)

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


   Please answer these questions before submitting a pull request
   
   - Why submit this pull request?
   - [x] E2E test
   - [ ] New feature provided
   - [ ] Improve performance
   
   - Related issues
   resolve #638
   


----------------------------------------------------------------
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 #945: test: config route with management fileds (E2E)

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


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/945?src=pr&el=h1) Report
   > Merging [#945](https://codecov.io/gh/apache/apisix-dashboard/pull/945?src=pr&el=desc) (bf6f20d) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/95f26122fee30d2fcbd18d98433b106c09e9bdca?el=desc) (95f2612) will **not change** coverage.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/945/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/945?src=pr&el=tree)
   
   ```diff
   @@           Coverage Diff           @@
   ##           master     #945   +/-   ##
   =======================================
     Coverage   43.10%   43.10%           
   =======================================
     Files          18       18           
     Lines        1290     1290           
   =======================================
     Hits          556      556           
     Misses        642      642           
     Partials       92       92           
   ```
   
   
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/945?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/945?src=pr&el=footer). Last update [95f2612...bf6f20d](https://codecov.io/gh/apache/apisix-dashboard/pull/945?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] membphis merged pull request #945: test: config route with management fileds (E2E)

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


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

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



[GitHub] [apisix-dashboard] membphis commented on a change in pull request #945: test: config route with management fileds (E2E)

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



##########
File path: api/test/e2e/route_with_management_fileds_test.go
##########
@@ -0,0 +1,228 @@
+/*
+ * 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 e2e
+
+import (
+	"io/ioutil"
+	"net/http"
+	"testing"
+	"time"
+
+	"github.com/stretchr/testify/assert"
+	"github.com/tidwall/gjson"
+)
+
+func TestRoute_with_name_desc(t *testing.T) {
+	tests := []HttpTestCase{
+		{
+			caseDesc: "config route with name and desc (r1)",
+			Object:   ManagerApiExpect(t),
+			Path:     "/apisix/admin/routes/r1",
+			Method:   http.MethodPut,
+			Body: `{
+					"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": token},
+			ExpectStatus: http.StatusOK,
+		},
+		{
+			caseDesc:     "access the route's uri (r1)",
+			Object:       APISIXExpect(t),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        sleepTime,
+		},
+		{
+			caseDesc:     "verify the route's content (r1)",
+			Object:       ManagerApiExpect(t),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+			Sleep:        sleepTime,
+		},
+	}
+	for _, tc := range tests {
+		testCaseCheck(tc)
+	}
+
+	//get the route
+	time.Sleep(time.Duration(100) * time.Millisecond)
+	basepath := "http://127.0.0.1:9000/apisix/admin/routes"
+	request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+	request.Header.Add("Authorization", token)
+	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")
+	assert.Equal(t, true, createtime.Int() >= time.Now().Unix()-1 && createtime.Int() <= time.Now().Unix()+1)
+	assert.Equal(t, true, updatetime.Int() >= time.Now().Unix()-1 && updatetime.Int() <= time.Now().Unix()+1)
+
+	tests = []HttpTestCase{
+		{
+			caseDesc: "update the route (r1)",
+			Object:   ManagerApiExpect(t),
+			Path:     "/apisix/admin/routes/r1",
+			Method:   http.MethodPut,
+			Body: `{
+					"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": token},
+			ExpectStatus: http.StatusOK,
+			Sleep:        time.Duration(2) * time.Second,
+		},
+
+		{
+			caseDesc:     "access the route's uri (r1)",
+			Object:       APISIXExpect(t),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        sleepTime,
+		},
+	}
+
+	for _, tc := range tests {
+		testCaseCheck(tc)
+	}
+
+	//get the route (updated)
+	time.Sleep(time.Duration(100) * time.Millisecond)
+	request, _ = http.NewRequest("GET", basepath+"/r1", nil)
+	request.Header.Add("Authorization", token)
+	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
+	assert.Equal(t, "new jack", gjson.Get(string(respBody), "data.name").String())
+	assert.Equal(t, "new desc", gjson.Get(string(respBody), "data.desc").String())
+	assert.Equal(t, createtime.String(), createtime2.String())
+	assert.NotEqual(t, updatetime.String(), updatetime2.String())
+
+	tests = []HttpTestCase{
+		{
+			caseDesc:     "delete the route (r1)",
+			Object:       ManagerApiExpect(t),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+		},
+	}
+
+	for _, tc := range tests {
+		testCaseCheck(tc)
+	}
+
+	tests = []HttpTestCase{

Review comment:
       I think we should put them to a new function




----------------------------------------------------------------
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 pull request #945: test: config route with management fileds (E2E)

Posted by GitBox <gi...@apache.org>.
nic-chen commented on pull request #945:
URL: https://github.com/apache/apisix-dashboard/pull/945#issuecomment-737054341


   LGTM Except for some code format issues.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

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



[GitHub] [apisix-dashboard] membphis commented on pull request #945: test: config route with management fileds (E2E)

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


   @nic-chen @gxthrj @moonming please take a look when you have time


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

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



[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #945: test: config route with management fileds (E2E)

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #945:
URL: https://github.com/apache/apisix-dashboard/pull/945#issuecomment-736956020


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/945?src=pr&el=h1) Report
   > Merging [#945](https://codecov.io/gh/apache/apisix-dashboard/pull/945?src=pr&el=desc) (97d3af5) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/95f26122fee30d2fcbd18d98433b106c09e9bdca?el=desc) (95f2612) will **not change** coverage.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/945/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/945?src=pr&el=tree)
   
   ```diff
   @@           Coverage Diff           @@
   ##           master     #945   +/-   ##
   =======================================
     Coverage   43.10%   43.10%           
   =======================================
     Files          18       18           
     Lines        1290     1290           
   =======================================
     Hits          556      556           
     Misses        642      642           
     Partials       92       92           
   ```
   
   
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/945?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/945?src=pr&el=footer). Last update [95f2612...c30b1d3](https://codecov.io/gh/apache/apisix-dashboard/pull/945?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] idbeta commented on a change in pull request #945: test: config route with management fileds (E2E)

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



##########
File path: api/test/e2e/route_with_management_fileds_test.go
##########
@@ -0,0 +1,228 @@
+/*
+ * 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 e2e
+
+import (
+	"io/ioutil"
+	"net/http"
+	"testing"
+	"time"
+
+	"github.com/stretchr/testify/assert"
+	"github.com/tidwall/gjson"
+)
+
+func TestRoute_with_name_desc(t *testing.T) {
+	tests := []HttpTestCase{
+		{
+			caseDesc: "config route with name and desc (r1)",
+			Object:   ManagerApiExpect(t),
+			Path:     "/apisix/admin/routes/r1",
+			Method:   http.MethodPut,
+			Body: `{
+					"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": token},
+			ExpectStatus: http.StatusOK,
+		},
+		{
+			caseDesc:     "access the route's uri (r1)",
+			Object:       APISIXExpect(t),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        sleepTime,
+		},
+		{
+			caseDesc:     "verify the route's content (r1)",
+			Object:       ManagerApiExpect(t),
+			Path:         "/apisix/admin/routes/r1",
+			Method:       http.MethodGet,
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"name\":\"jack\",\"desc\":\"config route with name and desc\"",
+			Sleep:        sleepTime,
+		},
+	}
+	for _, tc := range tests {
+		testCaseCheck(tc)
+	}
+
+	//get the route
+	time.Sleep(time.Duration(100) * time.Millisecond)
+	basepath := "http://127.0.0.1:9000/apisix/admin/routes"
+	request, _ := http.NewRequest("GET", basepath+"/r1", nil)
+	request.Header.Add("Authorization", token)
+	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")
+	assert.Equal(t, true, createtime.Int() >= time.Now().Unix()-1 && createtime.Int() <= time.Now().Unix()+1)
+	assert.Equal(t, true, updatetime.Int() >= time.Now().Unix()-1 && updatetime.Int() <= time.Now().Unix()+1)
+
+	tests = []HttpTestCase{
+		{
+			caseDesc: "update the route (r1)",
+			Object:   ManagerApiExpect(t),
+			Path:     "/apisix/admin/routes/r1",
+			Method:   http.MethodPut,
+			Body: `{
+					"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": token},
+			ExpectStatus: http.StatusOK,
+			Sleep:        time.Duration(2) * time.Second,
+		},
+
+		{
+			caseDesc:     "access the route's uri (r1)",
+			Object:       APISIXExpect(t),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        sleepTime,
+		},
+	}
+
+	for _, tc := range tests {
+		testCaseCheck(tc)
+	}
+
+	//get the route (updated)
+	time.Sleep(time.Duration(100) * time.Millisecond)
+	request, _ = http.NewRequest("GET", basepath+"/r1", nil)
+	request.Header.Add("Authorization", token)
+	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
+	assert.Equal(t, "new jack", gjson.Get(string(respBody), "data.name").String())
+	assert.Equal(t, "new desc", gjson.Get(string(respBody), "data.desc").String())
+	assert.Equal(t, createtime.String(), createtime2.String())
+	assert.NotEqual(t, updatetime.String(), updatetime2.String())
+
+	tests = []HttpTestCase{
+		{
+			caseDesc:     "delete the route (r1)",
+			Object:       ManagerApiExpect(t),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/routes/r1",
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+		},
+	}
+
+	for _, tc := range tests {
+		testCaseCheck(tc)
+	}
+
+	tests = []HttpTestCase{

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