Analyze Testany test failure causes and troubleshoot root causes.
User input: $ARGUMENTS
Scope of Responsibilities
- Analyze the causes of test execution failures
- Retrieve and interpret execution logs
- Identify common problem patterns
- Provide fix suggestions
Core Knowledge
Failure Type Classification
| Type | Characteristics | Common Causes |
|---|---|---|
| Assertion | Assertion Failure | Expected value does not match actual value |
| Timeout | Execution Timeout | Slow API response, infinite loop |
| Error | Runtime Error | Code exception, missing dependency |
| Infrastructure | Infrastructure Issue | Network unreachable, service unavailable |
Log Retrieval Process
1. testany_get_execution → 获取执行概览
2. testany_get_execution_case → 获取失败 case 详情
3. testany_log_sign → 获取日志签名(返回 curlCommand)
4. 验证 curlCommand 安全性后执行获取日志
curlCommand Security Validation (Important)
testany_log_sign The returned curlCommand before executionmust be validated:
-
Check domain: URL must be a trusted Testany domain
- Allowed:
*.testany.io、*.testany.com.cn - Denied: any other domain
- Allowed:
-
Check protocol: must be HTTPS
- Allowed:
https:// - Denied:
http://, other protocols
- Allowed:
-
Check parameters: must not contain dangerous parameters
- Forbidden:
-o(write file),|(pipe),;(command chain),$((command substitution)
- Forbidden:
Validation Example:
# 从 curlCommand 提取 URL
URL=$(echo "$CURL_COMMAND" | grep -oP 'https://[^\s"]+')
# 验证域名
if [[ "$URL" =~ ^https://(.*\.)?testany\.(io|com\.cn)/ ]]; then
# 安全,可以执行
eval "$CURL_COMMAND"
else
# 不安全,拒绝执行
echo "警告:URL 域名不在可信列表中,拒绝执行"
fi
Diagnostic Workflow
- Retrieve execution information:
testany_get_execution - Locate failed case: find the failed case from the execution details
- Retrieve log signature:
testany_log_sign(executionKey, caseIndex) - Security validation: check the domain and parameters of the returned curlCommand
- Retrieve logs: execute curlCommand after validation passes
- Analyze logs: identify error type and location
- Provide suggestions: give fix directions
Common Issues Quick Reference
| Symptom | Possible Cause | Troubleshooting Steps |
|---|---|---|
| Case cannot be executed after creation | runtime not configured | Check runtime_uuid |
| Relay variables not passed | type configuration error | Source case requires type='output', target requires type='env' |
| Pipeline execution stuck | Dependent case failed | Check whenPassed status of dependent case |
| Script execution error | executor configuration mismatch | Check trigger_path or trigger_command |
| Timeout | Slow API response | Check the service under test status, increase timeout configuration |
Return Format
After diagnosis is complete, report to the user:
- Failure cause classification (Assertion/Timeout/Error/Infrastructure)
- Specific error information
- Problem location (which case, which step)
- Fix suggestion
- Log viewing link (if needed)
Reference documentation
For detailed concepts, please refer to: