@@ -57,21 +57,19 @@ func buildAigwOnDemand() (string, error) {
5757}
5858
5959// startAIGWCLI starts the aigw CLI as a subprocess with the given config file.
60- func startAIGWCLI (t * testing.T , aigwBin string , arg ... string ) {
61- // aigw has many fixed ports, some are in the envoy subprocess, such as
62- // Envoy's gateway port, and its adminPort if in yaml configuration.
60+ func startAIGWCLI (t * testing.T , aigwBin string , env []string , arg ... string ) {
61+ // aigw has many fixed ports: some are in the envoy subprocess
6362 gatewayPort := 1975
64- envoyAdminPort := 9901
6563
6664 // Wait up to 10 seconds for both ports to be free.
6765 ctx , cancel := context .WithTimeout (t .Context (), 10 * time .Second )
6866 defer cancel ()
6967
70- for isPortInUse (ctx , gatewayPort ) || isPortInUse ( ctx , envoyAdminPort ) {
68+ for isPortInUse (ctx , gatewayPort ) {
7169 select {
7270 case <- ctx .Done ():
7371 require .FailNow (t , "Ports still in use after timeout" ,
74- "Ports %d and/or %d are still in use" , gatewayPort , envoyAdminPort )
72+ "Port %d is still in use" , gatewayPort )
7573 case <- time .After (500 * time .Millisecond ):
7674 // Retry after a short delay.
7775 }
@@ -92,6 +90,7 @@ func startAIGWCLI(t *testing.T, aigwBin string, arg ...string) {
9290 cmd := exec .CommandContext (cmdCtx , aigwBin , arg ... )
9391 cmd .Stdout = buffers [0 ]
9492 cmd .Stderr = buffers [1 ]
93+ cmd .Env = append (os .Environ (), env ... )
9594 cmd .WaitDelay = 3 * time .Second // auto-kill after 3 seconds.
9695
9796 require .NoError (t , cmd .Start ())
@@ -120,10 +119,10 @@ func startAIGWCLI(t *testing.T, aigwBin string, arg ...string) {
120119 t .Logf ("aigw process started with PID %d" , cmd .Process .Pid )
121120
122121 // Wait for health check using RequireEventuallyNoError.
123- t .Log ("Waiting for aigw to start (Envoy admin endpoint)..." )
124- envoyAdmin , err := aigw .NewEnvoyAdminClient (t .Context (), 1 , envoyAdminPort )
122+ envoyAdmin , err := aigw .NewEnvoyAdminClient (t .Context (), cmd .Process .Pid , 0 )
125123 require .NoError (t , err )
126124
125+ t .Logf ("Waiting for aigw to start (admin port %d)..." , envoyAdmin .Port ())
127126 internaltesting .RequireEventuallyNoError (t , func () error {
128127 return envoyAdmin .IsReady (t .Context ())
129128 }, 180 * time .Second , 2 * time .Second ,
0 commit comments