Skip to content

Commit

Permalink
Merge pull request #221 from hashicorp/b-docker-tests-osx
Browse files Browse the repository at this point in the history
Add skip detection for all docker tests
  • Loading branch information
cbednarski committed Oct 7, 2015
2 parents f6f2276 + 2801e7d commit b58fd56
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/driver/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func createContainer(ctx *ExecContext, task *structs.Task, logger *log.Logger) d
for _, port := range network.ListStaticPorts() {
dockerPorts[docker.Port(strconv.Itoa(port)+"/tcp")] = []docker.PortBinding{docker.PortBinding{HostIP: network.IP, HostPort: strconv.Itoa(port)}}
dockerPorts[docker.Port(strconv.Itoa(port)+"/udp")] = []docker.PortBinding{docker.PortBinding{HostIP: network.IP, HostPort: strconv.Itoa(port)}}
logger.Printf("[DEBUG] driver.docker: allocated port %s:%d -> %d (static) %s\n", network.IP, port, port)
logger.Printf("[DEBUG] driver.docker: allocated port %s:%d -> %d (static)\n", network.IP, port, port)
}

for label, port := range network.MapDynamicPorts() {
Expand Down
20 changes: 15 additions & 5 deletions client/driver/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ func TestDockerDriver_Fingerprint(t *testing.T) {
if err != nil {
t.Fatalf("err: %v", err)
}
if !apply {
t.Fatalf("should apply")
if apply != dockerLocated() {
t.Fatalf("Fingerprinter should detect Docker when it is installed")
}
if node.Attributes["driver.docker"] == "" {
t.Fatalf("Docker not found. The remainder of the docker tests will be skipped.")
t.Log("Docker not found. The remainder of the docker tests will be skipped.")
}
t.Logf("Found docker version %s", node.Attributes["driver.docker.version"])
}
Expand Down Expand Up @@ -200,6 +200,9 @@ func taskTemplate() *structs.Task {
}

func TestDocker_StartN(t *testing.T) {
if !dockerLocated() {
t.SkipNow()
}

task1 := taskTemplate()
task1.Resources.Networks[0].ReservedPorts[0] = 11111
Expand All @@ -214,7 +217,7 @@ func TestDocker_StartN(t *testing.T) {

handles := make([]DriverHandle, len(taskList))

t.Log("==> Starting %d tasks", len(taskList))
t.Logf("==> Starting %d tasks", len(taskList))

// Let's spin up a bunch of things
var err error
Expand Down Expand Up @@ -243,6 +246,9 @@ func TestDocker_StartN(t *testing.T) {
}

func TestDocker_StartNVersions(t *testing.T) {
if !dockerLocated() {
t.SkipNow()
}

task1 := taskTemplate()
task1.Config["image"] = "redis"
Expand All @@ -260,7 +266,7 @@ func TestDocker_StartNVersions(t *testing.T) {

handles := make([]DriverHandle, len(taskList))

t.Log("==> Starting %d tasks", len(taskList))
t.Logf("==> Starting %d tasks", len(taskList))

// Let's spin up a bunch of things
var err error
Expand Down Expand Up @@ -289,6 +295,10 @@ func TestDocker_StartNVersions(t *testing.T) {
}

func TestDockerHostNet(t *testing.T) {
if !dockerLocated() {
t.SkipNow()
}

task := &structs.Task{
Config: map[string]string{
"image": "redis",
Expand Down
4 changes: 2 additions & 2 deletions client/driver/java_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func TestJavaDriver_Fingerprint(t *testing.T) {
if err != nil {
t.Fatalf("err: %v", err)
}
if !apply {
t.Fatalf("should apply")
if apply != javaLocated() {
t.Fatalf("Fingerprinter should detect Java when it is installed")
}
if node.Attributes["driver.java"] != "1" {
t.Fatalf("missing driver")
Expand Down

0 comments on commit b58fd56

Please sign in to comment.