You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by st...@apache.org on 2021/03/28 02:42:32 UTC

[apisix-dashboard] branch master updated: feat: rewrite e2e test route with plugin limit count test with ginkgo (#1677)

This is an automated email from the ASF dual-hosted git repository.

starsz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 7adefe1  feat: rewrite e2e test route with plugin limit count test with ginkgo (#1677)
7adefe1 is described below

commit 7adefe147f99a6422f02fa652bb1534b71c1c65f
Author: JinChen <ji...@163.com>
AuthorDate: Sun Mar 28 10:42:25 2021 +0800

    feat: rewrite e2e test route with plugin limit count test with ginkgo (#1677)
---
 api/test/e2e/route_with_plugin_limit_count_test.go | 459 ---------------------
 .../route/route_with_plugin_limit_count_test.go    | 417 +++++++++++++++++++
 2 files changed, 417 insertions(+), 459 deletions(-)

diff --git a/api/test/e2e/route_with_plugin_limit_count_test.go b/api/test/e2e/route_with_plugin_limit_count_test.go
deleted file mode 100644
index 9b9e68e..0000000
--- a/api/test/e2e/route_with_plugin_limit_count_test.go
+++ /dev/null
@@ -1,459 +0,0 @@
-/*
- * 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 (
-	"net/http"
-	"testing"
-	"time"
-)
-
-func TestRoute_With_Limit_Plugin(t *testing.T) {
-	tests := []HttpTestCase{
-		{
-			Desc:         "make sure the route is not created ",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			ExpectStatus: http.StatusNotFound,
-			ExpectBody:   `{"error_msg":"404 Route Not Found"}`,
-		},
-		{
-			Desc:   "create route",
-			Object: ManagerApiExpect(t),
-			Method: http.MethodPut,
-			Path:   "/apisix/admin/routes/r1",
-			Body: `{
-				"name": "route1",
-				"uri": "/hello",
-				"plugins": {
-					"limit-count": {
-						"count": 2,
-						"time_window": 2,
-						"rejected_code": 503,
-						"key": "remote_addr"
-					}
-				},
-				"upstream": {
-					"type": "roundrobin",
-					"nodes": [{
-						"host": "172.16.238.20",
-						"port": 1981,
-						"weight": 1
-					}]
-				}
-			}`,
-			Headers:      map[string]string{"Authorization": token},
-			ExpectStatus: http.StatusOK,
-			ExpectBody:   `"code":0`,
-		},
-		{
-			Desc:         "verify route that should not be limited",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			ExpectStatus: http.StatusOK,
-			ExpectBody:   "hello world",
-			Sleep:        sleepTime,
-		},
-		{
-			Desc:         "verify route that should not be limited 2",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			ExpectStatus: http.StatusOK,
-			ExpectBody:   "hello world",
-		},
-		{
-			Desc:         "verify route that should be limited",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			ExpectStatus: http.StatusServiceUnavailable,
-			ExpectBody:   "503 Service Temporarily Unavailable",
-		},
-		{
-			Desc:         "verify route that should not be limited since time window pass",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			ExpectStatus: http.StatusOK,
-			ExpectBody:   "hello world",
-			Sleep:        3 * time.Second,
-		},
-		{
-			Desc:         "delete route",
-			Object:       ManagerApiExpect(t),
-			Method:       http.MethodDelete,
-			Path:         "/apisix/admin/routes/r1",
-			Headers:      map[string]string{"Authorization": token},
-			ExpectStatus: http.StatusOK,
-		},
-		{
-			Desc:         "make sure the route has been deleted",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			ExpectStatus: http.StatusNotFound,
-			ExpectBody:   `{"error_msg":"404 Route Not Found"}`,
-			Sleep:        sleepTime,
-		},
-	}
-
-	for _, tc := range tests {
-		testCaseCheck(tc, t)
-	}
-}
-
-func TestRoute_With_Limit_Plugin_By_Consumer(t *testing.T) {
-	tests := []HttpTestCase{
-		{
-			Desc:         "make sure the route is not created ",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			ExpectStatus: http.StatusNotFound,
-			ExpectBody:   `{"error_msg":"404 Route Not Found"}`,
-		},
-		{
-			Desc:   "create route",
-			Object: ManagerApiExpect(t),
-			Method: http.MethodPut,
-			Path:   "/apisix/admin/routes/r1",
-			Body: `{
-				"name": "route1",
-				"uri": "/hello",
-				"plugins": {
-					"key-auth": {},
-					"limit-count": {
-						"count": 2,
-						"time_window": 2,
-						"rejected_code": 503,
-						"key": "consumer_name"
-					}
-				},
-				"upstream": {
-					"type": "roundrobin",
-					"nodes": [{
-						"host": "172.16.238.20",
-						"port": 1981,
-						"weight": 1
-					}]
-				}
-			}`,
-			Headers:      map[string]string{"Authorization": token},
-			ExpectStatus: http.StatusOK,
-			ExpectBody:   `"code":0`,
-		},
-		{
-			Desc:         "make sure the consumer is not created",
-			Object:       ManagerApiExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/apisix/admin/consumers/jack",
-			Headers:      map[string]string{"Authorization": token},
-			ExpectStatus: http.StatusNotFound,
-		},
-		{
-			Desc:   "create consumer",
-			Object: ManagerApiExpect(t),
-			Path:   "/apisix/admin/consumers",
-			Method: http.MethodPut,
-			Body: `{
-				"username": "jack",
-				"plugins": {
-					"key-auth": {
-						"key": "auth-jack"
-					}
-				}
-			}`,
-			Headers:      map[string]string{"Authorization": token},
-			ExpectStatus: http.StatusOK,
-		},
-		{
-			Desc:   "create consumer 2",
-			Object: ManagerApiExpect(t),
-			Path:   "/apisix/admin/consumers",
-			Method: http.MethodPut,
-			Body: `{
-				"username": "pony",
-				"plugins": {
-					"key-auth": {
-						"key": "auth-pony"
-					}
-				}
-			}`,
-			Headers:      map[string]string{"Authorization": token},
-			ExpectStatus: http.StatusOK,
-		},
-		{
-			Desc:         "verify route that should not be limited",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			Headers:      map[string]string{"apikey": "auth-jack"},
-			ExpectStatus: http.StatusOK,
-			ExpectBody:   "hello world",
-			Sleep:        sleepTime,
-		},
-		{
-			Desc:         "verify route that should not be limited 2",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			Headers:      map[string]string{"apikey": "auth-jack"},
-			ExpectStatus: http.StatusOK,
-			ExpectBody:   "hello world",
-		},
-		{
-			Desc:         "verify route that should be limited",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			Headers:      map[string]string{"apikey": "auth-jack"},
-			ExpectStatus: http.StatusServiceUnavailable,
-			ExpectBody:   "503 Service Temporarily Unavailable",
-		},
-		{
-			Desc:         "verify route that should not be limited (other consumer)",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			Headers:      map[string]string{"apikey": "auth-pony"},
-			ExpectStatus: http.StatusOK,
-			ExpectBody:   "hello world",
-		},
-		{
-			Desc:         "verify route that should not be limited since time window pass",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			Headers:      map[string]string{"apikey": "auth-jack"},
-			ExpectStatus: http.StatusOK,
-			ExpectBody:   "hello world",
-			Sleep:        2 * time.Second,
-		},
-		{
-			Desc:         "delete consumer pony",
-			Object:       ManagerApiExpect(t),
-			Method:       http.MethodDelete,
-			Path:         "/apisix/admin/consumers/pony",
-			Headers:      map[string]string{"Authorization": token},
-			ExpectStatus: http.StatusOK,
-		},
-		{
-			Desc:         "delete consumer jack",
-			Object:       ManagerApiExpect(t),
-			Method:       http.MethodDelete,
-			Path:         "/apisix/admin/consumers/jack",
-			Headers:      map[string]string{"Authorization": token},
-			ExpectStatus: http.StatusOK,
-		},
-		{
-			Desc:         "make sure pony has been deleted",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			Headers:      map[string]string{"apikey": "auth-pony"},
-			ExpectStatus: http.StatusUnauthorized,
-			ExpectBody:   `{"message":"Missing related consumer"}`,
-			Sleep:        sleepTime,
-		},
-		{
-			Desc:         "make sure jack has been deleted",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			Headers:      map[string]string{"apikey": "auth-pony"},
-			ExpectStatus: http.StatusUnauthorized,
-			ExpectBody:   `{"message":"Missing related consumer"}`,
-		},
-		{
-			Desc:         "delete route",
-			Object:       ManagerApiExpect(t),
-			Method:       http.MethodDelete,
-			Path:         "/apisix/admin/routes/r1",
-			Headers:      map[string]string{"Authorization": token},
-			ExpectStatus: http.StatusOK,
-		},
-		{
-			Desc:         "make sure the route has been deleted",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			ExpectStatus: http.StatusNotFound,
-			ExpectBody:   `{"error_msg":"404 Route Not Found"}`,
-			Sleep:        sleepTime,
-		},
-	}
-
-	for _, tc := range tests {
-		testCaseCheck(tc, t)
-	}
-}
-
-func TestRoute_With_Limit_Count_And_Disable(t *testing.T) {
-	tests := []HttpTestCase{
-		{
-			Desc:         "make sure the route is not created ",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			ExpectStatus: http.StatusNotFound,
-			ExpectBody:   `{"error_msg":"404 Route Not Found"}`,
-		},
-		{
-			Desc:   "create route",
-			Object: ManagerApiExpect(t),
-			Method: http.MethodPut,
-			Path:   "/apisix/admin/routes/r1",
-			Body: `{
-				"name": "route1",
-				"uri": "/hello",
-				"plugins": {
-					"limit-count": {
-						"count": 2,
-						"time_window": 2,
-						"rejected_code": 503,
-						"key": "remote_addr",
-						"disable": false
-					}
-				},
-				"upstream": {
-					"type": "roundrobin",
-					"nodes": [{
-						"host": "172.16.238.20",
-						"port": 1981,
-						"weight": 1
-					}]
-				}
-			}`,
-			Headers:      map[string]string{"Authorization": token},
-			ExpectStatus: http.StatusOK,
-			ExpectBody:   `"code":0`,
-		},
-		{
-			Desc:         "verify route that should not be limited",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			ExpectStatus: http.StatusOK,
-			ExpectBody:   "hello world",
-			Sleep:        sleepTime,
-		},
-		{
-			Desc:         "verify route that should not be limited 2",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			ExpectStatus: http.StatusOK,
-			ExpectBody:   "hello world",
-		},
-		{
-			Desc:         "verify route that should be limited",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			ExpectStatus: http.StatusServiceUnavailable,
-			ExpectBody:   "503 Service Temporarily Unavailable",
-		},
-		{
-			Desc:         "verify route that should not be limited since time window pass",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			ExpectStatus: http.StatusOK,
-			ExpectBody:   "hello world",
-			Sleep:        2 * time.Second,
-		},
-		{
-			Desc:   "update route to disable plugin limit-count",
-			Object: ManagerApiExpect(t),
-			Method: http.MethodPut,
-			Path:   "/apisix/admin/routes/r1",
-			Body: `{
-				"name": "route1",
-				"uri": "/hello",
-				"plugins": {
-					"limit-count": {
-						"count": 1,
-						"time_window": 2,
-						"rejected_code": 503,
-						"key": "remote_addr",
-						"disable": true
-					}
-				},
-				"upstream": {
-					"type": "roundrobin",
-					"nodes": [{
-						"host": "172.16.238.20",
-						"port": 1981,
-						"weight": 1
-					}]
-				}
-			}`,
-			Headers:      map[string]string{"Authorization": token},
-			ExpectStatus: http.StatusOK,
-			ExpectBody:   `"code":0`,
-		},
-		{
-			Desc:         "verify route that should not be limited",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			ExpectStatus: http.StatusOK,
-			ExpectBody:   "hello world",
-			Sleep:        sleepTime,
-		},
-		{
-			Desc:         "verify route that should not be limited (exceed config count)",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			ExpectStatus: http.StatusOK,
-			ExpectBody:   "hello world",
-		},
-		{
-			Desc:         "verify route that should not be limited (exceed config count again)",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			ExpectStatus: http.StatusOK,
-			ExpectBody:   "hello world",
-		},
-		{
-			Desc:         "delete route",
-			Object:       ManagerApiExpect(t),
-			Method:       http.MethodDelete,
-			Path:         "/apisix/admin/routes/r1",
-			Headers:      map[string]string{"Authorization": token},
-			ExpectStatus: http.StatusOK,
-		},
-		{
-			Desc:         "make sure the route has been deleted",
-			Object:       APISIXExpect(t),
-			Method:       http.MethodGet,
-			Path:         "/hello",
-			ExpectStatus: http.StatusNotFound,
-			ExpectBody:   `{"error_msg":"404 Route Not Found"}`,
-			Sleep:        sleepTime,
-		},
-	}
-
-	for _, tc := range tests {
-		testCaseCheck(tc, t)
-	}
-}
diff --git a/api/test/e2enew/route/route_with_plugin_limit_count_test.go b/api/test/e2enew/route/route_with_plugin_limit_count_test.go
new file mode 100644
index 0000000..45e384b
--- /dev/null
+++ b/api/test/e2enew/route/route_with_plugin_limit_count_test.go
@@ -0,0 +1,417 @@
+/*
+ * 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 (
+	"net/http"
+	"time"
+
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route with limit plugin", func() {
+	table.DescribeTable("test route with limit plugin",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("make sure the route is not created", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			ExpectStatus: http.StatusNotFound,
+			ExpectBody:   `{"error_msg":"404 Route Not Found"}`,
+		}),
+		table.Entry("create route with limit plugin", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/routes/r1",
+			Body: `{
+				"name": "route1",
+				"uri": "/hello",
+				"plugins": {
+					"limit-count": {
+						"count": 2,
+						"time_window": 2,
+						"rejected_code": 503,
+						"key": "remote_addr"
+					}
+				},
+				"upstream": {
+					"type": "roundrobin",
+					"nodes": {
+						"` + base.UpstreamIp + `:1981": 1
+					}
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   `"code":0`,
+		}),
+		table.Entry("verify route that should not be limited", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("verify route that should not be limited 2", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify route that should be limited", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			ExpectStatus: http.StatusServiceUnavailable,
+			ExpectBody:   "503 Service Temporarily Unavailable",
+		}),
+		table.Entry("verify route that should not be limited since time window pass", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        3 * time.Second,
+		}),
+		table.Entry("delete route", 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("hit the route just deleted", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			ExpectStatus: http.StatusNotFound,
+			ExpectBody:   `{"error_msg":"404 Route Not Found"}`,
+			Sleep:        base.SleepTime,
+		}),
+	)
+})
+
+var _ = ginkgo.Describe("route with limit plugin by consumer", func() {
+	table.DescribeTable("test route with limit plugin by consumer",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("make sure the route is not created", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			ExpectStatus: http.StatusNotFound,
+			ExpectBody:   `{"error_msg":"404 Route Not Found"}`,
+		}),
+		table.Entry("create route with limit plugin", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/routes/r1",
+			Body: `{
+			   "name": "route1",
+			   "uri": "/hello",
+			   "plugins": {
+				"key-auth": {},
+				   "limit-count": {
+					   "count": 2,
+					   "time_window": 2,
+					   "rejected_code": 503,
+					   "key": "consumer_name"
+				   }
+			   },
+			   "upstream": {
+				   "type": "roundrobin",
+				   "nodes": {
+					   "` + base.UpstreamIp + `:1981": 1
+				   }
+			   }
+		   }`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   `"code":0`,
+		}),
+		table.Entry("make sure the consumer is not created", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodGet,
+			Path:         "/apisix/admin/consumers/jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusNotFound,
+		}),
+		table.Entry("create consumer", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/consumers",
+			Method: http.MethodPut,
+			Body: `{
+			"username": "jack",
+			"plugins": {
+				"key-auth": {
+					"key": "auth-jack"
+				}
+			}
+		}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("create consumer 2", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Path:   "/apisix/admin/consumers",
+			Method: http.MethodPut,
+			Body: `{
+			"username": "pony",
+			"plugins": {
+				"key-auth": {
+					"key": "auth-pony"
+				}
+			}
+		}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("verify route that should not be limited", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"apikey": "auth-jack"},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("verify route that should not be limited 2", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"apikey": "auth-jack"},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify route that should be limited", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"apikey": "auth-jack"},
+			ExpectStatus: http.StatusServiceUnavailable,
+			ExpectBody:   "503 Service Temporarily Unavailable",
+		}),
+		table.Entry("verify route that should not be limited (other consumer)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"apikey": "auth-pony"},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify route that should not be limited since time window pass", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"apikey": "auth-jack"},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        2 * time.Second,
+		}),
+		table.Entry("delete consumer pony", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/consumers/pony",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("delete consumer jack", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/consumers/jack",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		table.Entry("make sure pony has been deleted", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"apikey": "auth-pony"},
+			ExpectStatus: http.StatusUnauthorized,
+			ExpectBody:   `{"message":"Missing related consumer"}`,
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("make sure jack has been deleted", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			Headers:      map[string]string{"apikey": "auth-jack"},
+			ExpectStatus: http.StatusUnauthorized,
+			ExpectBody:   `{"message":"Missing related consumer"}`,
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("delete route", 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("hit the route just deleted", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			ExpectStatus: http.StatusNotFound,
+			ExpectBody:   `{"error_msg":"404 Route Not Found"}`,
+			Sleep:        base.SleepTime,
+		}),
+	)
+})
+
+var _ = ginkgo.Describe("route with limit count and disable", func() {
+	table.DescribeTable("test route with limit count and disable",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		table.Entry("make sure the route is not created", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			ExpectStatus: http.StatusNotFound,
+			ExpectBody:   `{"error_msg":"404 Route Not Found"}`,
+		}),
+		table.Entry("create route with limit plugin", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/routes/r1",
+			Body: `{
+			   "name": "route1",
+			   "uri": "/hello",
+			   "plugins": {
+				   "limit-count": {
+					   "count": 2,
+					   "time_window": 2,
+					   "rejected_code": 503,
+					   "key": "remote_addr",
+					   "disable": false
+				   }
+			   },
+			   "upstream": {
+				   "type": "roundrobin",
+				   "nodes": {
+					   "` + base.UpstreamIp + `:1981": 1
+				   }
+			   }
+		   }`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   `"code":0`,
+		}),
+		table.Entry("verify route that should not be limited", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("verify route that should not be limited 2", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify route that should be limited", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			ExpectStatus: http.StatusServiceUnavailable,
+			ExpectBody:   "503 Service Temporarily Unavailable",
+		}),
+		table.Entry("verify route that should not be limited since time window pass", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        2 * time.Second,
+		}),
+		table.Entry("update route to disable plugin limit-count", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/routes/r1",
+			Body: `{
+			   "name": "route1",
+			   "uri": "/hello",
+			   "plugins": {
+				   "limit-count": {
+					   "count": 1,
+					   "time_window": 2,
+					   "rejected_code": 503,
+					   "key": "remote_addr",
+					   "disable": true
+				   }
+			   },
+			   "upstream": {
+				   "type": "roundrobin",
+				   "nodes": {
+					   "` + base.UpstreamIp + `:1981": 1
+				   }
+			   }
+		   }`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   `"code":0`,
+		}),
+		table.Entry("verify route that should not be limited", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+			Sleep:        base.SleepTime,
+		}),
+		table.Entry("verify route that should not be limited (exceed config count)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("verify route that should not be limited (exceed config count again)", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "hello world",
+		}),
+		table.Entry("delete route", 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("hit the route just deleted", base.HttpTestCase{
+			Object:       base.APISIXExpect(),
+			Method:       http.MethodGet,
+			Path:         "/hello",
+			ExpectStatus: http.StatusNotFound,
+			ExpectBody:   `{"error_msg":"404 Route Not Found"}`,
+			Sleep:        base.SleepTime,
+		}),
+	)
+})