Skip to content

Commit

Permalink
tests: Only pull docker test image if not available locally
Browse files Browse the repository at this point in the history
Change the unit-test setup code to only download the "busybox" docker
image if it doesn't already exist locally. Since the unit-tests are run
twice (once as a non-privileged user and once as `root`), this can speed
up the overall unit-test runtime significantly.

Fixes clearcontainers#653.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
  • Loading branch information
jodh-intel committed Sep 29, 2017
1 parent c9d1687 commit 80f5652
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,16 @@ func init() {
// Do this now to avoid hitting the test timeout value due to
// slow network response.
fmt.Printf("INFO: ensuring required docker image (%v) is available\n", testDockerImage)
_, err = runCommand([]string{"docker", "pull", testDockerImage})
if err != nil {
panic(err)

// Only hit the network if the image doesn't exist locally
_, err = runCommand([]string{"docker", "image", "inspect", testDockerImage})
if err == nil {
fmt.Printf("INFO: docker image %v already exists locally\n", testDockerImage)
} else {
_, err = runCommand([]string{"docker", "pull", testDockerImage})
if err != nil {
panic(err)
}
}

testBundleDir = filepath.Join(testDir, testBundle)
Expand Down

0 comments on commit 80f5652

Please sign in to comment.