Skip to content

Commit

Permalink
core: bind to localhost per default and disable legacy docker machine (
Browse files Browse the repository at this point in the history
…#58)

* core: bind to localhost per default and disable legacy docker machine

closes #51

* travis: add go version 1.6
  • Loading branch information
arekkas authored Aug 3, 2016
1 parent e6ba58a commit 8164b50
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ env:
go:
- 1.4
- 1.5
- 1.6
- tip


Expand All @@ -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"
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -257,4 +257,4 @@ func GenerateContainerID() string {

func init() {
rand.Seed(time.Now().UTC().UnixNano())
}
}
8 changes: 4 additions & 4 deletions mockserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
})
Expand Down Expand Up @@ -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.")
}
}
}
5 changes: 4 additions & 1 deletion vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -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-")
Expand Down

0 comments on commit 8164b50

Please sign in to comment.