| path | /home/tom/github/semcod/vallm |
|---|
This document describes the comprehensive testing suite for vallm, covering E2E tests, Docker installation tests, and CI/CD workflows.
- All CLI commands:
validate,check,batch,info - Options testing:
--semantic,--security,--model,--verbose - Batch validation: recursive, include/exclude patterns, JSON/text output
- Multi-language support: Python, JavaScript, Go, Rust
- Error handling: missing files, syntax errors, invalid options
- Configuration: config files, environment variables
- pip installation: editable mode, wheel installation, with extras
- pipx installation: editable mode, with extras
- Post-installation validation: basic functionality, language detection
- Virtual environment testing: isolated installation testing
- LLM integration: mock providers, availability checks
- Code quality assessment: good code, bad code, syntax errors
- Multi-language semantic analysis: Python, JavaScript, Go, Rust
- Reference code comparison: diff-based analysis
- Edge cases: empty code, very long code, unsupported languages
- Multi-system support: Ubuntu 22.04/24.04, Debian 12, Alpine, Fedora 39, CentOS 9
- Python images: slim, Alpine variants
- Post-installation validation: help, info, basic validation
- Cross-platform compatibility: different package managers, Python versions
pytest tests/test_cli_e2e.py -v pytest tests/test_installation.py -v pytest tests/test_semantic_validation.py -v
pytest tests/ --cov=vallm --cov-report=html
pytest tests/ --benchmark-only
# Test Docker installation across systems
./scripts/test_docker_installation.sh
# Test specific Docker stage
docker build --target ubuntu-22 -t vallm-test -f Dockerfile.test .
docker run --rm vallm-test vallm --help
The comprehensive GitHub Actions workflow includes:
- Matrix testing: multiple OS and Python versions
- Docker testing: multi-system installation
- Integration testing: LLM integration with Ollama
- Performance testing: large project validation
- Security testing: vulnerability scanning
- Compatibility testing: pip/pipx installation
- Documentation testing: README examples validation
- VallmCLI: Helper for running CLI commands
- temp_project: Temporary project with multiple files
- mock_llm: Mock LLM provider for semantic tests
- Unit Tests: Individual component testing
- Integration Tests: Component interaction testing
- E2E Tests: Full workflow testing
- Performance Tests: Speed and resource usage
- Security Tests: Vulnerability detection
- Compatibility Tests: Cross-platform testing
- Push: main, develop branches
- Pull Request: main, develop branches
- Schedule: Weekly (Sundays at 2 AM UTC)
- test-matrix: Multi-OS, multi-Python version testing
- docker-tests: Docker installation across systems
- integration-tests: LLM integration testing
- performance-tests: Large project validation
- security-tests: Vulnerability scanning
- compatibility-tests: pip/pipx installation
- documentation-tests: README examples validation
- Codecov: Upload coverage reports
- HTML reports: Local coverage visualization
- Threshold: 85% coverage target
MOCK_LLM_RESPONSES = { "good_code": {"verdict": "pass", "score": 0.9}, "bad_code": {"verdict": "review", "score": 0.3}, "syntax_error": {"verdict": "fail", "score": 0.1} }
# Temporary test projects
@pytest.fixture
def temp_project():
with tempfile.TemporaryDirectory() as tmpdir:
# Create test files...
yield project_dir
- Validation speed: files/second
- Memory usage: peak memory consumption
- Startup time: CLI command initialization
- LLM integration: response time for semantic validation
time vallm batch large_project --recursive
python -m memory_profiler vallm batch project --recursive
# Bandit security scan
bandit -r src/ -f json -o bandit-report.json
# Safety dependency check
safety check --json --output safety-report.json
# vallm security validation
vallm batch security_test --recursive --security
- Dangerous functions:
os.system(),eval(),exec() - Shell injection:
subprocesswith shell=True - Hardcoded secrets: passwords, API keys
- SQL injection: string concatenation in queries
- LLM not available: Use mock providers in tests
- Docker build failures: Check base image availability
- Permission errors: Use proper file permissions
- Network issues: Mock external dependencies
pytest tests/test_cli_e2e.py::TestCLICommands::test_help_command -v
### Adding New Tests
1. Create test file in `tests/` directory
2. Follow naming convention: `test_<module>.py`
3. Use pytest fixtures for setup/teardown
4. Add mock for external dependencies
5. Update CI/CD workflow if needed
### Test Requirements
- **Coverage**: New features must have test coverage
- **CI/CD**: All tests must pass in CI/CD
- **Documentation**: Update testing guide
- **Performance**: Add benchmarks for performance-critical code
### Planned Additions
- **Property-based testing**: Hypothesis integration
- **Contract testing**: API contract validation
- **Load testing**: High-volume validation testing
- **Chaos testing**: Fault injection testing
- **A/B testing**: Different algorithm comparisons
### Tool Integration
- **Selenium**: Web UI testing (if applicable)
- **Playwright**: End-to-end web testing
- **Locust**: Load testing framework
- **Chaos Monkey**: Fault injection testing