summaryrefslogtreecommitdiff
path: root/internal/executor/executor_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/executor/executor_test.go')
-rw-r--r--internal/executor/executor_test.go99
1 files changed, 1 insertions, 98 deletions
diff --git a/internal/executor/executor_test.go b/internal/executor/executor_test.go
index 64e3ecb..267d9ca 100644
--- a/internal/executor/executor_test.go
+++ b/internal/executor/executor_test.go
@@ -1132,7 +1132,6 @@ func newPoolWithMockStore(store Store) *Pool {
rateLimited: make(map[string]time.Time),
cancels: make(map[string]context.CancelFunc),
consecutiveFailures: make(map[string]int),
- drained: make(map[string]bool),
resultCh: make(chan *Result, 4),
workCh: make(chan workItem, 4),
doneCh: make(chan struct{}, 2),
@@ -1589,55 +1588,6 @@ func TestPool_MaxPerAgent_AllowsDifferentAgents(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(3, runners, store, logger)
-
- // 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()
- }
- 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"]
- failures := pool.consecutiveFailures["claude"]
- pool.mu.Unlock()
-
- if !drained {
- t.Error("expected claude to be drained after 3 consecutive failures")
- }
- if failures < 3 {
- t.Errorf("expected consecutiveFailures >= 3, got %d", failures)
- }
-
- // The third task should have a drain question set.
- tk3fetched, err := store.GetTask("cf-3")
- if err != nil {
- t.Fatalf("GetTask: %v", err)
- }
- if tk3fetched.QuestionJSON == "" {
- t.Error("expected drain question to be set on task after drain")
- }
-}
-
func TestPool_ConsecutiveFailures_ResetOnSuccess(t *testing.T) {
store := testStore(t)
@@ -1668,7 +1618,7 @@ func TestPool_ConsecutiveFailures_ResetOnSuccess(t *testing.T) {
t.Errorf("expected 1 failure after first task, got %d", failsBefore)
}
- // Second task succeeds
+ // Second task succeeds — counter resets.
tk2 := makeTask("rs-2")
store.CreateTask(tk2)
pool.Submit(context.Background(), tk2)
@@ -1676,15 +1626,11 @@ func TestPool_ConsecutiveFailures_ResetOnSuccess(t *testing.T) {
pool.mu.Lock()
failsAfter := pool.consecutiveFailures["claude"]
- isDrained := pool.drained["claude"]
pool.mu.Unlock()
if failsAfter != 0 {
t.Errorf("expected consecutiveFailures reset to 0 after success, got %d", failsAfter)
}
- if isDrained {
- t.Error("expected drained to be false after success")
- }
}
func TestPool_CheckStoryCompletion_AllComplete(t *testing.T) {
@@ -1772,49 +1718,6 @@ func TestPool_CheckStoryCompletion_PartialComplete(t *testing.T) {
}
}
-func TestPool_Undrain_ResumesExecution(t *testing.T) {
- store := testStore(t)
-
- // Force drain state
- runner := &mockRunner{}
- 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.mu.Lock()
- pool.drained["claude"] = true
- pool.consecutiveFailures["claude"] = 3
- pool.mu.Unlock()
-
- // Undrain
- pool.UndrainingAgent("claude")
-
- pool.mu.Lock()
- drained := pool.drained["claude"]
- failures := pool.consecutiveFailures["claude"]
- pool.mu.Unlock()
-
- if drained {
- t.Error("expected drained=false after UndrainingAgent")
- }
- if failures != 0 {
- t.Errorf("expected consecutiveFailures=0 after UndrainingAgent, got %d", failures)
- }
-
- // Verify a task can now run
- tk := makeTask("undrain-1")
- store.CreateTask(tk)
- pool.Submit(context.Background(), tk)
- select {
- case result := <-pool.Results():
- if result.Err != nil {
- t.Errorf("unexpected error after undrain: %v", result.Err)
- }
- case <-time.After(5 * time.Second):
- t.Fatal("timed out waiting for task after undrain")
- }
-}
-
func TestPool_StoryDeploy_RunsDeployScript(t *testing.T) {
store := testStore(t)
runner := &mockRunner{}