From bba04072509f437241fc4c35b5d4bc7175dc95ac Mon Sep 17 00:00:00 2001 From: Juanadelacuesta <8647634+Juanadelacuesta@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:43:04 +0100 Subject: [PATCH] style: remove unused code and duplicated test --- drivers/rawexec/driver.go | 8 --- drivers/rawexec/driver_unix_test.go | 98 ----------------------------- 2 files changed, 106 deletions(-) diff --git a/drivers/rawexec/driver.go b/drivers/rawexec/driver.go index 764afb643..99b44fe7e 100644 --- a/drivers/rawexec/driver.go +++ b/drivers/rawexec/driver.go @@ -152,14 +152,6 @@ type Config struct { DeniedHostUidsStr string `codec:"denied_host_uids"` DeniedHostGidsStr string `codec:"denied_host_gids"` - - /* - // DeniedHostUids configures which host uids are disallowed - DeniedHostUids []validators.IDRange - - // DeniedHostGids configures which host gids are disallowed - DeniedHostGids []validators.IDRange - */ } // TaskConfig is the driver configuration of a task within a job diff --git a/drivers/rawexec/driver_unix_test.go b/drivers/rawexec/driver_unix_test.go index bf37b1ba4..4d5ca1b28 100644 --- a/drivers/rawexec/driver_unix_test.go +++ b/drivers/rawexec/driver_unix_test.go @@ -448,104 +448,6 @@ func TestRawExec_ExecTaskStreaming_User(t *testing.T) { require.Contains(t, stdout, "nobody") } -func TestRawExecUnixDriver_StartWaitRecoverWaitStop(t *testing.T) { - ci.Parallel(t) - require := require.New(t) - - d := newEnabledRawExecDriver(t) - harness := dtestutil.NewDriverHarness(t, d) - defer harness.Kill() - - config := &Config{Enabled: true} - var data []byte - require.NoError(basePlug.MsgPackEncode(&data, config)) - bconfig := &basePlug.Config{ - PluginConfig: data, - AgentConfig: &base.AgentConfig{ - Driver: &base.ClientDriverConfig{ - Topology: d.nomadConfig.Topology, - }, - }, - } - require.NoError(harness.SetConfig(bconfig)) - - allocID := uuid.Generate() - taskName := "sleep" - task := &drivers.TaskConfig{ - AllocID: allocID, - ID: uuid.Generate(), - Name: taskName, - Env: defaultEnv(), - Resources: testResources(allocID, taskName), - } - tc := &TaskConfig{ - Command: testtask.Path(), - Args: []string{"sleep", "100s"}, - } - require.NoError(task.EncodeConcreteDriverConfig(&tc)) - - testtask.SetTaskConfigEnv(task) - - cleanup := harness.MkAllocDir(task, false) - defer cleanup() - - harness.MakeTaskCgroup(allocID, taskName) - - handle, _, err := harness.StartTask(task) - require.NoError(err) - - ch, err := harness.WaitTask(context.Background(), task.ID) - require.NoError(err) - - var waitDone bool - var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() - result := <-ch - require.Error(result.Err) - waitDone = true - }() - - originalStatus, err := d.InspectTask(task.ID) - require.NoError(err) - - d.tasks.Delete(task.ID) - - wg.Wait() - require.True(waitDone) - _, err = d.InspectTask(task.ID) - require.Equal(drivers.ErrTaskNotFound, err) - - err = d.RecoverTask(handle) - require.NoError(err) - - status, err := d.InspectTask(task.ID) - require.NoError(err) - require.Exactly(originalStatus, status) - - ch, err = harness.WaitTask(context.Background(), task.ID) - require.NoError(err) - - wg.Add(1) - waitDone = false - go func() { - defer wg.Done() - result := <-ch - require.NoError(result.Err) - require.NotZero(result.ExitCode) - require.Equal(9, result.Signal) - waitDone = true - }() - - time.Sleep(300 * time.Millisecond) - require.NoError(d.StopTask(task.ID, 0, "SIGKILL")) - wg.Wait() - require.NoError(d.DestroyTask(task.ID, false)) - require.True(waitDone) - -} - func TestRawExecDriver_StartWaitRecoverWaitStop(t *testing.T) { ci.Parallel(t) require := require.New(t)