Remove global-rate-limit feature (#11851)
This commit is contained in:
parent
5243b9b90a
commit
21cd966d1c
25 changed files with 28 additions and 1326 deletions
|
|
@ -1,88 +0,0 @@
|
|||
/*
|
||||
Copyright 2020 The Kubernetes Authors.
|
||||
|
||||
Licensed 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 annotations
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||
)
|
||||
|
||||
var _ = framework.DescribeAnnotation("annotation-global-rate-limit", func() {
|
||||
f := framework.NewDefaultFramework("global-rate-limit")
|
||||
host := "global-rate-limit-annotation"
|
||||
|
||||
ginkgo.BeforeEach(func() {
|
||||
f.NewEchoDeployment()
|
||||
})
|
||||
|
||||
ginkgo.It("generates correct configuration", func() {
|
||||
annotations := make(map[string]string)
|
||||
annotations["nginx.ingress.kubernetes.io/global-rate-limit"] = "5"
|
||||
annotations["nginx.ingress.kubernetes.io/global-rate-limit-window"] = "2m"
|
||||
|
||||
// We need to allow { and } characters for this annotation to work
|
||||
f.UpdateNginxConfigMapData("annotation-value-word-blocklist", "load_module, lua_package, _by_lua, location, root")
|
||||
// Sleep a while just to guarantee that the configmap is applied
|
||||
framework.Sleep()
|
||||
|
||||
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations)
|
||||
ing = f.EnsureIngress(ing)
|
||||
namespace := strings.ReplaceAll(string(ing.UID), "-", "")
|
||||
|
||||
serverConfig := ""
|
||||
f.WaitForNginxServer(host, func(server string) bool {
|
||||
serverConfig = server
|
||||
return true
|
||||
})
|
||||
assert.Contains(ginkgo.GinkgoT(), serverConfig,
|
||||
fmt.Sprintf(`global_throttle = { namespace = "%v", `+
|
||||
`limit = 5, window_size = 120, key = { { nil, nil, "remote_addr", nil, }, }, `+
|
||||
`ignored_cidrs = { } }`,
|
||||
namespace))
|
||||
|
||||
f.HTTPTestClient().GET("/").WithHeader("Host", host).Expect().Status(http.StatusOK)
|
||||
|
||||
ginkgo.By("regenerating the correct configuration after update")
|
||||
annotations["nginx.ingress.kubernetes.io/global-rate-limit-key"] = "${remote_addr}${http_x_api_client}"
|
||||
annotations["nginx.ingress.kubernetes.io/global-rate-limit-ignored-cidrs"] = "192.168.1.1, 234.234.234.0/24"
|
||||
ing.SetAnnotations(annotations)
|
||||
|
||||
f.WaitForReload(func() {
|
||||
ing = f.UpdateIngress(ing)
|
||||
})
|
||||
|
||||
serverConfig = ""
|
||||
f.WaitForNginxServer(host, func(server string) bool {
|
||||
serverConfig = server
|
||||
return true
|
||||
})
|
||||
assert.Contains(ginkgo.GinkgoT(), serverConfig,
|
||||
fmt.Sprintf(`global_throttle = { namespace = "%v", `+
|
||||
`limit = 5, window_size = 120, `+
|
||||
`key = { { nil, "remote_addr", nil, nil, }, { nil, "http_x_api_client", nil, nil, }, }, `+
|
||||
`ignored_cidrs = { "192.168.1.1", "234.234.234.0/24", } }`,
|
||||
namespace))
|
||||
|
||||
f.HTTPTestClient().GET("/").WithHeader("Host", host).Expect().Status(http.StatusOK)
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue