Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion test/e2e/gateway_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func testGatewayAPIResourcesProtection(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
// Verify that GatewayAPI CRD creation is forbidden.
for i := range testCRDs {
if err := wait.PollUntilContextTimeout(context.Background(), 2*time.Second, 30*time.Second, false, func(ctx context.Context) (bool, error) {
if err := wait.PollUntilContextTimeout(context.Background(), 2*time.Second, 60*time.Second, false, func(ctx context.Context) (bool, error) {
if err := tc.kclient.Create(ctx, testCRDs[i]); err != nil {
if kerrors.IsAlreadyExists(err) {
// VAP was disabled and re-enabled at the beginning of the test.
Expand All @@ -391,6 +391,12 @@ func testGatewayAPIResourcesProtection(t *testing.T) {
t.Logf("Failed to create CRD %q: %v; retrying...", testCRDs[i].Name, err)
return false, nil
}
if isNetworkError(err) {
// Retry if the creation of CRD failed due to networking
// problems with the api server.
t.Logf("Failed to create CRD %q due to network error: %v, retrying", testCRDs[i].Name, err)
return false, nil
}
if !strings.Contains(err.Error(), tc.expectedErrMsg) {
return false, fmt.Errorf("unexpected error received while creating CRD %q: %v", testCRDs[i].Name, err)
}
Expand Down
6 changes: 4 additions & 2 deletions test/e2e/util_gatewayapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,9 @@ func assertDNSRecord(t *testing.T, recordName types.NamespacedName) error {
func assertVAP(t *testing.T, name string) error {
t.Helper()
vap := &admissionregistrationv1.ValidatingAdmissionPolicy{}
return wait.PollUntilContextTimeout(context.Background(), 1*time.Second, 1*time.Minute, false, func(context context.Context) (bool, error) {
// Re-creation of VAP can take some time especially after CVO is scaled back up.
// Use a large timeout of 5 minutes to avoid flakes.
return wait.PollUntilContextTimeout(context.Background(), 5*time.Second, 5*time.Minute, false, func(context context.Context) (bool, error) {
if err := kclient.Get(context, types.NamespacedName{Name: name}, vap); err != nil {
t.Logf("failed to get vap %q: %v, retrying...", name, err)
return false, nil
Expand All @@ -1076,7 +1078,7 @@ func scaleDeployment(t *testing.T, namespace, name string, replicas int32) error
t.Helper()

nsName := types.NamespacedName{Namespace: namespace, Name: name}
return wait.PollUntilContextTimeout(context.Background(), 1*time.Second, 30*time.Second, false, func(context context.Context) (bool, error) {
return wait.PollUntilContextTimeout(context.Background(), 2*time.Second, 120*time.Second, false, func(context context.Context) (bool, error) {
depl := &appsv1.Deployment{}
if err := kclient.Get(context, nsName, depl); err != nil {
t.Logf("failed to get deployment %q: %v, retrying...", nsName, err)
Expand Down
14 changes: 14 additions & 0 deletions test/e2e/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"bufio"
"bytes"
"context"
goerrors "errors"
"fmt"
"net"
"net/http"
Expand Down Expand Up @@ -1211,3 +1212,16 @@ func getIngressControllerLBAddress(t *testing.T, ic *operatorv1.IngressControlle
}
return lbAddress
}

func isNetworkError(err error) bool {
var (
netErr net.Error
opErr *net.OpError
msg = err.Error()
)
return goerrors.As(err, &netErr) ||
goerrors.As(err, &opErr) ||
strings.Contains(msg, "connection reset by peer") ||
strings.Contains(msg, "i/o timeout") ||
strings.Contains(msg, "read tcp")
}