Skip to content

Commit 356f41c

Browse files
committed
Add route ready check
1 parent b27d14d commit 356f41c

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Directory structure is as follows:
2222
- Docker.
2323
- Golang.
2424

25-
**Note**: all commands in steps below are executed from the ```tests``` directory
25+
**Note**: all commands in steps below are executed from the `tests` directory
2626

2727
```shell
2828
make

tests/framework/resourcemanager.go

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ func (rm *ResourceManager) getFileContents(file string) (*bytes.Buffer, error) {
220220

221221
// WaitForAppsToBeReady waits for all apps in the specified namespace to be ready,
222222
// or until the ctx timeout is reached.
223-
224223
func (rm *ResourceManager) WaitForAppsToBeReady(namespace string) error {
225224
ctx, cancel := context.WithTimeout(context.Background(), rm.TimeoutConfig.CreateTimeout)
226225
defer cancel()
@@ -229,6 +228,10 @@ func (rm *ResourceManager) WaitForAppsToBeReady(namespace string) error {
229228
return err
230229
}
231230

231+
if err := rm.waitForRoutesToBeReady(ctx, namespace); err != nil {
232+
return err
233+
}
234+
232235
return rm.waitForGatewaysToBeReady(ctx, namespace)
233236
}
234237

@@ -252,11 +255,7 @@ func (rm *ResourceManager) waitForPodsToBeReady(ctx context.Context, namespace s
252255
}
253256
}
254257

255-
if podsReady == len(podList.Items) {
256-
return true, nil
257-
}
258-
259-
return false, nil
258+
return podsReady == len(podList.Items), nil
260259
},
261260
)
262261
}
@@ -284,3 +283,31 @@ func (rm *ResourceManager) waitForGatewaysToBeReady(ctx context.Context, namespa
284283
},
285284
)
286285
}
286+
287+
func (rm *ResourceManager) waitForRoutesToBeReady(ctx context.Context, namespace string) error {
288+
return wait.PollUntilContextCancel(
289+
ctx,
290+
500*time.Millisecond,
291+
true, /* poll immediately */
292+
func(ctx context.Context) (bool, error) {
293+
var routeList v1.HTTPRouteList
294+
if err := rm.K8sClient.List(ctx, &routeList, client.InNamespace(namespace)); err != nil {
295+
return false, err
296+
}
297+
298+
var numParents, readyCount int
299+
for _, route := range routeList.Items {
300+
numParents += len(route.Status.Parents)
301+
for _, parent := range route.Status.Parents {
302+
for _, cond := range parent.Conditions {
303+
if cond.Type == string(v1.RouteConditionAccepted) && cond.Status == metav1.ConditionTrue {
304+
readyCount++
305+
}
306+
}
307+
}
308+
}
309+
310+
return numParents == readyCount, nil
311+
},
312+
)
313+
}

0 commit comments

Comments
 (0)