Add Global Rate Limiting support

This commit is contained in:
Elvin Efendi 2020-12-24 11:39:12 -05:00
parent 14345ebcfe
commit e0dece48f7
21 changed files with 1179 additions and 38 deletions

View file

@ -215,7 +215,8 @@ func (f *Framework) updateIngressNGINXPod() error {
return err
}
// WaitForNginxServer waits until the nginx configuration contains a particular server section
// WaitForNginxServer waits until the nginx configuration contains a particular server section.
// `cfg` passed to matcher is normalized by replacing all tabs and spaces with single space.
func (f *Framework) WaitForNginxServer(name string, matcher func(cfg string) bool) {
err := wait.Poll(Poll, DefaultTimeout, f.matchNginxConditions(name, matcher))
assert.Nil(ginkgo.GinkgoT(), err, "waiting for nginx server condition/s")
@ -223,6 +224,7 @@ func (f *Framework) WaitForNginxServer(name string, matcher func(cfg string) boo
}
// WaitForNginxConfiguration waits until the nginx configuration contains a particular configuration
// `cfg` passed to matcher is normalized by replacing all tabs and spaces with single space.
func (f *Framework) WaitForNginxConfiguration(matcher func(cfg string) bool) {
err := wait.Poll(Poll, DefaultTimeout, f.matchNginxConditions("", matcher))
assert.Nil(ginkgo.GinkgoT(), err, "waiting for nginx server condition/s")
@ -325,7 +327,7 @@ func (f *Framework) SetNginxConfigMapData(cmData map[string]string) {
assert.Nil(ginkgo.GinkgoT(), err, "updating configuration configmap")
}
f.waitForReload(fn)
f.WaitForReload(fn)
}
// CreateConfigMap creates a new configmap in the current namespace
@ -356,10 +358,12 @@ func (f *Framework) UpdateNginxConfigMapData(key string, value string) {
assert.Nil(ginkgo.GinkgoT(), err, "updating configuration configmap")
}
f.waitForReload(fn)
f.WaitForReload(fn)
}
func (f *Framework) waitForReload(fn func()) {
// WaitForReload calls the passed function and
// asser it has caused at least 1 reload.
func (f *Framework) WaitForReload(fn func()) {
initialReloadCount := getReloadCount(f.pod, f.Namespace, f.KubeClientSet)
fn()