Summary
Add unit tests for the execution cleanup background service which removes stale executions.
Current State
- File:
control-plane/internal/handlers/execution_cleanup.go
- Size: 242 lines
- Test coverage: None
What to Test
- Stale execution detection: Test that executions older than threshold are identified
- Batch processing: Test cleanup processes executions in batches
- Context cancellation: Test graceful shutdown when context is cancelled
- Error handling: Test behavior when storage operations fail
- Metrics tracking: Test that cleanup counts are tracked correctly
Implementation Notes
- Mock the execution store to return controlled test data
- Test different batch sizes and thresholds
- Verify logging output for cleanup operations
- Test edge cases (no stale executions, all stale executions)
Example Test Structure
func TestExecutionCleanup_CleansStaleExecutions(t *testing.T) {
// Setup mock store with stale executions
// Run cleanup
// Verify stale executions were cleaned
}
func TestExecutionCleanup_RespectsContextCancellation(t *testing.T) {
// Setup mock store
// Cancel context
// Verify cleanup stops gracefully
}
Acceptance Criteria
Files
- Source:
control-plane/internal/handlers/execution_cleanup.go
- Test:
control-plane/internal/handlers/execution_cleanup_test.go (new)
Using AI to solve this issue? Read our AI-Assisted Contributions guide for testing requirements, prompt strategies, and common pitfalls to avoid.
Summary
Add unit tests for the execution cleanup background service which removes stale executions.
Current State
control-plane/internal/handlers/execution_cleanup.goWhat to Test
Implementation Notes
Example Test Structure
Acceptance Criteria
execution_cleanup_test.gogo test ./internal/handlers/...Files
control-plane/internal/handlers/execution_cleanup.gocontrol-plane/internal/handlers/execution_cleanup_test.go(new)