⚠️ DISCLAIMER: Experimental ProjectThis project is an experimental codebase created using AI-assisted development.
Before using in production:
- Code has not been manually reviewed by humans
- Security audits have not been completed
- API/behavior may change without notice
- Test coverage meets project standards but may have edge cases
Use at your own risk.
Molock is a production-ready mock server for CI/CD pipelines, stress testing, and other testing scenarios. Built in Rust with Actix-web, it provides high-performance, configurable, and observable mock endpoints with OpenTelemetry integration.
- High Performance: Built with Rust and Actix-web for maximum throughput
- Dynamic Rules: Configure endpoints with flexible matching rules
- Response Control: Add delays, failure injection, and stateful behavior
- OpenTelemetry Integration: Built-in tracing, metrics, and logging
- Hot Reload: Watch configuration files for live updates
- Docker Ready: Production-ready container images
- Comprehensive Testing: >80% code coverage with unit and integration tests
Molock is committed to supply chain security. The project implements OpenSSF SLSA Level 2 requirements:
- Provenance: Cryptographically signed build provenance for all releases
- Hosted Build: All builds run on GitHub Actions (hosted infrastructure)
- Verified: SLSA provenance is automatically verified in CI on main branch
You can verify the authenticity of Molock releases using the SLSA verifier:
# Install the SLSA verifier
go install github.com/slsa-framework/slsa-verifier/cli/slsa-verifier@latest
# Verify a release
slsa-verifier --provenance-path <provenance-file> --artifact-path <binary> --source-uri github.com/fike/molockRelease artifacts and provenance are available on the Releases page.
- Rust 1.70+
- Docker and Docker Compose (for deployment)
# Clone the repository
git clone https://github.com/your-org/molock.git
cd molock
# Build the project
make build
# Run tests
make test
# Start the server
make run# Build and run with Docker Compose
make docker-build
make docker-runMolock uses YAML configuration files. See config/molock-config.yaml for examples:
server:
port: 8080
workers: 4
endpoints:
- name: "Get User"
method: GET
path: "/users/:id"
responses:
- status: 200
delay: 50ms
body: '{"id": "{{id}}", "name": "John Doe"}'
- status: 404
condition: "id == 'unknown'"
body: '{"error": "not found"}'
- name: "Retry Example"
method: GET
path: "/retry"
stateful: true
responses:
- status: 200
condition: "request_count > 2"
body: "OK"
- status: 503
default: true
body: "Service Unavailable"- Server: Port, workers, host, and request size limits
- Telemetry: OpenTelemetry endpoint, service name, sampling rate
- Logging: Log level, format, and OpenTelemetry log integration
- Endpoints: HTTP methods, paths with parameters, response rules
- Delays: Fixed (
100ms) or random ranges (100-500ms) - Conditions: Simple expressions using request data
- Probability: Random response selection with weights
- Stateful: Per-client counters for retry logic
- Templates: Dynamic response generation with variables
Molock integrates with OpenTelemetry for comprehensive observability:
- Traces: Request spans with timing and metadata
- Metrics: Request counts, errors, and latency histograms
- Logs: Structured JSON logging with trace context
# Start the full observability stack
docker-compose -f deployment/docker-compose.yml upAccess the monitoring tools:
- Jaeger: http://localhost:16686 (traces)
- Prometheus: http://localhost:9090 (metrics)
- Grafana: http://localhost:3000 (dashboards)
GET /healthReturns server health status.
GET /metricsPrometheus-formatted metrics (when not using OTLP).
All configured endpoints are available at their specified paths. The server matches requests based on:
- HTTP method
- Path (with parameter support:
/users/:id) - Query parameters
- Headers
- Request body
molock/
├── src/
│ ├── config/ # Configuration loading and parsing
│ ├── server/ # Actix web server setup
│ ├── rules/ # Rule matching and execution
│ ├── telemetry/ # OpenTelemetry integration
│ └── utils/ # Helper functions
├── tests/ # Integration tests
├── config/ # Configuration files
├── deployment/ # Docker and deployment artifacts
└── .ai/ # AI-assisted development documentation
# Build release binary
make build
# Run all tests
make test
# Run tests with coverage
make test-coverage
# Check code quality
make lint
make fmt
# Development mode
make devMolock includes comprehensive Apache Benchmark (ab) tests for performance evaluation:
# Install Apache Benchmark (if not already installed)
sudo apt-get install apache2-utils # Ubuntu/Debian
brew install apachebench # macOS
sudo yum install httpd-tools # RHEL/CentOS
# Run comprehensive benchmark suite
make benchmark
# Run individual benchmark scenarios
make benchmark-health # Health endpoint benchmarks
make benchmark-users # User endpoint benchmarks
make benchmark-delay # Delayed response benchmarks
make benchmark-post # POST endpoint benchmarksFor detailed benchmarking instructions, see BENCHMARKING.md.
- Write failing tests first following TDD guidelines in
.ai/TDD_GUIDE.md - Implement minimal solution to make tests pass
- Refactor while keeping tests green
- Ensure 80%+ test coverage using
make test-coverage - Follow coding conventions in
.ai/Agents.md - Update documentation as needed
- Run
make testandmake lintbefore committing
IMPORTANT: All contributions MUST follow Test-Driven Development (TDD) principles. PRs without adequate test coverage (<80%) will be rejected.
# Build the Docker image
docker build -f deployment/Dockerfile -t molock .
# Run the container
docker run -p 8080:8080 -v ./config:/etc/molock/config molockSee the deployment/ directory for example Kubernetes manifests.
MOLOCK_CONFIG_PATH: Path to configuration fileOTEL_EXPORTER_OTLP_ENDPOINT: OpenTelemetry collector endpointOTEL_SERVICE_NAME: Service name for telemetryRUST_LOG: Log level (info, debug, trace)
Please read .ai/CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
This project supports AI-assisted development workflows:
| Configuration File | Description |
|---|---|
AGENTS.md (root) |
Project-specific instructions and conventions |
.ai/Agents.md |
Extended guidelines, TDD workflow, and skills |
.ai/.cursorrules |
IDE-specific rules |
# Build and test
make build
make test
# Code quality
make lint
make fmt
make test-coverage
# Development
make run
make devSee .ai/Agents.md for detailed guidelines, or AGENTS.md for a standardized format compatible with AI coding agents.
This project is licensed under the Apache-2.0 License - see the LICENSE file for details.
- Issues: Use the GitHub issue tracker
- Documentation: Check
.ai/Skills.mdfor technical guidance - Questions: Open a discussion on GitHub
- Built with Actix-web
- Observability with OpenTelemetry
- Configuration with Serde
- Testing with Tokio
Molock is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.