Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,40 @@ CI checks include:
4. Coverage report generation
5. Coverage threshold validation

### Test Parallelization Strategy

The project uses a multi-level parallelization strategy to optimize CI time:

#### Unit Tests (Jest Workers)
- Unit tests run in parallel using Jest's worker pool
- Configuration: `maxWorkers: '50%'` uses half of available CPU cores
- Tests are isolated and have no shared state, making them safe to parallelize
- Run time: ~6-8 seconds for 549 tests

#### Integration Tests (GitHub Actions Matrix)
- Integration tests run in separate GitHub Actions runners using a matrix strategy
- Each test file runs in its own isolated environment to avoid Docker conflicts
- Test files run in parallel across multiple runners:
- `basic-firewall.test.ts` - Core firewall functionality
- `robustness.test.ts` - Comprehensive edge cases
- `volume-mounts.test.ts` - Volume mount functionality
- `container-workdir.test.ts` - Working directory configuration
- `no-docker.test.ts` - Docker-in-Docker removal verification

**Why Integration Tests Can't Use Jest Workers:**
- Integration tests use Docker containers that share network resources
- Running multiple tests simultaneously would cause:
- Docker network subnet pool exhaustion
- Container name conflicts
- Port binding conflicts
- The `maxWorkers: 1` setting in `jest.integration.config.js` ensures sequential execution within each runner

**Benefits of Matrix Strategy:**
- Each test file runs on a dedicated runner (full isolation)
- All test files run in parallel (reduces wall-clock time)
- `fail-fast: false` ensures all tests complete even if one fails
- Individual test artifacts are captured for failed tests

## Debugging Tests

### Running Tests in Debug Mode
Expand Down
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ module.exports = {
statements: 38,
},
},
// Parallel test execution - use 50% of available CPUs to balance speed and resource usage
// Unit tests are isolated and safe to run in parallel
maxWorkers: '50%',
};
Loading