This commit is contained in:
Alex Dadgar 2017-07-21 12:06:39 -07:00
parent 0fabb5902a
commit 7c433a1767
13 changed files with 82 additions and 0 deletions

View file

@ -44,6 +44,7 @@ func (m *mockImageClient) RemoveImage(id string) error {
}
func TestDockerCoordinator_ConcurrentPulls(t *testing.T) {
t.Parallel()
image := "foo"
imageID := structs.GenerateUUID()
mapping := map[string]string{imageID: image}
@ -90,6 +91,7 @@ func TestDockerCoordinator_ConcurrentPulls(t *testing.T) {
}
func TestDockerCoordinator_Pull_Remove(t *testing.T) {
t.Parallel()
image := "foo"
imageID := structs.GenerateUUID()
mapping := map[string]string{imageID: image}
@ -153,6 +155,7 @@ func TestDockerCoordinator_Pull_Remove(t *testing.T) {
}
func TestDockerCoordinator_Remove_Cancel(t *testing.T) {
t.Parallel()
image := "foo"
imageID := structs.GenerateUUID()
mapping := map[string]string{imageID: image}
@ -200,6 +203,7 @@ func TestDockerCoordinator_Remove_Cancel(t *testing.T) {
}
func TestDockerCoordinator_No_Cleanup(t *testing.T) {
t.Parallel()
image := "foo"
imageID := structs.GenerateUUID()
mapping := map[string]string{imageID: image}

View file

@ -158,6 +158,7 @@ func newTestDockerClient(t *testing.T) *docker.Client {
// This test should always pass, even if docker daemon is not available
func TestDockerDriver_Fingerprint(t *testing.T) {
t.Parallel()
ctx := testDockerDriverContexts(t, &structs.Task{Name: "foo", Driver: "docker", Resources: basicResources})
//ctx.DriverCtx.config.Options = map[string]string{"docker.cleanup.image": "false"}
defer ctx.AllocDir.Destroy()
@ -181,6 +182,7 @@ func TestDockerDriver_Fingerprint(t *testing.T) {
// TestDockerDriver_Fingerprint_Bridge asserts that if Docker is running we set
// the bridge network's IP as a node attribute. See #2785
func TestDockerDriver_Fingerprint_Bridge(t *testing.T) {
t.Parallel()
if !testutil.DockerIsConnected(t) {
t.Skip("requires Docker")
}
@ -213,6 +215,7 @@ func TestDockerDriver_Fingerprint_Bridge(t *testing.T) {
}
func TestDockerDriver_StartOpen_Wait(t *testing.T) {
t.Parallel()
if !testutil.DockerIsConnected(t) {
t.SkipNow()
}
@ -264,6 +267,7 @@ func TestDockerDriver_StartOpen_Wait(t *testing.T) {
}
func TestDockerDriver_Start_Wait(t *testing.T) {
t.Parallel()
task := &structs.Task{
Name: "nc-demo",
Driver: "docker",
@ -303,6 +307,7 @@ func TestDockerDriver_Start_Wait(t *testing.T) {
}
func TestDockerDriver_Start_LoadImage(t *testing.T) {
t.Parallel()
if !testutil.DockerIsConnected(t) {
t.SkipNow()
}
@ -369,6 +374,7 @@ func TestDockerDriver_Start_LoadImage(t *testing.T) {
}
func TestDockerDriver_Start_BadPull_Recoverable(t *testing.T) {
t.Parallel()
if !testutil.DockerIsConnected(t) {
t.SkipNow()
}
@ -410,6 +416,7 @@ func TestDockerDriver_Start_BadPull_Recoverable(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.
@ -480,6 +487,7 @@ func TestDockerDriver_Start_Wait_AllocDir(t *testing.T) {
}
func TestDockerDriver_Start_Kill_Wait(t *testing.T) {
t.Parallel()
task := &structs.Task{
Name: "nc-demo",
Driver: "docker",
@ -518,6 +526,7 @@ func TestDockerDriver_Start_Kill_Wait(t *testing.T) {
}
func TestDockerDriver_StartN(t *testing.T) {
t.Parallel()
if !testutil.DockerIsConnected(t) {
t.SkipNow()
}
@ -569,6 +578,7 @@ func TestDockerDriver_StartN(t *testing.T) {
}
func TestDockerDriver_StartNVersions(t *testing.T) {
t.Parallel()
if !testutil.DockerIsConnected(t) {
t.SkipNow()
}
@ -646,6 +656,7 @@ func waitForExist(t *testing.T, client *docker.Client, handle *DockerHandle) {
}
func TestDockerDriver_NetworkMode_Host(t *testing.T) {
t.Parallel()
expected := "host"
task := &structs.Task{
@ -685,6 +696,7 @@ func TestDockerDriver_NetworkMode_Host(t *testing.T) {
}
func TestDockerDriver_NetworkAliases_Bridge(t *testing.T) {
t.Parallel()
// Because go-dockerclient doesn't provide api for query network aliases, just check that
// a container can be created with a 'network_aliases' property
@ -731,6 +743,7 @@ func TestDockerDriver_NetworkAliases_Bridge(t *testing.T) {
}
func TestDockerDriver_Labels(t *testing.T) {
t.Parallel()
task, _, _ := dockerTask()
task.Config["labels"] = []map[string]string{
map[string]string{
@ -759,6 +772,7 @@ func TestDockerDriver_Labels(t *testing.T) {
}
func TestDockerDriver_ForcePull_IsInvalidConfig(t *testing.T) {
t.Parallel()
task, _, _ := dockerTask()
task.Config["force_pull"] = "nothing"
@ -773,6 +787,7 @@ func TestDockerDriver_ForcePull_IsInvalidConfig(t *testing.T) {
}
func TestDockerDriver_ForcePull(t *testing.T) {
t.Parallel()
task, _, _ := dockerTask()
task.Config["force_pull"] = "true"
@ -788,6 +803,7 @@ func TestDockerDriver_ForcePull(t *testing.T) {
}
func TestDockerDriver_SecurityOpt(t *testing.T) {
t.Parallel()
task, _, _ := dockerTask()
task.Config["security_opt"] = []string{"seccomp=unconfined"}
@ -807,6 +823,7 @@ func TestDockerDriver_SecurityOpt(t *testing.T) {
}
func TestDockerDriver_DNS(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"}
@ -831,6 +848,7 @@ func TestDockerDriver_DNS(t *testing.T) {
}
func TestDockerDriver_MACAddress(t *testing.T) {
t.Parallel()
task, _, _ := dockerTask()
task.Config["mac_address"] = "00:16:3e:00:00:00"
@ -850,6 +868,7 @@ func TestDockerDriver_MACAddress(t *testing.T) {
}
func TestDockerWorkDir(t *testing.T) {
t.Parallel()
task, _, _ := dockerTask()
task.Config["work_dir"] = "/some/path"
@ -876,6 +895,7 @@ func inSlice(needle string, haystack []string) bool {
}
func TestDockerDriver_PortsNoMap(t *testing.T) {
t.Parallel()
task, res, dyn := dockerTask()
client, handle, cleanup := dockerSetup(t, task)
@ -926,6 +946,7 @@ func TestDockerDriver_PortsNoMap(t *testing.T) {
}
func TestDockerDriver_PortsMapping(t *testing.T) {
t.Parallel()
task, res, dyn := dockerTask()
task.Config["port_map"] = []map[string]string{
map[string]string{
@ -984,6 +1005,7 @@ func TestDockerDriver_PortsMapping(t *testing.T) {
}
func TestDockerDriver_User(t *testing.T) {
t.Parallel()
task := &structs.Task{
Name: "redis-demo",
User: "alice",
@ -1033,6 +1055,7 @@ func TestDockerDriver_User(t *testing.T) {
}
func TestDockerDriver_CleanupContainer(t *testing.T) {
t.Parallel()
task := &structs.Task{
Name: "redis-demo",
Driver: "docker",
@ -1081,6 +1104,7 @@ func TestDockerDriver_CleanupContainer(t *testing.T) {
}
func TestDockerDriver_Stats(t *testing.T) {
t.Parallel()
task := &structs.Task{
Name: "sleep",
Driver: "docker",
@ -1189,6 +1213,7 @@ func setupDockerVolumes(t *testing.T, cfg *config.Config, hostpath string) (*str
}
func TestDockerDriver_VolumesDisabled(t *testing.T) {
t.Parallel()
cfg := testConfig()
cfg.Options = map[string]string{
dockerVolumesConfigOption: "false",
@ -1259,6 +1284,7 @@ func TestDockerDriver_VolumesDisabled(t *testing.T) {
}
func TestDockerDriver_VolumesEnabled(t *testing.T) {
t.Parallel()
cfg := testConfig()
tmpvol, err := ioutil.TempDir("", "nomadtest_docker_volumesenabled")
@ -1295,6 +1321,7 @@ func TestDockerDriver_VolumesEnabled(t *testing.T) {
// TestDockerDriver_Cleanup ensures Cleanup removes only downloaded images.
func TestDockerDriver_Cleanup(t *testing.T) {
t.Parallel()
if !testutil.DockerIsConnected(t) {
t.SkipNow()
}
@ -1356,6 +1383,7 @@ func copyImage(t *testing.T, taskDir *allocdir.TaskDir, image string) {
}
func TestDockerDriver_AuthConfiguration(t *testing.T) {
t.Parallel()
path := "./test-resources/docker/auth.json"
cases := []struct {
Repo string

View file

@ -16,6 +16,7 @@ import (
)
func TestDockerDriver_Signal(t *testing.T) {
t.Parallel()
if !testutil.DockerIsConnected(t) {
t.SkipNow()
}

View file

@ -220,6 +220,7 @@ func setupTaskEnv(t *testing.T, driver string) (*allocdir.TaskDir, map[string]st
}
func TestDriver_GetTaskEnv_None(t *testing.T) {
t.Parallel()
taskDir, exp, act := setupTaskEnv(t, "raw_exec")
// raw_exec should use host alloc dir path
@ -248,6 +249,7 @@ func TestDriver_GetTaskEnv_None(t *testing.T) {
}
func TestDriver_GetTaskEnv_Chroot(t *testing.T) {
t.Parallel()
_, exp, act := setupTaskEnv(t, "exec")
exp[env.AllocDir] = allocdir.SharedAllocContainerPath
@ -277,6 +279,7 @@ func TestDriver_GetTaskEnv_Chroot(t *testing.T) {
// TestDriver_TaskEnv_Image ensures host environment variables are not set
// for image based drivers. See #2211
func TestDriver_TaskEnv_Image(t *testing.T) {
t.Parallel()
_, exp, act := setupTaskEnv(t, "docker")
exp[env.AllocDir] = allocdir.SharedAllocContainerPath
@ -302,6 +305,7 @@ func TestDriver_TaskEnv_Image(t *testing.T) {
}
func TestMapMergeStrInt(t *testing.T) {
t.Parallel()
a := map[string]int{
"cakes": 5,
"cookies": 3,
@ -326,6 +330,7 @@ func TestMapMergeStrInt(t *testing.T) {
}
func TestMapMergeStrStr(t *testing.T) {
t.Parallel()
a := map[string]string{
"cake": "chocolate",
"cookie": "caramel",
@ -350,6 +355,7 @@ func TestMapMergeStrStr(t *testing.T) {
}
func TestCreatedResources_AddMerge(t *testing.T) {
t.Parallel()
res1 := NewCreatedResources()
res1.Add("k1", "v1")
res1.Add("k1", "v2")
@ -389,6 +395,7 @@ func TestCreatedResources_AddMerge(t *testing.T) {
}
func TestCreatedResources_CopyRemove(t *testing.T) {
t.Parallel()
res1 := NewCreatedResources()
res1.Add("k1", "v1")
res1.Add("k1", "v2")

View file

@ -20,6 +20,7 @@ import (
)
func TestExecDriver_Fingerprint(t *testing.T) {
t.Parallel()
ctestutils.ExecCompatible(t)
task := &structs.Task{
Name: "foo",
@ -47,6 +48,7 @@ func TestExecDriver_Fingerprint(t *testing.T) {
}
func TestExecDriver_StartOpen_Wait(t *testing.T) {
t.Parallel()
ctestutils.ExecCompatible(t)
task := &structs.Task{
Name: "sleep",
@ -88,6 +90,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",
@ -133,6 +136,7 @@ func TestExecDriver_Start_Wait(t *testing.T) {
}
func TestExecDriver_Start_Wait_AllocDir(t *testing.T) {
t.Parallel()
ctestutils.ExecCompatible(t)
exp := []byte{'w', 'i', 'n'}
@ -189,6 +193,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",
@ -237,6 +242,7 @@ func TestExecDriver_Start_Kill_Wait(t *testing.T) {
}
func TestExecDriverUser(t *testing.T) {
t.Parallel()
ctestutils.ExecCompatible(t)
task := &structs.Task{
Name: "sleep",
@ -275,6 +281,7 @@ func TestExecDriverUser(t *testing.T) {
// TestExecDriver_HandlerExec ensures the exec driver's handle properly
// executes commands inside the container.
func TestExecDriver_HandlerExec(t *testing.T) {
t.Parallel()
ctestutils.ExecCompatible(t)
task := &structs.Task{
Name: "sleep",

View file

@ -19,6 +19,7 @@ import (
)
func TestExecDriver_KillUserPid_OnPluginReconnectFailure(t *testing.T) {
t.Parallel()
ctestutils.ExecCompatible(t)
task := &structs.Task{
Name: "sleep",
@ -88,6 +89,7 @@ func TestExecDriver_KillUserPid_OnPluginReconnectFailure(t *testing.T) {
}
func TestExecDriver_Signal(t *testing.T) {
t.Parallel()
ctestutils.ExecCompatible(t)
task := &structs.Task{
Name: "signal",

View file

@ -31,6 +31,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)
task := &structs.Task{
Name: "foo",
@ -67,6 +68,7 @@ func TestJavaDriver_Fingerprint(t *testing.T) {
}
func TestJavaDriver_StartOpen_Wait(t *testing.T) {
t.Parallel()
if !javaLocated() {
t.Skip("Java not found; skipping")
}
@ -120,6 +122,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")
}
@ -183,6 +186,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")
}
@ -242,6 +246,7 @@ func TestJavaDriver_Start_Kill_Wait(t *testing.T) {
}
func TestJavaDriver_Signal(t *testing.T) {
t.Parallel()
if !javaLocated() {
t.Skip("Java not found; skipping")
}
@ -301,6 +306,7 @@ func TestJavaDriver_Signal(t *testing.T) {
}
func TestJavaDriverUser(t *testing.T) {
t.Parallel()
if !javaLocated() {
t.Skip("Java not found; skipping")
}
@ -339,6 +345,7 @@ func TestJavaDriverUser(t *testing.T) {
}
func TestJavaDriver_Start_Wait_Class(t *testing.T) {
t.Parallel()
if !javaLocated() {
t.Skip("Java not found; skipping")
}

View file

@ -16,6 +16,7 @@ import (
)
func TestLxcDriver_Fingerprint(t *testing.T) {
t.Parallel()
if !lxcPresent(t) {
t.Skip("lxc not present")
}
@ -54,6 +55,7 @@ func TestLxcDriver_Fingerprint(t *testing.T) {
}
func TestLxcDriver_Start_Wait(t *testing.T) {
t.Parallel()
if !lxcPresent(t) {
t.Skip("lxc not present")
}
@ -127,6 +129,7 @@ func TestLxcDriver_Start_Wait(t *testing.T) {
}
func TestLxcDriver_Open_Wait(t *testing.T) {
t.Parallel()
if !lxcPresent(t) {
t.Skip("lxc not present")
}

View file

@ -15,6 +15,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)
task := &structs.Task{
Name: "foo",
@ -44,6 +45,7 @@ func TestQemuDriver_Fingerprint(t *testing.T) {
}
func TestQemuDriver_StartOpen_Wait(t *testing.T) {
t.Parallel()
ctestutils.QemuCompatible(t)
task := &structs.Task{
Name: "linux",
@ -110,6 +112,7 @@ func TestQemuDriver_StartOpen_Wait(t *testing.T) {
}
func TestQemuDriverUser(t *testing.T) {
t.Parallel()
ctestutils.QemuCompatible(t)
task := &structs.Task{
Name: "linux",

View file

@ -19,6 +19,7 @@ import (
)
func TestRawExecDriver_Fingerprint(t *testing.T) {
t.Parallel()
task := &structs.Task{
Name: "foo",
Driver: "raw_exec",
@ -60,6 +61,7 @@ func TestRawExecDriver_Fingerprint(t *testing.T) {
}
func TestRawExecDriver_StartOpen_Wait(t *testing.T) {
t.Parallel()
task := &structs.Task{
Name: "sleep",
Driver: "raw_exec",
@ -106,6 +108,7 @@ func TestRawExecDriver_StartOpen_Wait(t *testing.T) {
}
func TestRawExecDriver_Start_Wait(t *testing.T) {
t.Parallel()
task := &structs.Task{
Name: "sleep",
Driver: "raw_exec",
@ -150,6 +153,7 @@ func TestRawExecDriver_Start_Wait(t *testing.T) {
}
func TestRawExecDriver_Start_Wait_AllocDir(t *testing.T) {
t.Parallel()
exp := []byte("win")
file := "output.txt"
outPath := fmt.Sprintf(`${%s}/%s`, env.AllocDir, file)
@ -206,6 +210,7 @@ func TestRawExecDriver_Start_Wait_AllocDir(t *testing.T) {
}
func TestRawExecDriver_Start_Kill_Wait(t *testing.T) {
t.Parallel()
task := &structs.Task{
Name: "sleep",
Driver: "raw_exec",
@ -255,6 +260,7 @@ func TestRawExecDriver_Start_Kill_Wait(t *testing.T) {
}
func TestRawExecDriverUser(t *testing.T) {
t.Parallel()
task := &structs.Task{
Name: "sleep",
Driver: "raw_exec",
@ -290,6 +296,7 @@ func TestRawExecDriverUser(t *testing.T) {
}
func TestRawExecDriver_HandlerExec(t *testing.T) {
t.Parallel()
task := &structs.Task{
Name: "sleep",
Driver: "raw_exec",

View file

@ -15,6 +15,7 @@ import (
)
func TestRawExecDriver_Signal(t *testing.T) {
t.Parallel()
task := &structs.Task{
Name: "signal",
Driver: "raw_exec",

View file

@ -21,6 +21,7 @@ import (
)
func TestRktVersionRegex(t *testing.T) {
t.Parallel()
if os.Getenv("NOMAD_TEST_RKT") == "" {
t.Skip("NOMAD_TEST_RKT unset, skipping")
}
@ -41,6 +42,7 @@ func TestRktVersionRegex(t *testing.T) {
// The fingerprinter test should always pass, even if rkt is not installed.
func TestRktDriver_Fingerprint(t *testing.T) {
t.Parallel()
if os.Getenv("NOMAD_TEST_RKT") == "" {
t.Skip("skipping rkt tests")
}
@ -70,6 +72,7 @@ func TestRktDriver_Fingerprint(t *testing.T) {
}
func TestRktDriver_Start_DNS(t *testing.T) {
t.Parallel()
if os.Getenv("NOMAD_TEST_RKT") == "" {
t.Skip("skipping rkt tests")
}
@ -121,6 +124,7 @@ func TestRktDriver_Start_DNS(t *testing.T) {
}
func TestRktDriver_Start_Wait(t *testing.T) {
t.Parallel()
if os.Getenv("NOMAD_TEST_RKT") == "" {
t.Skip("skipping rkt tests")
}
@ -180,6 +184,7 @@ func TestRktDriver_Start_Wait(t *testing.T) {
}
func TestRktDriver_Start_Wait_Skip_Trust(t *testing.T) {
t.Parallel()
if os.Getenv("NOMAD_TEST_RKT") == "" {
t.Skip("skipping rkt tests")
}
@ -233,6 +238,7 @@ func TestRktDriver_Start_Wait_Skip_Trust(t *testing.T) {
}
func TestRktDriver_Start_Wait_AllocDir(t *testing.T) {
t.Parallel()
if os.Getenv("NOMAD_TEST_RKT") == "" {
t.Skip("skipping rkt tests")
}
@ -305,6 +311,7 @@ func TestRktDriver_Start_Wait_AllocDir(t *testing.T) {
}
func TestRktDriverUser(t *testing.T) {
t.Parallel()
if os.Getenv("NOMAD_TEST_RKT") == "" {
t.Skip("skipping rkt tests")
}
@ -349,6 +356,7 @@ func TestRktDriverUser(t *testing.T) {
}
func TestRktTrustPrefix(t *testing.T) {
t.Parallel()
if os.Getenv("NOMAD_TEST_RKT") == "" {
t.Skip("skipping rkt tests")
}
@ -390,6 +398,7 @@ func TestRktTrustPrefix(t *testing.T) {
}
func TestRktTaskValidate(t *testing.T) {
t.Parallel()
ctestutils.RktCompatible(t)
task := &structs.Task{
Name: "etcd",
@ -415,6 +424,7 @@ func TestRktTaskValidate(t *testing.T) {
// TODO: Port Mapping test should be ran with proper ACI image and test the port access.
func TestRktDriver_PortsMapping(t *testing.T) {
t.Parallel()
if os.Getenv("NOMAD_TEST_RKT") == "" {
t.Skip("skipping rkt tests")
}
@ -479,6 +489,7 @@ func TestRktDriver_PortsMapping(t *testing.T) {
}
func TestRktDriver_HandlerExec(t *testing.T) {
t.Parallel()
if os.Getenv("NOMAD_TEST_RKT") == "" {
t.Skip("skipping rkt tests")
}

View file

@ -6,6 +6,7 @@ import (
)
func TestDriver_KillTimeout(t *testing.T) {
t.Parallel()
expected := 1 * time.Second
max := 10 * time.Second