From 6dc83ca7b5a2e15c21bae03edd80d0c5b3c794c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Pa=C3=9F?= <22845248+mpass99@users.noreply.github.com> Date: Sun, 17 Sep 2023 20:02:04 +0200 Subject: [PATCH] Add regression test for rescheduled used runners being removed. As they are already rescheduled and therefore recreated they do not need to be removed, but can be handled as a new runner. --- internal/runner/nomad_runner_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/internal/runner/nomad_runner_test.go b/internal/runner/nomad_runner_test.go index d8247c3..7681ba2 100644 --- a/internal/runner/nomad_runner_test.go +++ b/internal/runner/nomad_runner_test.go @@ -105,6 +105,33 @@ func (s *MainTestSuite) TestFromContextReturnsIsNotOkWhenContextHasNoRunner() { s.False(ok) } +func (s *MainTestSuite) TestDestroyDoesNotPropagateToNomadForSomeReasons() { + apiMock := &nomad.ExecutorAPIMock{} + timer := &InactivityTimerMock{} + timer.On("StopTimeout").Return() + ctx, cancel := context.WithCancel(s.TestCtx) + r := &NomadJob{ + executions: storage.NewLocalStorage[*dto.ExecutionRequest](), + InactivityTimer: timer, + id: tests.DefaultRunnerID, + api: apiMock, + ctx: ctx, + cancel: cancel, + } + + s.Run("destroy removes the runner only locally for OOM Killed Allocations", func() { + err := r.Destroy(ErrOOMKilled) + s.NoError(err) + apiMock.AssertExpectations(s.T()) + }) + + s.Run("destroy removes the runner only locally for rescheduled allocations", func() { + err := r.Destroy(nomad.ErrorAllocationRescheduled) + s.NoError(err) + apiMock.AssertExpectations(s.T()) + }) +} + func TestExecuteInteractivelyTestSuite(t *testing.T) { suite.Run(t, new(ExecuteInteractivelyTestSuite)) }