diff options
Diffstat (limited to 'internal/executor/executor_test.go')
| -rw-r--r-- | internal/executor/executor_test.go | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/internal/executor/executor_test.go b/internal/executor/executor_test.go index 67b2764..ad496e7 100644 --- a/internal/executor/executor_test.go +++ b/internal/executor/executor_test.go @@ -1543,20 +1543,32 @@ func TestPool_MaxPerAgent_AllowsDifferentAgents(t *testing.T) { } } -func TestPool_ConsecutiveFailures_DrainAtTwo(t *testing.T) { +func TestPool_ConsecutiveFailures_DrainAtThree(t *testing.T) { store := testStore(t) runner := &mockRunner{err: fmt.Errorf("boom")} runners := map[string]Runner{"claude": runner} logger := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelError})) - pool := NewPool(2, runners, store, logger) + pool := NewPool(3, runners, store, logger) - // Submit two failing tasks + // Two failures should NOT drain. for _, id := range []string{"cf-1", "cf-2"} { tk := makeTask(id) store.CreateTask(tk) pool.Submit(context.Background(), tk) - <-pool.Results() // drain + <-pool.Results() } + pool.mu.Lock() + draineEarly := pool.drained["claude"] + pool.mu.Unlock() + if draineEarly { + t.Error("expected claude NOT drained after only 2 failures") + } + + // Third failure should drain. + tk3 := makeTask("cf-3") + store.CreateTask(tk3) + pool.Submit(context.Background(), tk3) + <-pool.Results() pool.mu.Lock() drained := pool.drained["claude"] @@ -1564,18 +1576,18 @@ func TestPool_ConsecutiveFailures_DrainAtTwo(t *testing.T) { pool.mu.Unlock() if !drained { - t.Error("expected claude to be drained after 2 consecutive failures") + t.Error("expected claude to be drained after 3 consecutive failures") } - if failures < 2 { - t.Errorf("expected consecutiveFailures >= 2, got %d", failures) + if failures < 3 { + t.Errorf("expected consecutiveFailures >= 3, got %d", failures) } - // The second task should have a drain question set - tk2, err := store.GetTask("cf-2") + // The third task should have a drain question set. + tk3fetched, err := store.GetTask("cf-3") if err != nil { t.Fatalf("GetTask: %v", err) } - if tk2.QuestionJSON == "" { + if tk3fetched.QuestionJSON == "" { t.Error("expected drain question to be set on task after drain") } } |
