Skip to content

Commit 5700896

Browse files
committed
test: fix flaky e2e assertions in standalone mode
In APISIX standalone mode, config application via /apisix/admin/configs is async (returns 202). Two tests asserted HTTP status immediately after config push without retry, causing intermittent 404s: - Basic test: direct assertion on /headers after route update - WebSocket test: direct dial assertion after route creation Replace direct assertions with Eventually retry (20s timeout, 1s interval) to match the pattern used elsewhere in the test suite.
1 parent b1af3da commit 5700896

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

test/e2e/crds/v2/route.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ spec:
141141
applier.MustApplyAPIv2(types.NamespacedName{Namespace: s.Namespace(), Name: "default"},
142142
&apisixRoute, fmt.Sprintf(apisixRouteSpec, s.Namespace(), s.Namespace(), "/headers"))
143143
Eventually(request).WithArguments("/get").WithTimeout(20 * time.Second).ProbeEvery(time.Second).Should(Equal(http.StatusNotFound))
144-
s.NewAPISIXClient().GET("/headers").WithHost("httpbin").Expect().Status(http.StatusOK)
144+
Eventually(request).WithArguments("/headers").WithTimeout(20 * time.Second).ProbeEvery(time.Second).Should(Equal(http.StatusOK))
145145

146146
By("delete ApisixRoute")
147147
err := s.DeleteResource("ApisixRoute", "default")
@@ -1448,9 +1448,14 @@ spec:
14481448
Path: "/echo",
14491449
}
14501450
headers := http.Header{"Host": []string{"httpbin.org"}}
1451-
_, resp, _ := websocket.DefaultDialer.Dial(u.String(), headers)
1452-
// should receive 200 instead of 101
1453-
Expect(resp.StatusCode).Should(Equal(http.StatusOK))
1451+
// In standalone mode, config application is async — retry until the route is active
1452+
Eventually(func() int {
1453+
_, resp, _ := websocket.DefaultDialer.Dial(u.String(), headers)
1454+
if resp == nil {
1455+
return 0
1456+
}
1457+
return resp.StatusCode
1458+
}).WithTimeout(20 * time.Second).ProbeEvery(time.Second).Should(Equal(http.StatusOK))
14541459
By("apply ApisixRoute for WebSocket")
14551460
var apisixRoute apiv2.ApisixRoute
14561461
applier.MustApplyAPIv2(

0 commit comments

Comments
 (0)