Skip to content

Commit f876707

Browse files
author
Foo Bar
committed
test(e2e): poll for upstream count in multiple-backends route test
The 'ApisixRoute with multiple backends' spec asserted the data-plane upstream count exactly once, immediately after applying the route. The controller syncs the four upstreams asynchronously, so the single check can race and observe fewer (seen as 3 != 4 under load). Wrap it in a polling assertion so it waits for eventual consistency.
1 parent dc63f19 commit f876707

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

test/e2e/crds/v2/route.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,9 +2201,19 @@ spec:
22012201
&apiv2.ApisixRoute{}, fmt.Sprintf(apisixRouteSpec, s.Namespace()))
22022202

22032203
By("check upstreams")
2204-
upstreams, err := s.DefaultDataplaneResource().Upstream().List(context.Background())
2205-
Expect(err).ShouldNot(HaveOccurred())
2206-
Expect(upstreams).Should(HaveLen(4))
2204+
// Poll instead of asserting once: the controller syncs the four
2205+
// upstreams to the data plane asynchronously after the ApisixRoute is
2206+
// applied, so a single immediate check can race and observe fewer.
2207+
s.RetryAssertion(func() error {
2208+
upstreams, err := s.DefaultDataplaneResource().Upstream().List(context.Background())
2209+
if err != nil {
2210+
return err
2211+
}
2212+
if len(upstreams) != 4 {
2213+
return fmt.Errorf("expected 4 upstreams, got %d", len(upstreams))
2214+
}
2215+
return nil
2216+
}).ShouldNot(HaveOccurred(), "waiting for 4 upstreams to be synced")
22072217

22082218
By("verify ApisixRoute works")
22092219
s.RequestAssert(&scaffold.RequestAssert{

0 commit comments

Comments
 (0)