From 8523ad31f8df36ab904b2433a1b7350d7fdd5231 Mon Sep 17 00:00:00 2001 From: Gareth Smith Date: Mon, 27 Nov 2017 17:49:54 +0000 Subject: [PATCH] Start the fixture processes in parallel --- pkg/framework/test/fixtures.go | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/pkg/framework/test/fixtures.go b/pkg/framework/test/fixtures.go index 2220ad94..0c01a6db 100644 --- a/pkg/framework/test/fixtures.go +++ b/pkg/framework/test/fixtures.go @@ -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. @@ -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() } - if err := f.APIServer.Start(); err != nil { - return fmt.Errorf("Error starting apiserver: %s", err) + processes := []FixtureProcess{ + f.Etcd, + f.APIServer, } + + for _, process := range processes { + go starter(process) + } + + for pendingProcesses := len(processes); pendingProcesses > 0; pendingProcesses-- { + if err := <-started; err != nil { + return err + } + } + return nil }