Molock - High-Performance Mock Server
⚠️ DISCLAIMER: Experimental Project
This 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.
Features
- 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
Security & Supply Chain
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
Verifying Releases
You can verify the authenticity of Molock releases using the SLSA verifier:
# Install the SLSA verifier
# Verify a release
Release artifacts and provenance are available on the Releases page.
Quick Start
Prerequisites
- Rust 1.70+
- Docker and Docker Compose (for deployment)
Installation
# Clone the repository
# Build the project
# Run tests
# Start the server
Using Docker
# Build and run with Docker Compose
Configuration
Molock 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"
Configuration Options
- 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
Response Features
- 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
Observability
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
Local Development Stack
# Start the full observability stack
Access the monitoring tools:
- Jaeger: http://localhost:16686 (traces)
- Prometheus: http://localhost:9090 (metrics)
- Grafana: http://localhost:3000 (dashboards)
API Reference
Health Check
GET /health
Returns server health status.
Metrics
GET /metrics
Prometheus-formatted metrics (when not using OTLP).
Mock Endpoints
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
Development
Project Structure
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
Building and Testing
# Build release binary
# Run all tests
# Run tests with coverage
# Check code quality
# Development mode
Benchmarking
Molock includes comprehensive Apache Benchmark (ab) tests for performance evaluation:
# Install Apache Benchmark (if not already installed)
# Run comprehensive benchmark suite
# Run individual benchmark scenarios
For detailed benchmarking instructions, see BENCHMARKING.md.
Adding New Features (TDD Required)
- 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.
Deployment
Docker
# Build the Docker image
# Run the container
Kubernetes
See the deployment/ directory for example Kubernetes manifests.
Environment Variables
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)
Contributing
Please read .ai/CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
For AI-Assisted Development
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 |
Quick Commands
# Build and test
# Code quality
# Development
See .ai/Agents.md for detailed guidelines, or AGENTS.md for a standardized format compatible with AI coding agents.
License
This project is licensed under the Apache-2.0 License - see the LICENSE file for details.
Support
- Issues: Use the GitHub issue tracker
- Documentation: Check
.ai/Skills.mdfor technical guidance - Questions: Open a discussion on GitHub
Acknowledgments
- Built with Actix-web
- Observability with OpenTelemetry
- Configuration with Serde
- Testing with Tokio
License
Molock is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.