Fixes #2308 TestSpoofingClient_WaitForEndpointState flake (#2387)

This commit is contained in:
Dave Protasowski 2022-01-12 02:42:50 -05:00 committed by GitHub
parent b90b853c52
commit c568527ffc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 6 deletions

View File

@ -24,6 +24,7 @@ import (
"fmt"
"net/http"
"net/url"
"time"
"testing"
@ -111,7 +112,7 @@ func TestSpoofingClient_CheckEndpointState(t *testing.T) {
Client: &http.Client{Transport: tt.transport},
Logf: t.Logf,
RequestInterval: 1,
RequestTimeout: 1,
RequestTimeout: time.Second,
}
url := &url.URL{
Host: "fake.knative.net",
@ -155,10 +156,15 @@ func TestSpoofingClient_WaitForEndpointState(t *testing.T) {
}, {
name: "Non matching response triggers more requests",
transport: &fakeTransport{response: successResponse},
inState: func(resp *Response) (done bool, err error) {
return false, nil
},
wantErr: true,
inState: func() ResponseChecker {
var calls atomic.Int32
return func(resp *Response) (done bool, err error) {
val := calls.Inc()
// Stop the looping on the third invocation
return val == 3, nil
}
}(),
wantErr: false,
wantCalls: 3,
}, {
name: "Retriable error is retried",
@ -183,7 +189,7 @@ func TestSpoofingClient_WaitForEndpointState(t *testing.T) {
Client: &http.Client{Transport: tt.transport},
Logf: t.Logf,
RequestInterval: 1,
RequestTimeout: 1,
RequestTimeout: time.Second,
}
url := &url.URL{
Host: "fake.knative.net",