@debugmcp/mcp-debugger
Version:
Run-time step-through debugging for LLM agents.
129 lines (101 loc) • 4.24 kB
Markdown
# Smoke Tests Implementation Summary
## Overview
Successfully implemented SSE and containerized smoke tests for the MCP debugger server, complementing the existing stdio smoke test. These tests provide comprehensive coverage of all transport mechanisms and deployment scenarios.
## Files Created/Modified
### 1. **tests/e2e/smoke-test-utils.ts** (New)
Shared utilities for all smoke tests:
- `executeDebugSequence()` - Common debug workflow
- `isDockerAvailable()` - Docker availability check
- `waitForPort()` - SSE server health check
- `cleanupDocker()` - Container cleanup
- `getVolumeMount()` - Cross-platform volume mounting
- `generateContainerName()` - Unique container naming
- `ensureDockerImage()` - Smart Docker image building
### 2. **tests/e2e/mcp-server-smoke-sse.test.ts** (New)
SSE transport smoke test:
- Tests SSE (Server-Sent Events) transport
- Uses random port allocation (49152-65535 range)
- Fallback mechanism if server output not detected
- Tests from both project root and temp directory
- Comprehensive error handling and cleanup
### 3. **tests/e2e/mcp-server-smoke-container.test.ts** (New)
Containerized deployment smoke test:
- Tests Docker containerized deployment
- Verifies path translation (host → container paths)
- Smart Docker image caching
- Graceful skip if Docker not available
- Tests volume mounting and environment variables
- Captures container logs on failure
### 4. **package.json** (Modified)
Added convenience script:
```json
"test:e2e:smoke": "vitest run tests/e2e/mcp-server-smoke*.test.ts"
```
### 5. **tests/e2e/README.md** (New)
Comprehensive documentation covering:
- Test file descriptions
- Running instructions
- Prerequisites
- Test coverage details
- Troubleshooting guide
## Key Features Implemented
### 1. **Robust Error Handling**
- Proper cleanup in `afterEach` hooks
- Try/finally blocks for resource cleanup
- Detailed error logging with context
- Container logs captured on failure
### 2. **Cross-Platform Compatibility**
- Windows path handling for Docker volumes
- Platform-specific command adjustments
- Dynamic port allocation to avoid conflicts
### 3. **Performance Optimizations**
- Docker image caching (check before build)
- Random port allocation for parallel testing
- 2-second fallback for SSE server detection
### 4. **Developer Experience**
- Clear logging prefixes (`[SSE Smoke Test]`, `[Container Smoke Test]`)
- Graceful skip messages when prerequisites missing
- Detailed error context for debugging
- Consistent test structure across all smoke tests
## Test Coverage
The three smoke tests now provide comprehensive coverage:
1. **Transport Coverage**
- stdio (existing test)
- SSE (new test)
- containerized stdio (new test)
2. **Path Resolution**
- Running from project root
- Running from different directories
- Container path translation
3. **Environment Scenarios**
- Native execution
- Containerized execution
- Different working directories
## Running the Tests
```bash
# Run all smoke tests
npm run test:e2e:smoke
# Run individual tests
npx vitest run tests/e2e/mcp-server-smoke-sse.test.ts
npx vitest run tests/e2e/mcp-server-smoke-container.test.ts
```
## Known Considerations
### SSE Test
- Uses specific port allocation instead of port 0 due to output detection
- Fallback mechanism if server doesn't output to stdout/stderr
- 2-second timeout before checking health endpoint
### Container Test
- Requires Docker to be installed and running
- First run may be slow due to image building
- Uses unique container names to avoid conflicts
## Benefits
1. **Complete Transport Coverage**: All three transport methods are now tested
2. **Deployment Confidence**: Container tests verify production-like deployment
3. **Path Translation Verification**: Ensures container path mapping works correctly
4. **Maintainable Code**: Shared utilities reduce duplication
5. **Developer Friendly**: Clear skip conditions and error messages
## Next Steps
The smoke tests are ready for use and can be integrated into CI/CD pipelines. Consider:
- Adding to GitHub Actions workflow
- Setting up Docker in CI environment for container tests
- Monitoring test execution times for optimization opportunities