Skip to content
Closed
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
5 changes: 5 additions & 0 deletions test/e2e_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ type ServingEnvironmentFlags struct {
ResolvableDomain bool // Resolve Route controller's `domainSuffix`
Https bool // Indicates where the test service will be created with https
IngressClass string // Indicates the class of Ingress provider to test.
// Indicates how many consecutive requests sent against the ingress should be
// successful before claiming the Ingress ready.
IngressRetries int
CertificateClass string // Indicates the class of Certificate provider to test.
SystemNamespace string // Indicates the system namespace, in which Knative Serving is installed.
}
Expand All @@ -48,6 +51,8 @@ func initializeServingFlags() *ServingEnvironmentFlags {

flag.StringVar(&f.IngressClass, "ingressClass", network.IstioIngressClassName,
"Set this flag to the ingress class to test against.")
flag.IntVar(&f.IngressRetries, "ingressRetries", 0,
"Set this flag to a positive number to enforce retrying ingress consistency in tests.")
flag.StringVar(&f.CertificateClass, "certificateClass", network.CertManagerCertificateClassName,
"Set this flag to the certificate class to test against.")

Expand Down
16 changes: 14 additions & 2 deletions test/v1/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,22 @@ func IsRouteNotReady(r *v1.Route) (bool, error) {
return !r.Status.IsReady(), nil
}

// RetryingRouteInconsistency retries common requests seen when creating a new route
// RetryingRouteInconsistency conditionally retries common requests seen when creating a new route.
func RetryingRouteInconsistency(innerCheck spoof.ResponseChecker) spoof.ResponseChecker {
if test.ServingFlags.IngressRetries > 0 {
var successes int
return func(resp *spoof.Response) (bool, error) {
success, err := innerCheck(resp)
if !success {
successes = 0
return false, err
}
successes++
return successes == test.ServingFlags.IngressRetries, err
}
}
// By default only wrap the innerCheck.
return func(resp *spoof.Response) (bool, error) {
// If we didn't match any retryable codes, invoke the ResponseChecker that we wrapped.
return innerCheck(resp)
}
}
Expand Down
17 changes: 14 additions & 3 deletions test/v1alpha1/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,22 @@ func CreateRoute(t pkgTest.T, clients *test.Clients, names test.ResourceNames, f
return clients.ServingAlphaClient.Routes.Create(route)
}

// RetryingRouteInconsistency retries common requests seen when creating a new route
// TODO(5573): Remove this.
// RetryingRouteInconsistency conditionally retries common requests seen when creating a new route.
func RetryingRouteInconsistency(innerCheck spoof.ResponseChecker) spoof.ResponseChecker {
if test.ServingFlags.IngressRetries > 0 {
var successes int
return func(resp *spoof.Response) (bool, error) {
success, err := innerCheck(resp)
if !success {
successes = 0
return false, err
}
successes++
return successes == test.ServingFlags.IngressRetries, err
}
}
// By default only wrap the innerCheck.
return func(resp *spoof.Response) (bool, error) {
// If we didn't match any retryable codes, invoke the ResponseChecker that we wrapped.
return innerCheck(resp)
}
}
Expand Down
16 changes: 14 additions & 2 deletions test/v1beta1/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,22 @@ func IsRouteFailed(r *v1beta1.Route) (bool, error) {
return r.IsFailed(), nil
}

// RetryingRouteInconsistency retries common requests seen when creating a new route
// RetryingRouteInconsistency conditionally retries common requests seen when creating a new route.
func RetryingRouteInconsistency(innerCheck spoof.ResponseChecker) spoof.ResponseChecker {
if test.ServingFlags.IngressRetries > 0 {
var successes int
return func(resp *spoof.Response) (bool, error) {
success, err := innerCheck(resp)
if !success {
successes = 0
return false, err
}
successes++
return successes == test.ServingFlags.IngressRetries, err
}
}
// By default only wrap the innerCheck.
return func(resp *spoof.Response) (bool, error) {
// If we didn't match any retryable codes, invoke the ResponseChecker that we wrapped.
return innerCheck(resp)
}
}
Expand Down