@@ -47,6 +47,21 @@ type GlobalAcceleratorExpectation struct {
4747 Listeners []ListenerExpectation
4848}
4949
50+ func matchesListener (listener * types.Listener , expected ListenerExpectation ) bool {
51+ if expected .Protocol != "" && string (listener .Protocol ) != expected .Protocol {
52+ return false
53+ }
54+ if len (expected .PortRanges ) > 0 {
55+ if len (listener .PortRanges ) == 0 {
56+ return false
57+ }
58+ if awssdk .ToInt32 (listener .PortRanges [0 ].FromPort ) != expected .PortRanges [0 ].FromPort {
59+ return false
60+ }
61+ }
62+ return true
63+ }
64+
5065func verifyGlobalAcceleratorConfiguration (ctx context.Context , f * framework.Framework , acceleratorARN string , expected GlobalAcceleratorExpectation ) error {
5166 agaClient := f .Cloud .GlobalAccelerator ()
5267
@@ -79,8 +94,25 @@ func verifyGlobalAcceleratorConfiguration(ctx context.Context, f *framework.Fram
7994 return fmt .Errorf ("listener count mismatch: expected %d, got %d" , len (expected .Listeners ), len (listListenersResp .Listeners ))
8095 }
8196
97+ // Verify each expected listener exists (order-independent)
98+ matched := make (map [int ]bool )
8299 for i , expectedListener := range expected .Listeners {
83- listener := listListenersResp .Listeners [i ]
100+ var listener * types.Listener
101+ var matchedIdx int
102+ for j := range listListenersResp .Listeners {
103+ if ! matched [j ] && matchesListener (& listListenersResp .Listeners [j ], expectedListener ) {
104+ listener = & listListenersResp .Listeners [j ]
105+ matchedIdx = j
106+ break
107+ }
108+ }
109+ if listener == nil {
110+ if len (expectedListener .PortRanges ) > 0 {
111+ return fmt .Errorf ("expected listener[%d] with port %d not found" , i , expectedListener .PortRanges [0 ].FromPort )
112+ }
113+ return fmt .Errorf ("expected listener[%d] not found" , i )
114+ }
115+ matched [matchedIdx ] = true
84116
85117 if expectedListener .Protocol != "" && string (listener .Protocol ) != expectedListener .Protocol {
86118 return fmt .Errorf ("listener[%d] protocol mismatch: expected %s, got %s" , i , expectedListener .Protocol , string (listener .Protocol ))
0 commit comments