From 28fef04b64beb7219ad79ea5785b83c7e5b1e787 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Tue, 6 Oct 2015 00:27:05 -0700 Subject: [PATCH 1/3] Add skip detection for all docker tests --- client/driver/docker_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/client/driver/docker_test.go b/client/driver/docker_test.go index 3bea8235a52..37a5bb51a82 100644 --- a/client/driver/docker_test.go +++ b/client/driver/docker_test.go @@ -189,7 +189,7 @@ func taskTemplate() *structs.Task { MemoryMB: 256, CPU: 512, Networks: []*structs.NetworkResource{ - &structs.NetworkResource{ + { IP: "127.0.0.1", ReservedPorts: []int{11110}, DynamicPorts: []string{"REDIS"}, @@ -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 @@ -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" @@ -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", From 629a56ee7099f9d6328799b11d752e1a7a4c3c4c Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Tue, 6 Oct 2015 00:32:34 -0700 Subject: [PATCH 2/3] This is needed for 1.4.2 compat; not sure what removed it --- client/driver/docker_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/driver/docker_test.go b/client/driver/docker_test.go index 37a5bb51a82..e6eab88dc49 100644 --- a/client/driver/docker_test.go +++ b/client/driver/docker_test.go @@ -189,7 +189,7 @@ func taskTemplate() *structs.Task { MemoryMB: 256, CPU: 512, Networks: []*structs.NetworkResource{ - { + &structs.NetworkResource{ IP: "127.0.0.1", ReservedPorts: []int{11110}, DynamicPorts: []string{"REDIS"}, From 2801e7d1e10bbc4b7729beeb7a58b93ead3f636e Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Tue, 6 Oct 2015 16:33:02 -0700 Subject: [PATCH 3/3] Fingerprint test should now behave correctly when the executor is not installed; fix some go vet issues --- client/driver/docker.go | 2 +- client/driver/docker_test.go | 10 +++++----- client/driver/java_test.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/client/driver/docker.go b/client/driver/docker.go index 7f59e7ce38c..2b4fdd78edd 100644 --- a/client/driver/docker.go +++ b/client/driver/docker.go @@ -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() { diff --git a/client/driver/docker_test.go b/client/driver/docker_test.go index e6eab88dc49..6af8e28d1be 100644 --- a/client/driver/docker_test.go +++ b/client/driver/docker_test.go @@ -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"]) } @@ -217,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 @@ -266,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 diff --git a/client/driver/java_test.go b/client/driver/java_test.go index aa4752e9523..f73c9569235 100644 --- a/client/driver/java_test.go +++ b/client/driver/java_test.go @@ -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")