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)
testutil.DockerCompatible(t)
require := require.New(t)
harness := dockerDriverHarness(t, nil)
defer harness.Kill()
cases := []struct {
name string
cfg *drivers.DNSConfig
}{
{
name: "nil DNSConfig",
name: "nil",
},
{
name: "basic",
@ -843,6 +839,9 @@ func Test_dnsConfig(t *testing.T) {
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
harness := dockerDriverHarness(t, nil)
taskCfg := newTaskConfig("", []string{"/bin/sleep", "1000"})
task := &drivers.TaskConfig{
ID: uuid.Generate(),
@ -851,16 +850,20 @@ func Test_dnsConfig(t *testing.T) {
Resources: basicResources,
DNS: c.cfg,
}
require.NoError(task.EncodeConcreteDriverConfig(&taskCfg))
require.NoError(t, task.EncodeConcreteDriverConfig(&taskCfg))
cleanup := harness.MkAllocDir(task, false)
defer cleanup()
_, _, err := harness.StartTask(task)
require.NoError(err)
defer harness.DestroyTask(task.ID, true)
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()
})
}
}