diff options
Diffstat (limited to 'internal/executor/executor_test.go')
| -rw-r--r-- | internal/executor/executor_test.go | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/internal/executor/executor_test.go b/internal/executor/executor_test.go index f6d0179..a6c4ad8 100644 --- a/internal/executor/executor_test.go +++ b/internal/executor/executor_test.go @@ -596,15 +596,9 @@ func TestPool_RecoverStaleRunning(t *testing.T) { Status: "RUNNING", }) - pool.RecoverStaleRunning() + pool.RecoverStaleRunning(context.Background()) - recovered, err := store.GetTask(tk.ID) - if err != nil { - t.Fatalf("get task: %v", err) - } - if recovered.State != task.StateFailed { - t.Errorf("state: want FAILED, got %q", recovered.State) - } + // Execution record should be closed as FAILED. execs, _ := store.ListExecutions(tk.ID) if len(execs) == 0 || execs[0].Status != "FAILED" { t.Errorf("execution status: want FAILED, got %+v", execs) @@ -612,6 +606,24 @@ func TestPool_RecoverStaleRunning(t *testing.T) { if execs[0].ErrorMsg == "" { t.Error("expected non-empty error message on recovered execution") } + + // Task should be re-queued for retry and complete. + select { + case result := <-pool.Results(): + if result.TaskID != tk.ID { + t.Errorf("unexpected task in results: %s", result.TaskID) + } + case <-time.After(2 * time.Second): + t.Fatal("timed out waiting for stale RUNNING task to be re-queued and run") + } + recovered, err := store.GetTask(tk.ID) + if err != nil { + t.Fatalf("get task: %v", err) + } + // Top-level tasks (no parent) go to READY after a successful run. + if recovered.State != task.StateReady { + t.Errorf("state after re-queue: want READY, got %q", recovered.State) + } } func TestPool_RecoverStaleQueued_ResubmitsToPool(t *testing.T) { |
