@@ -43,14 +43,37 @@ func TestTerraformIntegration(t *testing.T) {
4343 })
4444}
4545
46+ // TODO: refactor assertions! Ugly!
4647func testSDMGatewayIsOnline (t * testing.T , opts * terraform.Options ) {
4748 gatewayIP := terraform .Output (t , opts , "ec2_instance_public_dns" )
48- cmd := exec .Command ("sdm" , "admin" , "nodes" , "list" , "--filter" , fmt .Sprintf ("listen_addr:%s:5000" , gatewayIP ))
49- output , err := cmd .CombinedOutput ()
50- assert .NoError (t , err , "Failed to execute SDM CLI command" )
5149
52- // Check if the output contains "online"
53- assert .Contains (t , string (output ), "online" , "Gateway should be online" )
50+ maxRetries := 12
51+ retryInterval := 10 * time .Second
52+
53+ var lastErr error
54+ var output []byte
55+
56+ for i := 0 ; i < maxRetries ; i ++ {
57+ cmd := exec .Command ("sdm" , "admin" , "nodes" , "list" , "--filter" , fmt .Sprintf ("listen_addr:%s:5000" , gatewayIP ))
58+ output , lastErr = cmd .CombinedOutput ()
59+
60+ if lastErr == nil && strings .Contains (string (output ), "online" ) {
61+ // Success - gateway is online
62+ return
63+ }
64+
65+ if i < maxRetries - 1 {
66+ t .Logf ("Attempt %d/%d: Gateway not online yet, retrying in %v..." , i + 1 , maxRetries , retryInterval )
67+ time .Sleep (retryInterval )
68+ }
69+ }
70+
71+ // All retries failed
72+ if lastErr != nil {
73+ assert .NoError (t , lastErr , "Failed to execute SDM CLI command after %d retries" , maxRetries )
74+ } else {
75+ assert .Contains (t , string (output ), "online" , "Gateway should be online after %d retries (2 minutes)" , maxRetries )
76+ }
5477}
5578
5679func testGatewayConnection (t * testing.T , opts * terraform.Options ) {
0 commit comments