Skip to content

Commit 502efee

Browse files
committed
Check listeners conditions serially
1 parent 8cf18e3 commit 502efee

File tree

2 files changed

+39
-49
lines changed

2 files changed

+39
-49
lines changed

conformance/utils/config/timeout.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ type TimeoutConfig struct {
4444
// Max value for conformant implementation: None
4545
GatewayStatusMustHaveListeners time.Duration
4646

47-
// GatewayListenersMustHaveCondition represents the maximum time for a Gateway to have all listeners with a specific condition.
47+
// GatewayListenersMustHaveConditions represents the maximum time for a Gateway to have all listeners with a specific condition.
4848
// Max value for conformant implementation: None
49-
GatewayListenersMustHaveCondition time.Duration
49+
GatewayListenersMustHaveConditions time.Duration
5050

5151
// GWCMustBeAccepted represents the maximum time for a GatewayClass to have an Accepted condition set to true.
5252
// Max value for conformant implementation: None
@@ -100,24 +100,24 @@ type TimeoutConfig struct {
100100
// DefaultTimeoutConfig populates a TimeoutConfig with the default values.
101101
func DefaultTimeoutConfig() TimeoutConfig {
102102
return TimeoutConfig{
103-
CreateTimeout: 60 * time.Second,
104-
DeleteTimeout: 10 * time.Second,
105-
GetTimeout: 10 * time.Second,
106-
GatewayMustHaveAddress: 180 * time.Second,
107-
GatewayMustHaveCondition: 180 * time.Second,
108-
GatewayStatusMustHaveListeners: 60 * time.Second,
109-
GatewayListenersMustHaveCondition: 60 * time.Second,
110-
GWCMustBeAccepted: 180 * time.Second,
111-
HTTPRouteMustNotHaveParents: 60 * time.Second,
112-
HTTPRouteMustHaveCondition: 60 * time.Second,
113-
TLSRouteMustHaveCondition: 60 * time.Second,
114-
RouteMustHaveParents: 60 * time.Second,
115-
ManifestFetchTimeout: 10 * time.Second,
116-
MaxTimeToConsistency: 30 * time.Second,
117-
NamespacesMustBeReady: 300 * time.Second,
118-
RequestTimeout: 10 * time.Second,
119-
LatestObservedGenerationSet: 60 * time.Second,
120-
RequiredConsecutiveSuccesses: 3,
103+
CreateTimeout: 60 * time.Second,
104+
DeleteTimeout: 10 * time.Second,
105+
GetTimeout: 10 * time.Second,
106+
GatewayMustHaveAddress: 180 * time.Second,
107+
GatewayMustHaveCondition: 180 * time.Second,
108+
GatewayStatusMustHaveListeners: 60 * time.Second,
109+
GatewayListenersMustHaveConditions: 60 * time.Second,
110+
GWCMustBeAccepted: 180 * time.Second,
111+
HTTPRouteMustNotHaveParents: 60 * time.Second,
112+
HTTPRouteMustHaveCondition: 60 * time.Second,
113+
TLSRouteMustHaveCondition: 60 * time.Second,
114+
RouteMustHaveParents: 60 * time.Second,
115+
ManifestFetchTimeout: 10 * time.Second,
116+
MaxTimeToConsistency: 30 * time.Second,
117+
NamespacesMustBeReady: 300 * time.Second,
118+
RequestTimeout: 10 * time.Second,
119+
LatestObservedGenerationSet: 60 * time.Second,
120+
RequiredConsecutiveSuccesses: 3,
121121
}
122122
}
123123

@@ -141,8 +141,8 @@ func SetupTimeoutConfig(timeoutConfig *TimeoutConfig) {
141141
if timeoutConfig.GatewayStatusMustHaveListeners == 0 {
142142
timeoutConfig.GatewayStatusMustHaveListeners = defaultTimeoutConfig.GatewayStatusMustHaveListeners
143143
}
144-
if timeoutConfig.GatewayListenersMustHaveCondition == 0 {
145-
timeoutConfig.GatewayListenersMustHaveCondition = defaultTimeoutConfig.GatewayListenersMustHaveCondition
144+
if timeoutConfig.GatewayListenersMustHaveConditions == 0 {
145+
timeoutConfig.GatewayListenersMustHaveConditions = defaultTimeoutConfig.GatewayListenersMustHaveConditions
146146
}
147147
if timeoutConfig.GWCMustBeAccepted == 0 {
148148
timeoutConfig.GWCMustBeAccepted = defaultTimeoutConfig.GWCMustBeAccepted

conformance/utils/kubernetes/helpers.go

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"reflect"
2525
"strconv"
2626
"strings"
27-
"sync"
2827
"testing"
2928
"time"
3029

@@ -72,12 +71,12 @@ func NewGatewayRef(nn types.NamespacedName, listenerNames ...string) GatewayRef
7271
}
7372
}
7473

75-
// GWCMustBeAcceptedConditionTrue waits until the specified GatewayClass has an Accepted condition set with a status value equal to True.
74+
// GWCMustHaveAcceptedConditionTrue waits until the specified GatewayClass has an Accepted condition set with a status value equal to True.
7675
func GWCMustHaveAcceptedConditionTrue(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, gwcName string) string {
7776
return gwcMustBeAccepted(t, c, timeoutConfig, gwcName, string(metav1.ConditionTrue))
7877
}
7978

80-
// GWCMustBeAcceptedConditionAny waits until the specified GatewayClass has an Accepted condition set with a status set to any value.
79+
// GWCMustHaveAcceptedConditionAny waits until the specified GatewayClass has an Accepted condition set with a status set to any value.
8180
func GWCMustHaveAcceptedConditionAny(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, gwcName string) string {
8281
return gwcMustBeAccepted(t, c, timeoutConfig, gwcName, "")
8382
}
@@ -429,34 +428,25 @@ func WaitForGatewayAddress(t *testing.T, client client.Client, timeoutConfig con
429428
func GatewayListenersMustHaveConditions(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, gwName types.NamespacedName, conditions []metav1.Condition) {
430429
t.Helper()
431430

432-
var wg sync.WaitGroup
433-
wg.Add(len(conditions))
434-
435-
for _, condition := range conditions {
436-
go func(condition metav1.Condition) {
437-
defer wg.Done()
438-
439-
waitErr := wait.PollUntilContextTimeout(context.Background(), 1*time.Second, timeoutConfig.GatewayListenersMustHaveCondition, true, func(ctx context.Context) (bool, error) {
440-
var gw gatewayv1.Gateway
441-
if err := client.Get(ctx, gwName, &gw); err != nil {
442-
return false, fmt.Errorf("error fetching Gateway: %w", err)
443-
}
431+
waitErr := wait.PollUntilContextTimeout(context.Background(), 1*time.Second, timeoutConfig.GatewayListenersMustHaveConditions, true, func(ctx context.Context) (bool, error) {
432+
var gw gatewayv1.Gateway
433+
if err := client.Get(ctx, gwName, &gw); err != nil {
434+
return false, fmt.Errorf("error fetching Gateway: %w", err)
435+
}
444436

445-
for _, listener := range gw.Status.Listeners {
446-
if !findConditionInList(t, listener.Conditions, condition.Type, string(condition.Status), condition.Reason) {
447-
return false, nil
448-
}
437+
for _, condition := range conditions {
438+
for _, listener := range gw.Status.Listeners {
439+
if !findConditionInList(t, listener.Conditions, condition.Type, string(condition.Status), condition.Reason) {
440+
t.Logf("gateway %s doesn't have %s condition set to %s on %s listener", gwName, condition.Type, condition.Status, listener.Name)
441+
return false, nil
449442
}
443+
}
444+
}
450445

451-
return true, nil
452-
})
453-
454-
require.NoErrorf(t, waitErr, "error waiting for Gateway status to have the %s condition set to %s on all listeners",
455-
condition.Type, condition.Status)
456-
}(condition)
457-
}
446+
return true, nil
447+
})
458448

459-
wg.Wait()
449+
require.NoErrorf(t, waitErr, "error waiting for Gateway status to have conditions matching expectations on all listeners")
460450
}
461451

462452
// GatewayMustHaveZeroRoutes validates that the gateway has zero routes attached. The status

0 commit comments

Comments
 (0)