@debugmcp/mcp-debugger
Version:
Run-time step-through debugging for LLM agents.
116 lines (90 loc) • 4.26 kB
Markdown
# Task 27: Debug Docker Test Timeout and Remove Conditional Skips - Summary
## Overview
Task 27 successfully removed all conditional skips from Docker container tests and improved test diagnostics. The tests now fail loudly when Docker is unavailable, following the project's testing philosophy.
## Test Status
- **2 tests passing** in `tests/e2e/mcp-server-smoke-container.test.ts`
- **0 tests skipped** (conditional skips removed)
- **No timeouts** affecting test execution (cleanup warnings don't break tests)
## Changes Made
### 1. Removed Conditional Skips
- Removed all `this.skip()` patterns when Docker is unavailable
- Tests now throw clear error messages when Docker is required but not available
- Added comment explaining the project's testing philosophy
### 2. Enhanced Diagnostics
- Added timestamp logging throughout test execution
- Added container name logging for better traceability
- Capture and display container logs on failure
- Added detailed error messages for Docker availability checks
### 3. Improved Container Management
- Generate unique container names to prevent conflicts
- Extended afterEach cleanup timeout to 30 seconds
- Import container management utilities from smoke-test-utils
- Proper container cleanup even when tests fail
### 4. Better Error Messages
```javascript
if (!dockerAvailable) {
throw new Error('Docker is required for this test but is not available. Please install Docker and ensure it is running.');
}
```
## Implementation Details
### Container Name Generation
```javascript
activeContainerName = generateContainerName('mcp-fibonacci-test');
// Example: mcp-fibonacci-test-1752177488061-zq4lsq0yp
```
### Timestamped Logging
```javascript
console.log(`[${Date.now() - startTime}ms] Building Docker image...`);
console.log(`[${Date.now() - startTime}ms] Docker image ready`);
```
### Container Cleanup
```javascript
afterEach(async function() {
if (activeContainerName) {
try {
await cleanupDocker(activeContainerName);
console.log(`[Container Smoke Test] Cleaned up container: ${activeContainerName}`);
} catch (e) {
console.error(`[Container Smoke Test] Error cleaning up container ${activeContainerName}:`, e);
}
activeContainerName = null;
}
}, 30000); // 30 second timeout for cleanup
```
## Test Results
### Test 1: fibonacci.py Debug Test
- **Duration**: 60.3 seconds
- **Status**: ✓ Passed
- Successfully builds Docker image, connects to containerized MCP server, and executes debug sequence
### Test 2: Absolute Path Rejection Test
- **Duration**: 17.8 seconds
- **Status**: ✓ Passed
- Correctly rejects absolute host paths and accepts relative paths in container mode
## Minor Issues (Non-Breaking)
### Docker Cleanup Timeouts
- `docker stop` commands timeout after 10 seconds during cleanup
- This generates warnings but doesn't affect test results
- Tests still pass and containers are eventually cleaned up
Example warning:
```
[Smoke Test] Error during Docker cleanup: Error: Command timed out after 10000ms: docker stop mcp-fibonacci-test-1752177488061-zq4lsq0yp
```
## Testing Philosophy
The implementation now follows the project's testing philosophy:
> Tests should fail loudly when dependencies are unavailable rather than being silently skipped.
This ensures:
- No hidden failures due to missing dependencies
- Clear visibility of environment requirements
- Better CI/CD pipeline reliability
## Future Improvements
1. **Optimize Container Cleanup**: Consider using `docker kill` instead of `docker stop` for faster cleanup
2. **Parallel Container Management**: Add container tracking to prevent orphaned containers
3. **Test Tagging**: When Vitest supports proper tagging, add `@requires-docker` tags
4. **Performance**: The tests take ~78 seconds total, which could be optimized
## Impact
This implementation ensures:
- **No silent test skips** - all tests run or fail explicitly
- **Better debugging** - comprehensive logging helps diagnose issues
- **Cleaner test environment** - proper container cleanup prevents resource leaks
- **Consistent behavior** - tests behave the same locally and in CI/CD
The removal of conditional skips aligns with the project's commitment to test transparency and reliability.