mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 13:41:36 +00:00
[unit tests] Cleanly kill all containers before nuking a temporary runtime
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -17,6 +18,15 @@ var unitTestStoreBase string
|
||||
var srv *Server
|
||||
|
||||
func nuke(runtime *Runtime) error {
|
||||
var wg sync.WaitGroup
|
||||
for _, container := range runtime.List() {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
container.Kill()
|
||||
wg.Add(-1)
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
return os.RemoveAll(runtime.root)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user