diff --git a/.travis.yml b/.travis.yml index dbb95a10..651dba72 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ env: go: - 1.4 - 1.5 + - 1.6 - tip @@ -22,12 +23,10 @@ matrix: install: - go get github.com/mattn/goveralls - go get golang.org/x/tools/cmd/cover - - go get github.com/golang/lint/golint - go get github.com/pierrre/gotestcover - go get -t ./... script: - go vet -x . - - golint . - gotestcover -coverprofile="cover.out" -race -covermode="count" . - goveralls -coverprofile="cover.out" diff --git a/README.md b/README.md index bc2f1844..debaf048 100644 --- a/README.md +++ b/README.md @@ -36,11 +36,12 @@ Dockertest ships with support for these backends: - [Write awesome tests](#write-awesome-tests) - [Setting up Travis-CI](#setting-up-travis-ci) - [Troubleshoot & FAQ](#troubleshoot-&-faq) - - [I want to use a specific image version](#i-want-to-use-a-specific-image-version) + - [I need to use a specific container version for XYZ](#i-need-to-use-a-specific-container-version-for-xyz) - [My build is broken!](#my-build-is-broken) - [Out of disk space](#out-of-disk-space) + - [I am using docker machine (OSX / Linux)](#i-am-using-docker-machine-osx--linux) - [Removing old containers](#removing-old-containers) - - [Customized database] (#Customized-database) + - [Customized database](#customized-database) @@ -225,6 +226,13 @@ If you relied on these, run `go get gopkg.in/ory-am/dockertest.v1` and replace Try cleaning up the images with [docker-cleanup-volumes](https://github.com/chadoe/docker-cleanup-volumes). +### I am using docker machine (OSX / Linux) + +First of all, consider upgrading! If that's not an option, there are some steps you need to take: + +* Set `dockertest.UseDockerMachine = "1"` or set the environment variable `DOCKERTEST_LEGACY_DOCKER_MACHINE=1` +* Set `docker.BindDockerToLocalhost = ""` or alternatively `DOCKER_BIND_LOCALHOST=` + ### Removing old containers Sometimes container clean up fails. Check out diff --git a/docker.go b/docker.go index 3c428b08..5c09c256 100644 --- a/docker.go +++ b/docker.go @@ -37,7 +37,7 @@ import ( // based on image. func runLongTest(image string) error { DockerMachineAvailable = false - if haveDockerMachine() { + if haveDockerMachine() && UseDockerMachine != "" { DockerMachineAvailable = true if !startDockerMachine() { log.Printf(`Starting docker machine "%s" failed. @@ -257,4 +257,4 @@ func GenerateContainerID() string { func init() { rand.Seed(time.Now().UTC().UnixNano()) -} \ No newline at end of file +} diff --git a/mockserver.go b/mockserver.go index f7e6d772..0bdf1539 100644 --- a/mockserver.go +++ b/mockserver.go @@ -2,9 +2,9 @@ package dockertest import ( "fmt" - "time" - "log" "github.com/go-errors/errors" + "log" + "time" ) // SetupMockserverContainer sets up a real Mockserver instance for testing purposes @@ -22,7 +22,7 @@ func SetupMockserverContainer() (c ContainerID, ip string, mockPort, proxyPort i proxyForward = "127.0.0.1:" + proxyForward } - c, ip, err = SetupMultiportContainer(RabbitMQImageName, []int{ mockPort, proxyPort}, 10*time.Second, func() (string, error) { + c, ip, err = SetupMultiportContainer(RabbitMQImageName, []int{mockPort, proxyPort}, 10*time.Second, func() (string, error) { res, err := run("--name", GenerateContainerID(), "-d", "-P", "-p", mockForward, "-p", proxyForward, MockserverImageName) return res, err }) @@ -63,4 +63,4 @@ func ConnectToMockserver(tries int, delay time.Duration, mockConnector func(url } else { return c, errors.New("Could not set up Mockserver container.") } -} \ No newline at end of file +} diff --git a/vars.go b/vars.go index 6ee66bd9..34c7759a 100644 --- a/vars.go +++ b/vars.go @@ -17,7 +17,10 @@ var ( // BindDockerToLocalhost if set, forces docker to bind the image to localhost. This for example is required when running tests on travis-ci. // You can set this variable either directly or by defining a DOCKERTEST_BIND_LOCALHOST env variable. // FIXME DOCKER_BIND_LOCALHOST remove legacy support - BindDockerToLocalhost = env.Getenv("DOCKERTEST_BIND_LOCALHOST", env.Getenv("DOCKER_BIND_LOCALHOST", "")) + BindDockerToLocalhost = env.Getenv("DOCKERTEST_BIND_LOCALHOST", env.Getenv("DOCKER_BIND_LOCALHOST", "1")) + + // UseDockerMachine if set, forces docker to use the legacy docker-machine on OSX/Windows. + UseDockerMachine = env.Getenv("DOCKERTEST_LEGACY_DOCKER_MACHINE", "") // ContainerPrefix will be prepended to all containers started by dockertest to make identification of these "test images" hassle-free. ContainerPrefix = env.Getenv("DOCKERTEST_CONTAINER_PREFIX", "dockertest-")