Ensure webhook backend requests are not artificially rate-limited

This commit is contained in:
Jordan Liggitt
2019-12-02 11:39:16 -05:00
parent 711790af23
commit d620493b74
3 changed files with 18 additions and 0 deletions

View File

@@ -566,6 +566,9 @@ func testWebhookAdmission(t *testing.T, watchCache bool) {
// Allow the webhook to establish
time.Sleep(time.Second)
start := time.Now()
count := 0
// Test admission on all resources, subresources, and verbs
for _, gvr := range gvrsToTest {
resource := resourcesByGVR[gvr]
@@ -573,6 +576,7 @@ func testWebhookAdmission(t *testing.T, watchCache bool) {
for _, verb := range []string{"create", "update", "patch", "connect", "delete", "deletecollection"} {
if shouldTestResourceVerb(gvr, resource, verb) {
t.Run(verb, func(t *testing.T) {
count++
holder.reset(t)
testFunc := getTestFunc(gvr, verb)
testFunc(&testContext{
@@ -591,6 +595,12 @@ func testWebhookAdmission(t *testing.T, watchCache bool) {
}
})
}
duration := time.Now().Sub(start)
perResourceDuration := time.Duration(int(duration) / count)
if perResourceDuration >= 150*time.Millisecond {
t.Errorf("expected resources to process in < 150ms, average was %v", perResourceDuration)
}
}
//