Skip to content

Commit e1d5ba5

Browse files
committed
feat: add /debug-test slash command for analyzing test failures
Signed-off-by: emmaaroche <eroche@redhat.com>
1 parent 207e607 commit e1d5ba5

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

.claude/commands/debug-test.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
description: Analyze test failures and suggest fixes
3+
---
4+
5+
# Debug Test Failures
6+
7+
Analyze test failures and suggest fixes.
8+
9+
## Instructions
10+
11+
Follow these steps to analyze the test failure:
12+
13+
1. **Extract file path from traceback**: The error shows the failing file path (e.g., `testsuite/tests/.../test_basic.py:39`)
14+
15+
2. **Read test file and trace fixtures**:
16+
- Read the test file at the path from the traceback
17+
- Look at fixtures (function parameters) and imports that the test uses
18+
- Read `conftest.py` in same directory, then parent directories if needed
19+
- Understand what the test expects vs what's actually happening
20+
21+
3. **Categorize the failure**:
22+
- Identify the pattern (see `Common Failure Patterns` below)
23+
- Determine if this is a test/code issue or an environment/cluster state issue
24+
25+
4. **Provide appropriate response**:
26+
- **If investigation needed**: Suggest kubectl commands to check policy status, conditions, events, logs, and verify resources exist and are ready
27+
- **If cluster/environment issue**: Provide kubectl/cleanup commands to fix cluster state
28+
- **If test/code issue**: Suggest code changes to fixtures or tests
29+
- **Mixed approach**: Combine multiple approaches as needed (e.g., investigate first, then apply fixes based on what you find)
30+
31+
## Common Failure Patterns
32+
33+
- **Policy not enforced**: Expected 302/401/429 but got 200 (policy not attached, wrong route/gateway, wrong host, or enforcement not yet propagated)
34+
- **Policy targeting**: `is_affected_by()` returns `False` (wrong `targetRef`, `parentRef`, namespace, labels, or resource mismatch)
35+
- **Reconciliation / propagation delay**: Async reconciliation not finished, config/policy not pushed, `observedGeneration` not catching up, race conditions
36+
- **DNS resolution / propagation**: `NXDOMAIN`, stale records (external DNS delay or caching, record deletion not fully propagated)
37+
- **DNS provider / credentials**: `DNSProviderError` (missing/misnamed/wrong-namespace secret, provider throttling or rate limits)
38+
- **Dependency missing or not found**: Policy `Accepted=False`, `reason=MissingDependency`, or selector found no objects (`selected 0`)
39+
(required operator/backend not installed, wrong namespace, or wrong labels, e.g., Authorino, Limitador)
40+
- **Component not ready**: Dependency installed but not `Ready` (slow rollout or readiness probe delays)
41+
- **Connectivity / request timeouts**: Gateway or Listener not ready, LoadBalancer provisioning delay, DNS resolves but traffic does not route, client `httpx` connect/read timeouts
42+
- **Wrong endpoint hit**: Test traffic bypasses the intended Gateway or Route (wrong URL, scheme, port, or hostname)
43+
- **Stale state / cleanup issues**: Leftover resources from previous tests (policies, routes, DNS records, namespaces not fully deleted)
44+
- **Invalid or rejected configuration**: Policy `Accepted=False` with reasons like `Invalid` or `TargetNotFound` (bad references, missing targets, wrong issuer/secret)
45+
- **Status / model mismatch**: `MissingModelBranch` (testsuite expects status/conditions not present, CRD or controller output drift)
46+
47+
## Output Format
48+
49+
**Issue**: [Summary of the problem]
50+
51+
**Root cause**: [Summary of why it's failing, or "needs more investigation" if unclear]
52+
53+
**Recommended steps**: [One or more steps - can be investigation, code changes, environment fixes, or a mix]
54+
55+
_NOTE:_ Do NOT auto-run bash/kubectl commands before providing direct analysis and recommendations.

0 commit comments

Comments
 (0)