Skip to content

Commit

Permalink
AwaitConvergence
Browse files Browse the repository at this point in the history
Signed-off-by: zirain <zirain2009@gmail.com>
  • Loading branch information
zirain committed Feb 27, 2024
1 parent bb801ca commit 2a378f3
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions test/e2e/tests/client-timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import (
"net/http"
"net/url"
"testing"
"time"

"github.com/stretchr/testify/assert"
"k8s.io/apimachinery/pkg/types"
httputils "sigs.k8s.io/gateway-api/conformance/utils/http"
"sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
"sigs.k8s.io/gateway-api/conformance/utils/suite"
)
Expand Down Expand Up @@ -46,16 +47,20 @@ var ClientTimeoutTest = suite.ConformanceTest{
}

client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer func() {
_ = resp.Body.Close()
}()

// return 408 instead of 400 when request timeout.
assert.Equal(t, http.StatusRequestTimeout, resp.StatusCode)
httputils.AwaitConvergence(t,
suite.TimeoutConfig.RequiredConsecutiveSuccesses,
suite.TimeoutConfig.MaxTimeToConsistency,
func(_ time.Duration) bool {
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()

// return 408 instead of 400 when request timeout.
return http.StatusRequestTimeout == resp.StatusCode
})

})
},
Expand Down

0 comments on commit 2a378f3

Please sign in to comment.