Skip to content

Commit 6007467

Browse files
committed
NE-2097: e2e - Add assertCatalogSourceWithConfig helper
1 parent 1c4170b commit 6007467

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/e2e/util_gatewayapi_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,11 +1085,18 @@ func getHTTPResponse(client *http.Client, name string) (int, http.Header, string
10851085
// assertCatalogSource checks if the CatalogSource of the given name exists,
10861086
// and returns an error if not.
10871087
func assertCatalogSource(t *testing.T, namespace, csName string) error {
1088+
return assertCatalogSourceWithConfig(t, namespace, csName, 1*time.Second, 30*time.Second)
1089+
}
1090+
1091+
// assertCatalogSourceWithConfig checks if the CatalogSource of the given name exists,
1092+
// and returns an error if not. It uses configurable parameters such as polling interval
1093+
// and timeout.
1094+
func assertCatalogSourceWithConfig(t *testing.T, namespace, csName string, interval, timeout time.Duration) error {
10881095
t.Helper()
10891096
catalogSource := &operatorsv1alpha1.CatalogSource{}
10901097
nsName := types.NamespacedName{Namespace: namespace, Name: csName}
10911098

1092-
err := wait.PollUntilContextTimeout(context.Background(), 1*time.Second, 30*time.Second, false, func(context context.Context) (bool, error) {
1099+
return wait.PollUntilContextTimeout(context.Background(), interval, timeout, false, func(context context.Context) (bool, error) {
10931100
if err := kclient.Get(context, nsName, catalogSource); err != nil {
10941101
t.Logf("Failed to get CatalogSource %s: %v. Retrying...", csName, err)
10951102
return false, nil
@@ -1101,7 +1108,6 @@ func assertCatalogSource(t *testing.T, namespace, csName string) error {
11011108
t.Logf("Found CatalogSource %s but could not determine last observed state. Retrying...", catalogSource.Name)
11021109
return false, nil
11031110
})
1104-
return err
11051111
}
11061112

11071113
// assertIstio checks if the Istio exists in a ready state,

0 commit comments

Comments
 (0)