Skip to content

Commit da0be9c

Browse files
authored
Use assert.Eventually to update HTTPRoute (#7911)
1 parent eae5a24 commit da0be9c

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

test/integration/httproute_test.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -648,13 +648,18 @@ func TestHTTPRouteFilterHosts(t *testing.T) {
648648
require.Error(t, testGetByHost(t, "another2.specific.io"))
649649

650650
t.Logf("update hostname in httproute to an unmatched host")
651-
httpRoute, err = hClient.Get(ctx, httpRoute.Name, metav1.GetOptions{})
652-
require.NoError(t, err)
653-
httpRoute.Spec.Hostnames = []gatewayapi.Hostname{
654-
gatewayapi.Hostname("another.specific.io"),
655-
}
656-
httpRoute, err = hClient.Update(ctx, httpRoute, metav1.UpdateOptions{})
657-
require.NoError(t, err)
651+
require.EventuallyWithT(t, func(c *assert.CollectT) {
652+
httpRoute, err = hClient.Get(ctx, httpRoute.Name, metav1.GetOptions{})
653+
if !assert.NoErrorf(t, err, "failed getting the HTTPRoute %s", httpRoute.Name) {
654+
return
655+
}
656+
httpRoute.Spec.Hostnames = []gatewayapi.Hostname{
657+
gatewayapi.Hostname("another.specific.io"),
658+
}
659+
httpRoute, err = hClient.Update(ctx, httpRoute, metav1.UpdateOptions{})
660+
assert.NoErrorf(c, err, "failed updating the HTTPRoute %s", httpRoute.Name)
661+
}, test.RequestTimeout, 100*time.Millisecond)
662+
658663
t.Logf("status of httproute should contain an 'Accepted' condition with 'False' status")
659664
require.EventuallyWithT(t, func(c *assert.CollectT) {
660665
currentHTTPRoute, err := hClient.Get(ctx, httpRoute.Name, metav1.GetOptions{})

0 commit comments

Comments
 (0)