Skip to content

Commit a17c1c8

Browse files
committed
fixup! Add version guards and http.Status constants to shard routing tests
Signed-off-by: Sean Chittenden <sean.chittenden@crowdstrike.com>
1 parent 7c1bc92 commit a17c1c8

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

opensearchtransport/integration_test_helpers_test.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func waitForAllNodesActive(t *testing.T, transport *Client, ctx context.Context,
5252
return false
5353
}
5454

55-
conns := extractActiveConnsFromPolicy(routerPolicy)
55+
conns := collectActiveConns(routerPolicy)
5656
if len(conns) < expectedNodes {
5757
return false
5858
}
@@ -66,6 +66,23 @@ func waitForAllNodesActive(t *testing.T, transport *Client, ctx context.Context,
6666
"expected %d active nodes with names, got fewer after repeated DiscoverNodes", expectedNodes)
6767
}
6868

69+
// collectActiveConns walks the policy tree depth-first and returns the first
70+
// non-empty set of active connections found. Unlike extractActiveConnsFromPolicy,
71+
// this handles poolRouter by recursing into its inner policy via policyTreeWalker.
72+
func collectActiveConns(p Policy) []*Connection {
73+
if conns := extractActiveConnsFromPolicy(p); len(conns) > 0 {
74+
return conns
75+
}
76+
if walker, ok := p.(policyTreeWalker); ok {
77+
for _, child := range walker.childPolicies() {
78+
if conns := collectActiveConns(child); len(conns) > 0 {
79+
return conns
80+
}
81+
}
82+
}
83+
return nil
84+
}
85+
6986
// clusterNodeCount queries /_nodes via the transport and returns the total
7087
// number of nodes reported by the cluster. The transport must already be
7188
// warmed up (able to serve requests) before calling this.

0 commit comments

Comments
 (0)