diff --git a/integration/build/build_test.go b/integration/build/build_test.go index 5a23371bdc..b04cbbf205 100644 --- a/integration/build/build_test.go +++ b/integration/build/build_test.go @@ -17,6 +17,7 @@ import ( ) func TestBuildWithRemoveAndForceRemove(t *testing.T) { + defer setupTest(t)() t.Parallel() cases := []struct { name string diff --git a/integration/build/main_test.go b/integration/build/main_test.go index 007f2d98e5..113766a73a 100644 --- a/integration/build/main_test.go +++ b/integration/build/main_test.go @@ -17,6 +17,11 @@ func TestMain(m *testing.M) { fmt.Println(err) os.Exit(1) } + err = environment.EnsureFrozenImagesLinux(testEnv) + if err != nil { + fmt.Println(err) + os.Exit(1) + } testEnv.Print() os.Exit(m.Run()) diff --git a/integration/container/main_test.go b/integration/container/main_test.go index fbfed2ae40..9854004a10 100644 --- a/integration/container/main_test.go +++ b/integration/container/main_test.go @@ -17,6 +17,11 @@ func TestMain(m *testing.M) { fmt.Println(err) os.Exit(1) } + err = environment.EnsureFrozenImagesLinux(testEnv) + if err != nil { + fmt.Println(err) + os.Exit(1) + } testEnv.Print() os.Exit(m.Run()) diff --git a/integration/network/main_test.go b/integration/network/main_test.go index fffe37dcc4..9729c3e927 100644 --- a/integration/network/main_test.go +++ b/integration/network/main_test.go @@ -17,6 +17,11 @@ func TestMain(m *testing.M) { fmt.Println(err) os.Exit(1) } + err = environment.EnsureFrozenImagesLinux(testEnv) + if err != nil { + fmt.Println(err) + os.Exit(1) + } testEnv.Print() os.Exit(m.Run()) diff --git a/integration/plugin/authz/main_test.go b/integration/plugin/authz/main_test.go index da1799ea1b..0ecf66cde6 100644 --- a/integration/plugin/authz/main_test.go +++ b/integration/plugin/authz/main_test.go @@ -33,6 +33,11 @@ func TestMain(m *testing.M) { fmt.Println(err) os.Exit(1) } + err = environment.EnsureFrozenImagesLinux(testEnv) + if err != nil { + fmt.Println(err) + os.Exit(1) + } testEnv.Print() setupSuite() diff --git a/integration/service/main_test.go b/integration/service/main_test.go index 4cad6ed975..6dfb6b986c 100644 --- a/integration/service/main_test.go +++ b/integration/service/main_test.go @@ -19,6 +19,11 @@ func TestMain(m *testing.M) { fmt.Println(err) os.Exit(1) } + err = environment.EnsureFrozenImagesLinux(testEnv) + if err != nil { + fmt.Println(err) + os.Exit(1) + } testEnv.Print() os.Exit(m.Run()) diff --git a/integration/system/main_test.go b/integration/system/main_test.go index 575bbc166d..aa332c91fb 100644 --- a/integration/system/main_test.go +++ b/integration/system/main_test.go @@ -17,6 +17,11 @@ func TestMain(m *testing.M) { fmt.Println(err) os.Exit(1) } + err = environment.EnsureFrozenImagesLinux(testEnv) + if err != nil { + fmt.Println(err) + os.Exit(1) + } testEnv.Print() os.Exit(m.Run()) diff --git a/internal/test/environment/environment.go b/internal/test/environment/environment.go index eba92b2b31..fb927271f3 100644 --- a/internal/test/environment/environment.go +++ b/internal/test/environment/environment.go @@ -8,6 +8,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/client" + "github.com/docker/docker/integration-cli/fixtures/load" "github.com/pkg/errors" "golang.org/x/net/context" ) @@ -128,3 +129,15 @@ func (e *Execution) Print() { func (e *Execution) APIClient() client.APIClient { return e.client } + +// EnsureFrozenImagesLinux loads frozen test images into the daemon +// if they aren't already loaded +func EnsureFrozenImagesLinux(testEnv *Execution) error { + if testEnv.OSType == "linux" { + err := load.FrozenImagesLinux(testEnv.APIClient(), frozenImages...) + if err != nil { + return errors.Wrap(err, "error loading frozen images") + } + } + return nil +} diff --git a/internal/test/environment/protect.go b/internal/test/environment/protect.go index 296ae73789..7885f80fd8 100644 --- a/internal/test/environment/protect.go +++ b/internal/test/environment/protect.go @@ -6,10 +6,11 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" dclient "github.com/docker/docker/client" - "github.com/docker/docker/integration-cli/fixtures/load" "github.com/stretchr/testify/require" ) +var frozenImages = []string{"busybox:latest", "hello-world:frozen", "debian:jessie"} + type protectedElements struct { containers map[string]struct{} images map[string]struct{} @@ -83,7 +84,7 @@ func ProtectImages(t testingT, testEnv *Execution) { images := getExistingImages(t, testEnv) if testEnv.OSType == "linux" { - images = append(images, ensureFrozenImagesLinux(t, testEnv)...) + images = append(images, frozenImages...) } testEnv.ProtectImage(t, images...) } @@ -120,15 +121,6 @@ func tagsFromImageSummary(image types.ImageSummary) []string { return result } -func ensureFrozenImagesLinux(t testingT, testEnv *Execution) []string { - images := []string{"busybox:latest", "hello-world:frozen", "debian:jessie"} - err := load.FrozenImagesLinux(testEnv.APIClient(), images...) - if err != nil { - t.Fatalf("Failed to load frozen images: %s", err) - } - return images -} - // ProtectNetwork adds the specified network(s) to be protected in case of // clean func (e *Execution) ProtectNetwork(t testingT, networks ...string) {