@@ -306,63 +306,59 @@ func (r *Runner) Clean() error {
306
306
}
307
307
308
308
func (r * Runner ) runK8sInstances (ctx context.Context , instances []StateInstance ) (map [string ]OSRunnerResult , error ) {
309
- g , ctx := errgroup .WithContext (ctx )
310
309
results := make (map [string ]OSRunnerResult )
311
310
var resultsMx sync.Mutex
311
+ var err error
312
312
for _ , instance := range instances {
313
- func (instance StateInstance ) {
314
- g .Go (func () error {
315
- batch , ok := findBatchByID (instance .ID , r .batches )
316
- if ! ok {
317
- return fmt .Errorf ("unable to find batch with ID: %s" , instance .ID )
318
- }
313
+ batch , ok := findBatchByID (instance .ID , r .batches )
314
+ if ! ok {
315
+ err = fmt .Errorf ("unable to find batch with ID: %s" , instance .ID )
316
+ continue
317
+ }
319
318
320
- logger := & batchLogger {wrapped : r .logger , prefix : instance .ID }
321
- // start with the ExtraEnv first preventing the other environment flags below
322
- // from being overwritten
323
- env := map [string ]string {}
324
- for k , v := range r .cfg .ExtraEnv {
325
- env [k ] = v
326
- }
327
- // ensure that we have all the requirements for the stack if required
328
- if batch .Batch .Stack != nil {
329
- // wait for the stack to be ready before continuing
330
- logger .Logf ("Waiting for stack to be ready..." )
331
- stack , err := r .getStackForBatchID (batch .ID )
332
- if err != nil {
333
- return err
334
- }
335
- env ["ELASTICSEARCH_HOST" ] = stack .Elasticsearch
336
- env ["ELASTICSEARCH_USERNAME" ] = stack .Username
337
- env ["ELASTICSEARCH_PASSWORD" ] = stack .Password
338
- env ["KIBANA_HOST" ] = stack .Kibana
339
- env ["KIBANA_USERNAME" ] = stack .Username
340
- env ["KIBANA_PASSWORD" ] = stack .Password
341
- logger .Logf ("Using Stack with Kibana host %s, credentials available under .integration-cache" , stack .Kibana )
342
- }
319
+ logger := & batchLogger {wrapped : r .logger , prefix : instance .ID }
320
+ // start with the ExtraEnv first preventing the other environment flags below
321
+ // from being overwritten
322
+ env := map [string ]string {}
323
+ for k , v := range r .cfg .ExtraEnv {
324
+ env [k ] = v
325
+ }
326
+ // ensure that we have all the requirements for the stack if required
327
+ if batch .Batch .Stack != nil {
328
+ // wait for the stack to be ready before continuing
329
+ logger .Logf ("Waiting for stack to be ready..." )
330
+ stack , stackErr := r .getStackForBatchID (batch .ID )
331
+ if stackErr != nil {
332
+ err = stackErr
333
+ continue
334
+ }
335
+ env ["ELASTICSEARCH_HOST" ] = stack .Elasticsearch
336
+ env ["ELASTICSEARCH_USERNAME" ] = stack .Username
337
+ env ["ELASTICSEARCH_PASSWORD" ] = stack .Password
338
+ env ["KIBANA_HOST" ] = stack .Kibana
339
+ env ["KIBANA_USERNAME" ] = stack .Username
340
+ env ["KIBANA_PASSWORD" ] = stack .Password
341
+ logger .Logf ("Using Stack with Kibana host %s, credentials available under .integration-cache" , stack .Kibana )
342
+ }
343
343
344
- // set the go test flags
345
- env ["GOTEST_FLAGS" ] = r .cfg .TestFlags
346
- env ["KUBECONFIG" ] = instance .Instance .Internal ["config" ].(string )
347
- env ["TEST_BINARY_NAME" ] = r .cfg .BinaryName
348
- env ["AGENT_IMAGE" ] = instance .Instance .Internal ["agent_image" ].(string )
344
+ // set the go test flags
345
+ env ["GOTEST_FLAGS" ] = r .cfg .TestFlags
346
+ env ["KUBECONFIG" ] = instance .Instance .Internal ["config" ].(string )
347
+ env ["TEST_BINARY_NAME" ] = r .cfg .BinaryName
348
+ env ["AGENT_IMAGE" ] = instance .Instance .Internal ["agent_image" ].(string )
349
349
350
- prefix := fmt .Sprintf ("%s-%s" , instance .Instance .Internal ["version" ].(string ), batch .ID )
350
+ prefix := fmt .Sprintf ("%s-%s" , instance .Instance .Internal ["version" ].(string ), batch .ID )
351
351
352
- // run the actual tests on the host
353
- result , err := batch .OS .Runner .Run (ctx , r .cfg .VerboseMode , nil , logger , r .cfg .AgentVersion , prefix , batch .Batch , env )
354
- if err != nil {
355
- logger .Logf ("Failed to execute tests on instance: %s" , err )
356
- return fmt .Errorf ("failed to execute tests on instance %s: %w" , instance .Name , err )
357
- }
358
- resultsMx .Lock ()
359
- results [batch .ID ] = result
360
- resultsMx .Unlock ()
361
- return nil
362
- })
363
- }(instance )
352
+ // run the actual tests on the host
353
+ result , runErr := batch .OS .Runner .Run (ctx , r .cfg .VerboseMode , nil , logger , r .cfg .AgentVersion , prefix , batch .Batch , env )
354
+ if runErr != nil {
355
+ logger .Logf ("Failed to execute tests on instance: %s" , err )
356
+ err = fmt .Errorf ("failed to execute tests on instance %s: %w" , instance .Name , err )
357
+ }
358
+ resultsMx .Lock ()
359
+ results [batch .ID ] = result
360
+ resultsMx .Unlock ()
364
361
}
365
- err := g .Wait ()
366
362
if err != nil {
367
363
return nil , err
368
364
}
0 commit comments