@@ -84,23 +84,21 @@ func BuildTestRunners(cfg config.Config, opt TestRunnerOptions) (TestRunners, er
84
84
}
85
85
86
86
infra := make (map [string ][]config.ServiceConfig )
87
- infraComposeFiles := make ([]string , 0 , len (cfg .Infrastructure )+ len (t .Infrastructure ))
88
87
for k , v := range cfg .Infrastructure {
89
88
infra [k ] = append (infra [k ], v )
90
- infraComposeFiles = append (infraComposeFiles , collectDockerComposeFiles (v )... )
91
89
}
92
90
for k , v := range t .Infrastructure {
93
91
infra [k ] = append (infra [k ], v )
94
- infraComposeFiles = append (infraComposeFiles , collectDockerComposeFiles (v )... )
95
92
}
96
93
97
- var infraContainers [] string
98
- if len ( infra ) > 0 {
99
- var err error
100
- infraContainers , err = findContainerNames (context .Background (), infraComposeFiles )
94
+ infraContainers := make ( map [ string ][] string )
95
+ for k , v := range infra {
96
+ f := collectDockerComposeFiles ( v ... )
97
+ containers , err : = findContainerNames (context .Background (), f )
101
98
if err != nil {
102
- return nil , fmt .Errorf ("failed to find infrastructure container names: %w" , err )
99
+ return nil , fmt .Errorf ("failed to find infrastructure container names for %s : %w" , k , err )
103
100
}
101
+ infraContainers [k ] = containers
104
102
}
105
103
106
104
toolNames := slices .Collect (maps .Keys (cfg .Tools ))
@@ -370,7 +368,7 @@ type TestRunner struct {
370
368
tools []config.ServiceConfig
371
369
collectors []metrics.Collector
372
370
373
- infrastructureContainers []string
371
+ infrastructureContainers map [ string ] []string
374
372
toolContainers []string
375
373
376
374
name string
@@ -422,7 +420,13 @@ func (r *TestRunner) Infrastructure() map[string][]config.ServiceConfig {
422
420
}
423
421
424
422
func (r * TestRunner ) InfrastructureContainers () []string {
425
- return r .infrastructureContainers
423
+ return fold (
424
+ maps .Values (r .infrastructureContainers ),
425
+ nil ,
426
+ func (result []string , containers []string ) []string {
427
+ return append (result , containers ... )
428
+ },
429
+ )
426
430
}
427
431
428
432
func (r * TestRunner ) Tools () []config.ServiceConfig {
@@ -565,11 +569,7 @@ func (r *TestRunner) runInfrastructure(ctx context.Context) (err error) {
565
569
paths := collectDockerComposeFiles (infraConfigs ... )
566
570
567
571
logger .Info ("Running infrastructure" , "name" , k , "log-path" , logPath )
568
- containers , err := findContainerNames (ctx , paths )
569
- if err != nil {
570
- return fmt .Errorf ("failed finding container names for paths %v: %w" , paths , err )
571
- }
572
- err = r .dockerComposeUpWait (ctx , logger , paths , containers , logPath )
572
+ err = r .dockerComposeUpWait (ctx , logger , paths , r .infrastructureContainers [k ], logPath )
573
573
if err != nil {
574
574
return fmt .Errorf ("failed to start infrastructure: %w" , err )
575
575
}
0 commit comments