MockForge CLI
Command-line interface for MockForge - the comprehensive API mocking framework.
MockForge CLI provides a powerful command-line interface to manage MockForge servers, generate synthetic data, perform load testing, and orchestrate chaos experiments. It's the primary tool for interacting with MockForge in development, testing, and CI/CD environments.
Installation
From Source
# Binary will be available at target/release/mockforge
From Crates.io (when published)
Quick Start
Start Mock Servers
# Start all servers with default configuration
# Start with custom ports
# Start with OpenAPI spec
# Start with admin UI and metrics
Generate Test Data
# Generate user data
# Generate from JSON schema
Load Testing
# Load test an API
Core Commands
Server Management (serve)
Start MockForge servers with comprehensive configuration options:
Key Options
- Ports:
--http-port,--ws-port,--grpc-port,--admin-port,--metrics-port - Protocols:
--spec(OpenAPI),--ws-replay-file(WebSocket replay) - Observability:
--metrics,--tracing,--recorder - Chaos Engineering:
--chaos,--traffic-shaping - AI Features:
--ai-enabled,--rag-provider
Examples
# Basic HTTP mock server
# Full-stack with all protocols
# With chaos engineering
# With traffic shaping
Protocol-Specific Commands
MQTT Broker (mqtt)
# Start MQTT broker
# Publish message
# Subscribe to topic
# Manage topics
FTP Server (ftp)
# Start FTP server
# Manage virtual filesystem
# Load fixtures
Kafka Broker (kafka) [requires kafka feature]
# Start Kafka broker
# Create topic
# Produce message
# Consume messages
AMQP Broker (amqp)
# Start AMQP broker
# Declare exchange
# Publish message
# Consume messages
SMTP Server (smtp) [requires smtp feature]
# Send test email
# Manage mailbox
Data Generation (data)
Generate synthetic test data using various methods:
Subcommands
- template: Generate from built-in templates (user, product, order)
- schema: Generate from JSON schema files
Examples
# Generate users
# Generate products with RAG enhancement
# Generate from custom schema
Load Testing (bench)
Perform load testing using OpenAPI specifications:
Options
- Load Profile:
--vus(virtual users),--duration,--scenario - Target:
--target(API endpoint),--auth,--headers - Filters:
--operations,--method,--path - Thresholds:
--threshold-percentile,--threshold-ms,--max-error-rate
Examples
# Basic load test
# Ramp-up scenario
# Test specific endpoints
Test Generation (generate-tests)
Generate test suites from recorded API interactions:
Supported Formats
rust_reqwest- Rust with reqwestpython_pytest- Python with pytestjavascript_jest- JavaScript with Jestgo_test- Go with testinghttp_file- HTTP filescurl- cURL commandspostman- Postman collectionk6- k6 load testing script
Examples
# Generate Rust tests
# Generate with AI descriptions
# Filter by endpoint
AI-Powered Features (suggest, test-ai)
API Specification Suggestion (suggest)
Generate complete OpenAPI specs from minimal input:
# From text description
# From example endpoint
AI Testing (test-ai)
Test AI-powered features:
# Test intelligent mock generation
# Test event stream generation
Workspace Management (workspace)
Multi-tenant workspace management:
# List workspaces
# Create workspace
# Workspace info
Plugin Management (plugin)
Manage MockForge plugins:
# List installed plugins
# Install plugin
# Build plugin
Chaos Orchestration (orchestrate)
Orchestrate chaos experiments:
# Start orchestration
# Check status
# Stop orchestration
Synchronization (sync)
Bidirectional workspace synchronization:
# Start sync daemon
Project Initialization (init)
Initialize new MockForge projects:
# Initialize in current directory
# Initialize with custom name
# Skip example files
Configuration
Configuration Files
MockForge supports YAML configuration files:
# mockforge.yaml
http:
port: 3000
openapi_spec: "api.yaml"
websocket:
port: 3001
replay_file: "events.json"
grpc:
port: 50051
admin:
enabled: true
port: 9080
observability:
prometheus:
enabled: true
port: 9090
data:
rag:
enabled: true
provider: "openai"
model: "gpt-4"
Environment Variables
Override configuration with environment variables:
Command-Line Completions
Generate shell completions:
# Bash
# Zsh
# Fish
Advanced Features
Chaos Engineering
Inject failures and test resilience:
# Network degradation
# Custom latency
# HTTP errors
# Rate limiting
# Random chaos
Traffic Shaping
Simulate network conditions:
# Bandwidth limiting
# Network profiles
# List available profiles
AI Integration
Leverage AI for enhanced mocking:
# Enable AI features
# Generate intelligent mocks
# AI-powered test generation
Observability
Monitor and trace requests:
# Enable metrics
# Enable tracing
# Enable API recorder
Examples
Development Workflow
# 1. Initialize project
# 2. Start development server
# 3. Generate test data
# 4. Load test your API
CI/CD Integration
# Validate configuration
# Generate tests from recordings
# Run chaos experiments
Testing Workflow
# Start mock servers for testing
# Generate test data
# Run load tests
Troubleshooting
Common Issues
Port already in use:
# Check what's using the port
# Use different ports
Configuration validation:
# Validate config before starting
Performance issues:
# Enable metrics to monitor performance
# Check metrics at http://localhost:9090
Contributing
See the main MockForge repository for contribution guidelines.
License
Licensed under MIT OR Apache-2.0