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>
| ... | ... |
@@ -8,6 +8,7 @@ import ( |
| 8 | 8 |
|
| 9 | 9 |
"github.com/docker/docker/api/types" |
| 10 | 10 |
"github.com/docker/docker/client" |
| 11 |
+ "github.com/docker/docker/integration-cli/fixtures/load" |
|
| 11 | 12 |
"github.com/pkg/errors" |
| 12 | 13 |
"golang.org/x/net/context" |
| 13 | 14 |
) |
| ... | ... |
@@ -128,3 +129,15 @@ func (e *Execution) Print() {
|
| 128 | 128 |
func (e *Execution) APIClient() client.APIClient {
|
| 129 | 129 |
return e.client |
| 130 | 130 |
} |
| 131 |
+ |
|
| 132 |
+// EnsureFrozenImagesLinux loads frozen test images into the daemon |
|
| 133 |
+// if they aren't already loaded |
|
| 134 |
+func EnsureFrozenImagesLinux(testEnv *Execution) error {
|
|
| 135 |
+ if testEnv.OSType == "linux" {
|
|
| 136 |
+ err := load.FrozenImagesLinux(testEnv.APIClient(), frozenImages...) |
|
| 137 |
+ if err != nil {
|
|
| 138 |
+ return errors.Wrap(err, "error loading frozen images") |
|
| 139 |
+ } |
|
| 140 |
+ } |
|
| 141 |
+ return nil |
|
| 142 |
+} |
| ... | ... |
@@ -6,10 +6,11 @@ import ( |
| 6 | 6 |
"github.com/docker/docker/api/types" |
| 7 | 7 |
"github.com/docker/docker/api/types/filters" |
| 8 | 8 |
dclient "github.com/docker/docker/client" |
| 9 |
- "github.com/docker/docker/integration-cli/fixtures/load" |
|
| 10 | 9 |
"github.com/stretchr/testify/require" |
| 11 | 10 |
) |
| 12 | 11 |
|
| 12 |
+var frozenImages = []string{"busybox:latest", "hello-world:frozen", "debian:jessie"}
|
|
| 13 |
+ |
|
| 13 | 14 |
type protectedElements struct {
|
| 14 | 15 |
containers map[string]struct{}
|
| 15 | 16 |
images map[string]struct{}
|
| ... | ... |
@@ -83,7 +84,7 @@ func ProtectImages(t testingT, testEnv *Execution) {
|
| 83 | 83 |
images := getExistingImages(t, testEnv) |
| 84 | 84 |
|
| 85 | 85 |
if testEnv.OSType == "linux" {
|
| 86 |
- images = append(images, ensureFrozenImagesLinux(t, testEnv)...) |
|
| 86 |
+ images = append(images, frozenImages...) |
|
| 87 | 87 |
} |
| 88 | 88 |
testEnv.ProtectImage(t, images...) |
| 89 | 89 |
} |
| ... | ... |
@@ -120,15 +121,6 @@ func tagsFromImageSummary(image types.ImageSummary) []string {
|
| 120 | 120 |
return result |
| 121 | 121 |
} |
| 122 | 122 |
|
| 123 |
-func ensureFrozenImagesLinux(t testingT, testEnv *Execution) []string {
|
|
| 124 |
- images := []string{"busybox:latest", "hello-world:frozen", "debian:jessie"}
|
|
| 125 |
- err := load.FrozenImagesLinux(testEnv.APIClient(), images...) |
|
| 126 |
- if err != nil {
|
|
| 127 |
- t.Fatalf("Failed to load frozen images: %s", err)
|
|
| 128 |
- } |
|
| 129 |
- return images |
|
| 130 |
-} |
|
| 131 |
- |
|
| 132 | 123 |
// ProtectNetwork adds the specified network(s) to be protected in case of |
| 133 | 124 |
// clean |
| 134 | 125 |
func (e *Execution) ProtectNetwork(t testingT, networks ...string) {
|