diff --git a/hack/test-integration-docker.sh b/hack/test-integration-docker.sh index 2fce7a5162c6..1f1e21be9063 100755 --- a/hack/test-integration-docker.sh +++ b/hack/test-integration-docker.sh @@ -22,4 +22,6 @@ trap cleanup EXIT SIGINT echo echo Docker integration test cases ... echo -KUBE_RACE="${KUBE_RACE:--race}" KUBE_COVER=" " "${OS_ROOT}/hack/test-go.sh" test/integration -tags 'integration docker' "${@:1}" +# A long timeout is set here in case the docker images do not exist. To speed execution of this test +# either pre-build or pre-pull the docker images that are being used. +KUBE_TIMEOUT="-timeout 600s" KUBE_RACE="${KUBE_RACE:--race}" KUBE_COVER=" " "${OS_ROOT}/hack/test-go.sh" test/integration -tags 'integration docker' "${@:1}" diff --git a/test/integration/router_test.go b/test/integration/router_test.go index d92a8deb24a3..e8658d6517e8 100644 --- a/test/integration/router_test.go +++ b/test/integration/router_test.go @@ -18,7 +18,7 @@ import ( tr "github.com/openshift/origin/test/integration/router" ) -const defaultRouterImage = "openshift/origin-haproxy-router" +const defaultRouterImage = "openshift/origin-haproxy-router:latest" // init ensures docker exists for this test func init() { @@ -233,6 +233,12 @@ func createAndStartRouterContainer(dockerCli *dockerClient.Client, masterIp stri }, } + err = pullIfNotPresent(dockerCli, getRouterImage()) + + if err != nil { + return "", err + } + container, err := dockerCli.CreateContainer(containerOpts) if err != nil { @@ -270,6 +276,31 @@ func createAndStartRouterContainer(dockerCli *dockerClient.Client, masterIp stri return container.ID, nil } +// pullIfNotPresent checks for a docker image and tries to pull it if it receives a 'no such image' error +func pullIfNotPresent(dockerCli *dockerClient.Client, image string) error { + _, err := dockerCli.InspectImage(image) + + if err != nil { + if err.Error() == "no such image" { + pio := dockerClient.PullImageOptions{ + Repository: image, + } + + auth := dockerClient.AuthConfiguration{} + + e := dockerCli.PullImage(pio, auth) + + if e != nil { + return e + } + } else { + return err + } + } + + return nil +} + // validateServer performs a basic run through by validating each of the configured urls for the simulator to // ensure they are responding func validateServer(server *tr.TestHttpService, t *testing.T) {