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/07 06:15:34 UTC

[GitHub] [apisix-dashboard] idbeta opened a new pull request #972: test: e2e test balancer (roundrobin upstream)

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


   Please answer these questions before submitting a pull request
   
   - Why submit this pull request?
   - [x] E2E test
   - [ ] New feature provided
   - [ ] Improve performance
   
   - Related 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] juzhiyuan commented on pull request #972: test: e2e test balancer (roundrobin upstream)

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


   CI failed, @idbeta please take a look.
   
   ![image](https://user-images.githubusercontent.com/2106987/101564592-6560f580-3a06-11eb-9329-112cbf45bf29.png)
   


----------------------------------------------------------------
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 pull request #972: test: e2e test balancer (roundrobin upstream)

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


   > no related issue?
   
   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] membphis merged pull request #972: test: e2e test balancer (roundrobin upstream)

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


   


----------------------------------------------------------------
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 #972: test: e2e test balancer (roundrobin upstream)

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


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/972?src=pr&el=h1) Report
   > Merging [#972](https://codecov.io/gh/apache/apisix-dashboard/pull/972?src=pr&el=desc) (9eb6683) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/8976cca55972b7ba8686843bd51241cbc3e1554c?el=desc) (8976cca) will **increase** coverage by `0.07%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/972/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/972?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master     #972      +/-   ##
   ==========================================
   + Coverage   43.41%   43.49%   +0.07%     
   ==========================================
     Files          18       18              
     Lines        1299     1299              
   ==========================================
   + Hits          564      565       +1     
   + Misses        643      642       -1     
     Partials       92       92              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/972?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [api/internal/core/store/store.go](https://codecov.io/gh/apache/apisix-dashboard/pull/972/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvc3RvcmUvc3RvcmUuZ28=) | `79.22% <0.00%> (+0.64%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/972?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/972?src=pr&el=footer). Last update [8976cca...9eb6683](https://codecov.io/gh/apache/apisix-dashboard/pull/972?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 commented on pull request #972: test: e2e test balancer (roundrobin upstream)

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


   no related issue?


----------------------------------------------------------------
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 #972: test: e2e test balancer (roundrobin upstream)

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


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/972?src=pr&el=h1) Report
   > Merging [#972](https://codecov.io/gh/apache/apisix-dashboard/pull/972?src=pr&el=desc) (4c9c08f) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/8976cca55972b7ba8686843bd51241cbc3e1554c?el=desc) (8976cca) will **increase** coverage by `0.07%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/972/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/972?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master     #972      +/-   ##
   ==========================================
   + Coverage   43.41%   43.49%   +0.07%     
   ==========================================
     Files          18       18              
     Lines        1299     1299              
   ==========================================
   + Hits          564      565       +1     
   + Misses        643      642       -1     
     Partials       92       92              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/972?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [api/internal/core/store/store.go](https://codecov.io/gh/apache/apisix-dashboard/pull/972/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvc3RvcmUvc3RvcmUuZ28=) | `79.22% <0.00%> (+0.64%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/972?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/972?src=pr&el=footer). Last update [8976cca...4c9c08f](https://codecov.io/gh/apache/apisix-dashboard/pull/972?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 pull request #972: test: e2e test balancer (roundrobin upstream)

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


   @nic-chen when you are free, please help check the reason for this E2E failure.


----------------------------------------------------------------
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 #972: test: e2e test balancer (roundrobin upstream)

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



##########
File path: api/test/e2e/balancer_test.go
##########
@@ -0,0 +1,262 @@
+/*
+ * 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"
+)
+
+func TestBalancer_roundrobin_with_weight(t *testing.T) {
+	tests := []HttpTestCase{
+		{
+			caseDesc: "create upstream (roundrobin with same weight)",
+			Object:   ManagerApiExpect(t),
+			Method:   http.MethodPut,
+			Path:     "/apisix/admin/upstreams/1",
+			Body: `{
+				"nodes": [{
+					"host": "172.16.238.20",
+					"port": 1980,
+					"weight": 1
+				},
+				{
+					"host": "172.16.238.20",
+					"port": 1981,
+					"weight": 1
+				},
+				{
+					"host": "172.16.238.20",
+					"port": 1982,
+					"weight": 1
+				}],
+				"type": "roundrobin"
+			}`,
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+		},
+		{
+			caseDesc: "create route using the upstream just created",
+			Object:   ManagerApiExpect(t),
+			Method:   http.MethodPut,
+			Path:     "/apisix/admin/routes/1",
+			Body: `{
+				"uri": "/server_port",
+				"upstream_id": "1"
+			}`,
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+			Sleep:        sleepTime,
+		},
+	}
+
+	for _, tc := range tests {
+		testCaseCheck(tc)
+	}
+
+	//hit routes

Review comment:
       fixed.

##########
File path: api/test/e2e/balancer_test.go
##########
@@ -0,0 +1,262 @@
+/*
+ * 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"
+)
+
+func TestBalancer_roundrobin_with_weight(t *testing.T) {
+	tests := []HttpTestCase{
+		{
+			caseDesc: "create upstream (roundrobin with same weight)",
+			Object:   ManagerApiExpect(t),
+			Method:   http.MethodPut,
+			Path:     "/apisix/admin/upstreams/1",
+			Body: `{
+				"nodes": [{
+					"host": "172.16.238.20",
+					"port": 1980,
+					"weight": 1
+				},
+				{
+					"host": "172.16.238.20",
+					"port": 1981,
+					"weight": 1
+				},
+				{
+					"host": "172.16.238.20",
+					"port": 1982,
+					"weight": 1
+				}],
+				"type": "roundrobin"
+			}`,
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+		},
+		{
+			caseDesc: "create route using the upstream just created",
+			Object:   ManagerApiExpect(t),
+			Method:   http.MethodPut,
+			Path:     "/apisix/admin/routes/1",
+			Body: `{
+				"uri": "/server_port",
+				"upstream_id": "1"
+			}`,
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+			Sleep:        sleepTime,
+		},
+	}
+
+	for _, tc := range tests {
+		testCaseCheck(tc)
+	}
+
+	//hit routes
+	time.Sleep(200 * time.Millisecond)
+	basepath := "http://127.0.0.1:9080/"
+	request, err := http.NewRequest("GET", basepath+"/server_port", nil)
+	request.Header.Add("Authorization", token)
+	var resp *http.Response
+	var respBody []byte
+	res := map[string]int{}
+	for i := 0; i < 18; i++ {
+		resp, err = http.DefaultClient.Do(request)
+		assert.Nil(t, err)
+		respBody, err = ioutil.ReadAll(resp.Body)
+		body := string(respBody)
+		if _, ok := res[body]; !ok {
+			res[body] = 1
+		} else {
+			res[body] += 1
+		}
+		resp.Body.Close()
+	}
+	assert.True(t, res["1982"] == res["1981"] && res["1981"] == res["1980"] && res["1980"] == 6)

Review comment:
       fixed.

##########
File path: api/test/e2e/balancer_test.go
##########
@@ -0,0 +1,262 @@
+/*
+ * 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"
+)
+
+func TestBalancer_roundrobin_with_weight(t *testing.T) {
+	tests := []HttpTestCase{
+		{
+			caseDesc: "create upstream (roundrobin with same weight)",
+			Object:   ManagerApiExpect(t),
+			Method:   http.MethodPut,
+			Path:     "/apisix/admin/upstreams/1",
+			Body: `{
+				"nodes": [{
+					"host": "172.16.238.20",
+					"port": 1980,
+					"weight": 1
+				},
+				{
+					"host": "172.16.238.20",
+					"port": 1981,
+					"weight": 1
+				},
+				{
+					"host": "172.16.238.20",
+					"port": 1982,
+					"weight": 1
+				}],
+				"type": "roundrobin"
+			}`,
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+		},
+		{
+			caseDesc: "create route using the upstream just created",
+			Object:   ManagerApiExpect(t),
+			Method:   http.MethodPut,
+			Path:     "/apisix/admin/routes/1",
+			Body: `{
+				"uri": "/server_port",
+				"upstream_id": "1"
+			}`,
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+			Sleep:        sleepTime,
+		},
+	}
+
+	for _, tc := range tests {
+		testCaseCheck(tc)
+	}
+
+	//hit routes
+	time.Sleep(200 * time.Millisecond)
+	basepath := "http://127.0.0.1:9080/"
+	request, err := http.NewRequest("GET", basepath+"/server_port", nil)
+	request.Header.Add("Authorization", token)
+	var resp *http.Response
+	var respBody []byte
+	res := map[string]int{}
+	for i := 0; i < 18; i++ {
+		resp, err = http.DefaultClient.Do(request)
+		assert.Nil(t, err)
+		respBody, err = ioutil.ReadAll(resp.Body)
+		body := string(respBody)
+		if _, ok := res[body]; !ok {
+			res[body] = 1
+		} else {
+			res[body] += 1
+		}
+		resp.Body.Close()
+	}
+	assert.True(t, res["1982"] == res["1981"] && res["1981"] == res["1980"] && res["1980"] == 6)
+
+	tests = []HttpTestCase{
+		{
+			caseDesc: "create upstream (roundrobin with different weight)",
+			Object:   ManagerApiExpect(t),
+			Method:   http.MethodPut,
+			Path:     "/apisix/admin/upstreams/1",
+			Body: `{
+				"nodes": [{
+					"host": "172.16.238.20",
+					"port": 1980,
+					"weight": 1
+				},
+				{
+					"host": "172.16.238.20",
+					"port": 1981,
+					"weight": 2
+				},
+				{
+					"host": "172.16.238.20",
+					"port": 1982,
+					"weight": 3
+				}],
+				"type": "roundrobin"
+			}`,
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+		},
+	}
+	for _, tc := range tests {
+		testCaseCheck(tc)
+	}
+
+	//hit routes
+	time.Sleep(200 * time.Millisecond)
+	res = map[string]int{}
+	for i := 0; i < 18; i++ {
+		resp, err = http.DefaultClient.Do(request)
+		assert.Nil(t, err)
+		respBody, err = ioutil.ReadAll(resp.Body)
+		body := string(respBody)
+		if _, ok := res[body]; !ok {
+			res[body] = 1
+		} else {
+			res[body] += 1
+		}
+		resp.Body.Close()
+	}
+	assert.True(t, res["1980"] == 3 && res["1981"] == 6 && res["1982"] == 9)

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] idbeta edited a comment on pull request #972: test: e2e test balancer (roundrobin upstream)

Posted by GitBox <gi...@apache.org>.
idbeta edited a comment on pull request #972:
URL: https://github.com/apache/apisix-dashboard/pull/972#issuecomment-740443960


   @nic-chen when you are free, please help check the reason for this E2E failure. https://github.com/apache/apisix-dashboard/pull/972/checks?check_run_id=1515573556


----------------------------------------------------------------
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 #972: test: e2e test balancer (roundrobin upstream)

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



##########
File path: api/test/e2e/balancer_test.go
##########
@@ -0,0 +1,262 @@
+/*
+ * 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"
+)
+
+func TestBalancer_roundrobin_with_weight(t *testing.T) {
+	tests := []HttpTestCase{
+		{
+			caseDesc: "create upstream (roundrobin with same weight)",
+			Object:   ManagerApiExpect(t),
+			Method:   http.MethodPut,
+			Path:     "/apisix/admin/upstreams/1",
+			Body: `{
+				"nodes": [{
+					"host": "172.16.238.20",
+					"port": 1980,
+					"weight": 1
+				},
+				{
+					"host": "172.16.238.20",
+					"port": 1981,
+					"weight": 1
+				},
+				{
+					"host": "172.16.238.20",
+					"port": 1982,
+					"weight": 1
+				}],
+				"type": "roundrobin"
+			}`,
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+		},
+		{
+			caseDesc: "create route using the upstream just created",
+			Object:   ManagerApiExpect(t),
+			Method:   http.MethodPut,
+			Path:     "/apisix/admin/routes/1",
+			Body: `{
+				"uri": "/server_port",
+				"upstream_id": "1"
+			}`,
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+			Sleep:        sleepTime,
+		},
+	}
+
+	for _, tc := range tests {
+		testCaseCheck(tc)
+	}
+
+	//hit routes

Review comment:
       code style

##########
File path: api/test/e2e/balancer_test.go
##########
@@ -0,0 +1,262 @@
+/*
+ * 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"
+)
+
+func TestBalancer_roundrobin_with_weight(t *testing.T) {
+	tests := []HttpTestCase{
+		{
+			caseDesc: "create upstream (roundrobin with same weight)",
+			Object:   ManagerApiExpect(t),
+			Method:   http.MethodPut,
+			Path:     "/apisix/admin/upstreams/1",
+			Body: `{
+				"nodes": [{
+					"host": "172.16.238.20",
+					"port": 1980,
+					"weight": 1
+				},
+				{
+					"host": "172.16.238.20",
+					"port": 1981,
+					"weight": 1
+				},
+				{
+					"host": "172.16.238.20",
+					"port": 1982,
+					"weight": 1
+				}],
+				"type": "roundrobin"
+			}`,
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+		},
+		{
+			caseDesc: "create route using the upstream just created",
+			Object:   ManagerApiExpect(t),
+			Method:   http.MethodPut,
+			Path:     "/apisix/admin/routes/1",
+			Body: `{
+				"uri": "/server_port",
+				"upstream_id": "1"
+			}`,
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+			Sleep:        sleepTime,
+		},
+	}
+
+	for _, tc := range tests {
+		testCaseCheck(tc)
+	}
+
+	//hit routes
+	time.Sleep(200 * time.Millisecond)
+	basepath := "http://127.0.0.1:9080/"
+	request, err := http.NewRequest("GET", basepath+"/server_port", nil)
+	request.Header.Add("Authorization", token)
+	var resp *http.Response
+	var respBody []byte
+	res := map[string]int{}
+	for i := 0; i < 18; i++ {
+		resp, err = http.DefaultClient.Do(request)
+		assert.Nil(t, err)
+		respBody, err = ioutil.ReadAll(resp.Body)
+		body := string(respBody)
+		if _, ok := res[body]; !ok {
+			res[body] = 1
+		} else {
+			res[body] += 1
+		}
+		resp.Body.Close()
+	}
+	assert.True(t, res["1982"] == res["1981"] && res["1981"] == res["1980"] && res["1980"] == 6)

Review comment:
       code style

##########
File path: api/test/e2e/balancer_test.go
##########
@@ -0,0 +1,262 @@
+/*
+ * 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"
+)
+
+func TestBalancer_roundrobin_with_weight(t *testing.T) {
+	tests := []HttpTestCase{
+		{
+			caseDesc: "create upstream (roundrobin with same weight)",
+			Object:   ManagerApiExpect(t),
+			Method:   http.MethodPut,
+			Path:     "/apisix/admin/upstreams/1",
+			Body: `{
+				"nodes": [{
+					"host": "172.16.238.20",
+					"port": 1980,
+					"weight": 1
+				},
+				{
+					"host": "172.16.238.20",
+					"port": 1981,
+					"weight": 1
+				},
+				{
+					"host": "172.16.238.20",
+					"port": 1982,
+					"weight": 1
+				}],
+				"type": "roundrobin"
+			}`,
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+		},
+		{
+			caseDesc: "create route using the upstream just created",
+			Object:   ManagerApiExpect(t),
+			Method:   http.MethodPut,
+			Path:     "/apisix/admin/routes/1",
+			Body: `{
+				"uri": "/server_port",
+				"upstream_id": "1"
+			}`,
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+			Sleep:        sleepTime,
+		},
+	}
+
+	for _, tc := range tests {
+		testCaseCheck(tc)
+	}
+
+	//hit routes
+	time.Sleep(200 * time.Millisecond)
+	basepath := "http://127.0.0.1:9080/"
+	request, err := http.NewRequest("GET", basepath+"/server_port", nil)
+	request.Header.Add("Authorization", token)
+	var resp *http.Response
+	var respBody []byte
+	res := map[string]int{}
+	for i := 0; i < 18; i++ {
+		resp, err = http.DefaultClient.Do(request)
+		assert.Nil(t, err)
+		respBody, err = ioutil.ReadAll(resp.Body)
+		body := string(respBody)
+		if _, ok := res[body]; !ok {
+			res[body] = 1
+		} else {
+			res[body] += 1
+		}
+		resp.Body.Close()
+	}
+	assert.True(t, res["1982"] == res["1981"] && res["1981"] == res["1980"] && res["1980"] == 6)
+
+	tests = []HttpTestCase{
+		{
+			caseDesc: "create upstream (roundrobin with different weight)",
+			Object:   ManagerApiExpect(t),
+			Method:   http.MethodPut,
+			Path:     "/apisix/admin/upstreams/1",
+			Body: `{
+				"nodes": [{
+					"host": "172.16.238.20",
+					"port": 1980,
+					"weight": 1
+				},
+				{
+					"host": "172.16.238.20",
+					"port": 1981,
+					"weight": 2
+				},
+				{
+					"host": "172.16.238.20",
+					"port": 1982,
+					"weight": 3
+				}],
+				"type": "roundrobin"
+			}`,
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+		},
+	}
+	for _, tc := range tests {
+		testCaseCheck(tc)
+	}
+
+	//hit routes
+	time.Sleep(200 * time.Millisecond)
+	res = map[string]int{}
+	for i := 0; i < 18; i++ {
+		resp, err = http.DefaultClient.Do(request)
+		assert.Nil(t, err)
+		respBody, err = ioutil.ReadAll(resp.Body)
+		body := string(respBody)
+		if _, ok := res[body]; !ok {
+			res[body] = 1
+		} else {
+			res[body] += 1
+		}
+		resp.Body.Close()
+	}
+	assert.True(t, res["1980"] == 3 && res["1981"] == 6 && res["1982"] == 9)

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