tests: create fresh harness for each docker dns test

Not actually sure this fixes the flaky tests, but seems
like it could be related.
This commit is contained in:
Seth Hoenig 2022-03-31 08:04:40 -05:00
parent a897ad63aa
commit 174a7532a1
1 changed files with 23 additions and 20 deletions

View File

@ -815,16 +815,12 @@ func Test_dnsConfig(t *testing.T) {
ci.Parallel(t) ci.Parallel(t)
testutil.DockerCompatible(t) testutil.DockerCompatible(t)
require := require.New(t)
harness := dockerDriverHarness(t, nil)
defer harness.Kill()
cases := []struct { cases := []struct {
name string name string
cfg *drivers.DNSConfig cfg *drivers.DNSConfig
}{ }{
{ {
name: "nil DNSConfig", name: "nil",
}, },
{ {
name: "basic", name: "basic",
@ -843,24 +839,31 @@ func Test_dnsConfig(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
taskCfg := newTaskConfig("", []string{"/bin/sleep", "1000"}) t.Run(c.name, func(t *testing.T) {
task := &drivers.TaskConfig{ harness := dockerDriverHarness(t, nil)
ID: uuid.Generate(),
Name: "nc-demo",
AllocID: uuid.Generate(),
Resources: basicResources,
DNS: c.cfg,
}
require.NoError(task.EncodeConcreteDriverConfig(&taskCfg))
cleanup := harness.MkAllocDir(task, false) taskCfg := newTaskConfig("", []string{"/bin/sleep", "1000"})
defer cleanup() task := &drivers.TaskConfig{
ID: uuid.Generate(),
Name: "nc-demo",
AllocID: uuid.Generate(),
Resources: basicResources,
DNS: c.cfg,
}
require.NoError(t, task.EncodeConcreteDriverConfig(&taskCfg))
_, _, err := harness.StartTask(task) cleanup := harness.MkAllocDir(task, false)
require.NoError(err)
defer harness.DestroyTask(task.ID, true)
dtestutil.TestTaskDNSConfig(t, harness, task.ID, c.cfg) _, _, err := harness.StartTask(task)
require.NoError(t, err)
dtestutil.TestTaskDNSConfig(t, harness, task.ID, c.cfg)
// cleanup immediately before the next test case
require.NoError(t, harness.DestroyTask(task.ID, true))
cleanup()
harness.Kill()
})
} }
} }