From 3f884bb3faa70d2618991ef8ea8e510444528e51 Mon Sep 17 00:00:00 2001 From: Juanadelacuesta <8647634+Juanadelacuesta@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:53:40 +0100 Subject: [PATCH] fix: remove the setConfig and modify the test driver to include idValidator to avoid panics --- drivers/exec/driver_test.go | 8 ++++---- drivers/rawexec/driver_test.go | 1 - drivers/rawexec/driver_unix_test.go | 4 ++++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/exec/driver_test.go b/drivers/exec/driver_test.go index 93279f166..66af7965c 100644 --- a/drivers/exec/driver_test.go +++ b/drivers/exec/driver_test.go @@ -150,7 +150,6 @@ func TestExecDriver_StartWait(t *testing.T) { Args: []string{"/proc/self/cgroup"}, } require.NoError(t, task.EncodeConcreteDriverConfig(&tc)) - //require.NoError(t, harness.SetConfig(&base.Config{})) cleanup := harness.MkAllocDir(task, false) defer cleanup() @@ -187,7 +186,6 @@ func TestExecDriver_StartWaitStopKill(t *testing.T) { Args: []string{"-c", "echo hi; sleep 600"}, } require.NoError(t, task.EncodeConcreteDriverConfig(&tc)) - //require.NoError(t, harness.SetConfig(&base.Config{})) cleanup := harness.MkAllocDir(task, false) defer cleanup() @@ -253,7 +251,6 @@ func TestExecDriver_StartWaitRecover(t *testing.T) { Args: []string{"5"}, } require.NoError(t, task.EncodeConcreteDriverConfig(&tc)) - //require.NoError(t, harness.SetConfig(&base.Config{})) cleanup := harness.MkAllocDir(task, false) defer cleanup() @@ -457,7 +454,6 @@ func TestExecDriver_Stats(t *testing.T) { Args: []string{"5"}, } require.NoError(t, task.EncodeConcreteDriverConfig(&tc)) - require.NoError(t, harness.SetConfig(&base.Config{})) cleanup := harness.MkAllocDir(task, false) defer cleanup() @@ -886,6 +882,10 @@ func TestDriver_Config_setDeniedIds(t *testing.T) { defer cancel() d := newExecDriverTest(t, ctx) + + // Force the creation of the validatior. + d.(*Driver).userIDValidator = nil + harness := dtestutil.NewDriverHarness(t, d) defer harness.Kill() diff --git a/drivers/rawexec/driver_test.go b/drivers/rawexec/driver_test.go index f2825379f..506c0669d 100644 --- a/drivers/rawexec/driver_test.go +++ b/drivers/rawexec/driver_test.go @@ -233,7 +233,6 @@ func TestRawExecDriver_StartWait(t *testing.T) { Args: []string{"sleep", "10ms"}, } require.NoError(task.EncodeConcreteDriverConfig(&tc)) - //require.NoError(harness.SetConfig(&base.Config{})) testtask.SetTaskConfigEnv(task) diff --git a/drivers/rawexec/driver_unix_test.go b/drivers/rawexec/driver_unix_test.go index 81ba252ca..6912590a3 100644 --- a/drivers/rawexec/driver_unix_test.go +++ b/drivers/rawexec/driver_unix_test.go @@ -587,6 +587,10 @@ func TestRawExec_Validate(t *testing.T) { } { d := newEnabledRawExecDriver(t) + + // Force the creation of the validatior, the mock is used by newEnabledRawExecDriver by default + d.userIDValidator = nil + harness := dtestutil.NewDriverHarness(t, d) defer harness.Kill()