Skip to content

Commit

Permalink
Start the fixture processes in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
totherme authored and hoegaarden committed Nov 27, 2017
1 parent a0e9df8 commit 6a2d02b
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions pkg/framework/test/fixtures.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package test

import (
"fmt"
)

// Fixtures is a struct that knows how to start all your test fixtures.
//
// Right now, that means Etcd and your APIServer. This is likely to increase in future.
Expand Down Expand Up @@ -39,12 +35,25 @@ func NewFixtures(pathToEtcd, pathToAPIServer string) *Fixtures {

// Start will start all your fixtures. To stop them, call Stop().
func (f *Fixtures) Start() error {
if err := f.Etcd.Start(); err != nil {
return fmt.Errorf("Error starting etcd: %s", err)
started := make(chan error)
starter := func(process FixtureProcess) {
started <- process.Start()
}
processes := []FixtureProcess{
f.Etcd,
f.APIServer,
}

for _, process := range processes {
go starter(process)
}
if err := f.APIServer.Start(); err != nil {
return fmt.Errorf("Error starting apiserver: %s", err)

for pendingProcesses := len(processes); pendingProcesses > 0; pendingProcesses-- {
if err := <-started; err != nil {
return err
}
}

return nil
}

Expand Down

0 comments on commit 6a2d02b

Please sign in to comment.