[integration] ensure frozen images are loaded
Ensures that the frozen test images are loaded in the daemon before any tests are run. Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com>
This commit is contained in:
parent
ab0eb8fcf6
commit
58151358c0
9 changed files with 47 additions and 11 deletions
|
@ -17,6 +17,7 @@ import (
|
|||
)
|
||||
|
||||
func TestBuildWithRemoveAndForceRemove(t *testing.T) {
|
||||
defer setupTest(t)()
|
||||
t.Parallel()
|
||||
cases := []struct {
|
||||
name string
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue