Skip to content

Commit 2f50621

Browse files
authored
Shutdown integration scenario faster (#7256)
Signed-off-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com>
1 parent 246fab9 commit 2f50621

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

integration/e2e/scenario.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66
"strings"
7+
"sync"
78

89
"github.com/pkg/errors"
910
)
@@ -147,12 +148,19 @@ func (s *Scenario) clean() {
147148
}
148149

149150
func (s *Scenario) shutdown() {
150-
// Kill the services in the opposite order.
151+
// Kill the services in parallel. We still iterate in reverse order
152+
// to respect service dependencies, but we kill them concurrently.
153+
var wg sync.WaitGroup
151154
for i := len(s.services) - 1; i >= 0; i-- {
152-
if err := s.services[i].Kill(); err != nil {
153-
logger.Log("Unable to kill service", s.services[i].Name(), ":", err.Error())
154-
}
155+
wg.Add(1)
156+
go func(service Service) {
157+
defer wg.Done()
158+
if err := service.Kill(); err != nil {
159+
logger.Log("Unable to kill service", service.Name(), ":", err.Error())
160+
}
161+
}(s.services[i])
155162
}
163+
wg.Wait()
156164

157165
// Ensure there are no leftover containers.
158166
if out, err := RunCommandAndGetOutput(

0 commit comments

Comments
 (0)