Skip to content

Commit

Permalink
Speed up tests by allowing parallel execution.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHines committed Nov 25, 2015
1 parent d707adc commit ffda9d7
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 0 deletions.
13 changes: 13 additions & 0 deletions client/driver/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func dockerSetup(t *testing.T, task *structs.Task) (*docker.Client, DriverHandle
}

func TestDockerDriver_Handle(t *testing.T) {
t.Parallel()
h := &DockerHandle{
imageID: "imageid",
containerID: "containerid",
Expand All @@ -135,6 +136,7 @@ func TestDockerDriver_Handle(t *testing.T) {

// This test should always pass, even if docker daemon is not available
func TestDockerDriver_Fingerprint(t *testing.T) {
t.Parallel()
d := NewDockerDriver(testDockerDriverContext(""))
node := &structs.Node{
Attributes: make(map[string]string),
Expand All @@ -153,6 +155,7 @@ func TestDockerDriver_Fingerprint(t *testing.T) {
}

func TestDockerDriver_StartOpen_Wait(t *testing.T) {
t.Parallel()
if !dockerIsConnected(t) {
t.SkipNow()
}
Expand Down Expand Up @@ -190,6 +193,7 @@ func TestDockerDriver_StartOpen_Wait(t *testing.T) {
}

func TestDockerDriver_Start_Wait(t *testing.T) {
t.Parallel()
task := &structs.Task{
Name: "redis-demo",
Config: map[string]interface{}{
Expand Down Expand Up @@ -223,6 +227,7 @@ func TestDockerDriver_Start_Wait(t *testing.T) {
}

func TestDockerDriver_Start_Wait_AllocDir(t *testing.T) {
t.Parallel()
// This test requires that the alloc dir be mounted into docker as a volume.
// Because this cannot happen when docker is run remotely, e.g. when running
// docker in a VM, we skip this when we detect Docker is being run remotely.
Expand Down Expand Up @@ -285,6 +290,7 @@ func TestDockerDriver_Start_Wait_AllocDir(t *testing.T) {
}

func TestDockerDriver_Start_Kill_Wait(t *testing.T) {
t.Parallel()
task := &structs.Task{
Name: "redis-demo",
Config: map[string]interface{}{
Expand Down Expand Up @@ -317,6 +323,7 @@ func TestDockerDriver_Start_Kill_Wait(t *testing.T) {
}

func TestDocker_StartN(t *testing.T) {
t.Parallel()
if !dockerIsConnected(t) {
t.SkipNow()
}
Expand Down Expand Up @@ -371,6 +378,7 @@ func TestDocker_StartN(t *testing.T) {
}

func TestDocker_StartNVersions(t *testing.T) {
t.Parallel()
if !dockerIsConnected(t) {
t.SkipNow()
}
Expand Down Expand Up @@ -428,6 +436,7 @@ func TestDocker_StartNVersions(t *testing.T) {
}

func TestDockerHostNet(t *testing.T) {
t.Parallel()
expected := "host"

task := &structs.Task{
Expand Down Expand Up @@ -457,6 +466,7 @@ func TestDockerHostNet(t *testing.T) {
}

func TestDockerLabels(t *testing.T) {
t.Parallel()
task := dockerTask()
task.Config["labels"] = []map[string]string{
map[string]string{
Expand All @@ -483,6 +493,7 @@ func TestDockerLabels(t *testing.T) {
}

func TestDockerDNS(t *testing.T) {
t.Parallel()
task := dockerTask()
task.Config["dns_servers"] = []string{"8.8.8.8", "8.8.4.4"}
task.Config["dns_search_domains"] = []string{"example.com", "example.org", "example.net"}
Expand Down Expand Up @@ -514,6 +525,7 @@ func inSlice(needle string, haystack []string) bool {
}

func TestDockerPortsNoMap(t *testing.T) {
t.Parallel()
task := dockerTask()

client, handle, cleanup := dockerSetup(t, task)
Expand Down Expand Up @@ -564,6 +576,7 @@ func TestDockerPortsNoMap(t *testing.T) {
}

func TestDockerPortsMapping(t *testing.T) {
t.Parallel()
task := dockerTask()
task.Config["port_map"] = []map[string]string{
map[string]string{
Expand Down
3 changes: 3 additions & 0 deletions client/driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func testDriverExecContext(task *structs.Task, driverCtx *DriverContext) *ExecCo
}

func TestDriver_TaskEnvironmentVariables(t *testing.T) {
t.Parallel()
ctx := &ExecContext{}
task := &structs.Task{
Env: map[string]string{
Expand Down Expand Up @@ -108,6 +109,7 @@ func TestDriver_TaskEnvironmentVariables(t *testing.T) {
}

func TestMapMergeStrInt(t *testing.T) {
t.Parallel()
a := map[string]int{
"cakes": 5,
"cookies": 3,
Expand All @@ -132,6 +134,7 @@ func TestMapMergeStrInt(t *testing.T) {
}

func TestMapMergeStrStr(t *testing.T) {
t.Parallel()
a := map[string]string{
"cake": "chocolate",
"cookie": "caramel",
Expand Down
7 changes: 7 additions & 0 deletions client/driver/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
)

func TestExecDriver_Fingerprint(t *testing.T) {
t.Parallel()
ctestutils.ExecCompatible(t)
d := NewExecDriver(testDriverContext(""))
node := &structs.Node{
Expand All @@ -34,6 +35,7 @@ func TestExecDriver_Fingerprint(t *testing.T) {
}

func TestExecDriver_StartOpen_Wait(t *testing.T) {
t.Parallel()
ctestutils.ExecCompatible(t)
task := &structs.Task{
Name: "sleep",
Expand Down Expand Up @@ -68,6 +70,7 @@ func TestExecDriver_StartOpen_Wait(t *testing.T) {
}

func TestExecDriver_Start_Wait(t *testing.T) {
t.Parallel()
ctestutils.ExecCompatible(t)
task := &structs.Task{
Name: "sleep",
Expand Down Expand Up @@ -109,6 +112,7 @@ func TestExecDriver_Start_Wait(t *testing.T) {
}

func TestExecDriver_Start_Artifact_basic(t *testing.T) {
t.Parallel()
ctestutils.ExecCompatible(t)
file := "hi_linux_amd64"
checksum := "sha256:6f99b4c5184726e601ecb062500aeb9537862434dfe1898dbe5c68d9f50c179c"
Expand Down Expand Up @@ -153,6 +157,7 @@ func TestExecDriver_Start_Artifact_basic(t *testing.T) {
}

func TestExecDriver_Start_Artifact_expanded(t *testing.T) {
t.Parallel()
ctestutils.ExecCompatible(t)
file := "hi_linux_amd64"

Expand Down Expand Up @@ -199,6 +204,7 @@ func TestExecDriver_Start_Artifact_expanded(t *testing.T) {
}
}
func TestExecDriver_Start_Wait_AllocDir(t *testing.T) {
t.Parallel()
ctestutils.ExecCompatible(t)

exp := []byte{'w', 'i', 'n'}
Expand Down Expand Up @@ -251,6 +257,7 @@ func TestExecDriver_Start_Wait_AllocDir(t *testing.T) {
}

func TestExecDriver_Start_Kill_Wait(t *testing.T) {
t.Parallel()
ctestutils.ExecCompatible(t)
task := &structs.Task{
Name: "sleep",
Expand Down
1 change: 1 addition & 0 deletions client/driver/executor/exec_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ package executor
import "testing"

func TestExecutorBasic(t *testing.T) {
t.Parallel()
testExecutor(t, NewBasicExecutor, nil)
}
1 change: 1 addition & 0 deletions client/driver/executor/exec_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ func init() {
}

func TestExecutorLinux(t *testing.T) {
t.Parallel()
testExecutor(t, NewLinuxExecutor, ctestutil.ExecCompatible)
}
4 changes: 4 additions & 0 deletions client/driver/java_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func javaLocated() bool {

// The fingerprinter test should always pass, even if Java is not installed.
func TestJavaDriver_Fingerprint(t *testing.T) {
t.Parallel()
ctestutils.JavaCompatible(t)
d := NewJavaDriver(testDriverContext(""))
node := &structs.Node{
Expand All @@ -42,6 +43,7 @@ func TestJavaDriver_Fingerprint(t *testing.T) {
}

func TestJavaDriver_StartOpen_Wait(t *testing.T) {
t.Parallel()
if !javaLocated() {
t.Skip("Java not found; skipping")
}
Expand Down Expand Up @@ -88,6 +90,7 @@ func TestJavaDriver_StartOpen_Wait(t *testing.T) {
}

func TestJavaDriver_Start_Wait(t *testing.T) {
t.Parallel()
if !javaLocated() {
t.Skip("Java not found; skipping")
}
Expand Down Expand Up @@ -134,6 +137,7 @@ func TestJavaDriver_Start_Wait(t *testing.T) {
}

func TestJavaDriver_Start_Kill_Wait(t *testing.T) {
t.Parallel()
if !javaLocated() {
t.Skip("Java not found; skipping")
}
Expand Down
3 changes: 3 additions & 0 deletions client/driver/qemu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

// The fingerprinter test should always pass, even if QEMU is not installed.
func TestQemuDriver_Fingerprint(t *testing.T) {
t.Parallel()
ctestutils.QemuCompatible(t)
d := NewQemuDriver(testDriverContext(""))
node := &structs.Node{
Expand All @@ -33,6 +34,7 @@ func TestQemuDriver_Fingerprint(t *testing.T) {
}

func TestQemuDriver_StartOpen_Wait(t *testing.T) {
t.Parallel()
ctestutils.QemuCompatible(t)
// TODO: use test server to load from a fixture
task := &structs.Task{
Expand Down Expand Up @@ -86,6 +88,7 @@ func TestQemuDriver_StartOpen_Wait(t *testing.T) {
}

func TestQemuDriver_RequiresMemory(t *testing.T) {
t.Parallel()
ctestutils.QemuCompatible(t)
// TODO: use test server to load from a fixture
task := &structs.Task{
Expand Down
7 changes: 7 additions & 0 deletions client/driver/raw_exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
)

func TestRawExecDriver_Fingerprint(t *testing.T) {
t.Parallel()
d := NewRawExecDriver(testDriverContext(""))
node := &structs.Node{
Attributes: make(map[string]string),
Expand Down Expand Up @@ -51,6 +52,7 @@ func TestRawExecDriver_Fingerprint(t *testing.T) {
}

func TestRawExecDriver_StartOpen_Wait(t *testing.T) {
t.Parallel()
task := &structs.Task{
Name: "sleep",
Config: map[string]interface{}{
Expand Down Expand Up @@ -91,6 +93,7 @@ func TestRawExecDriver_StartOpen_Wait(t *testing.T) {
}

func TestRawExecDriver_Start_Artifact_basic(t *testing.T) {
t.Parallel()
path := testtask.Path()
ts := httptest.NewServer(http.FileServer(http.Dir(filepath.Dir(path))))
defer ts.Close()
Expand Down Expand Up @@ -138,6 +141,7 @@ func TestRawExecDriver_Start_Artifact_basic(t *testing.T) {
}

func TestRawExecDriver_Start_Artifact_expanded(t *testing.T) {
t.Parallel()
path := testtask.Path()
ts := httptest.NewServer(http.FileServer(http.Dir(filepath.Dir(path))))
defer ts.Close()
Expand Down Expand Up @@ -185,6 +189,7 @@ func TestRawExecDriver_Start_Artifact_expanded(t *testing.T) {
}

func TestRawExecDriver_Start_Wait(t *testing.T) {
t.Parallel()
task := &structs.Task{
Name: "sleep",
Config: map[string]interface{}{
Expand Down Expand Up @@ -226,6 +231,7 @@ func TestRawExecDriver_Start_Wait(t *testing.T) {
}

func TestRawExecDriver_Start_Wait_AllocDir(t *testing.T) {
t.Parallel()
exp := []byte{'w', 'i', 'n'}
file := "output.txt"
outPath := fmt.Sprintf(`$%s/%s`, environment.AllocDir, file)
Expand Down Expand Up @@ -278,6 +284,7 @@ func TestRawExecDriver_Start_Wait_AllocDir(t *testing.T) {
}

func TestRawExecDriver_Start_Kill_Wait(t *testing.T) {
t.Parallel()
task := &structs.Task{
Name: "sleep",
Config: map[string]interface{}{
Expand Down

0 comments on commit ffda9d7

Please sign in to comment.