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/11/27 11:25:39 UTC

[GitHub] [apisix-dashboard] membphis commented on a change in pull request #897: test: add cHash upstream (E2E)

membphis commented on a change in pull request #897:
URL: https://github.com/apache/apisix-dashboard/pull/897#discussion_r531543175



##########
File path: api/test/e2e/upstream_test.go
##########
@@ -188,7 +188,60 @@ func TestRoute_Node_Host(t *testing.T) {
 	}
 }
 
-//TODO cHash
+func TestUpstream_cHash(t *testing.T) {
+	tests := []HttpTestCase{
+		{
+			caseDesc: "create cHash upstream",
+			Object:   MangerApiExpect(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
+                }],
+				"type": "chash",
+				"hash_on":"header",
+				"key": "remote_addr"
+			}`,
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusOK,
+		},
+		{
+			caseDesc: "create route using the upstream just created",
+			Object:   MangerApiExpect(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,
+		},
+		{
+			caseDesc:     "hit the route just created",
+			Object:       APISIXExpect(t),
+			Method:       http.MethodGet,
+			Path:         "/server_port",
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "1981",
+			Sleep:        sleepTime,
+		},

Review comment:
       delete upstream object




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