lmn-core
Core engine for lmn — a fast HTTP load testing tool.
This crate provides the building blocks for running load tests programmatically: HTTP execution, dynamic request templating, load curve definitions, result sampling, threshold evaluation, and report generation. The lmn CLI is built entirely on top of this crate.
Full documentation at https://lmn.talek.cloud
Features
- Fixed and curve-based execution — run N requests at fixed concurrency, or drive VU counts dynamically over time with linear or step ramps
- Dynamic request templates — JSON templates with typed placeholder generators (strings, floats),
:onceplaceholders, and${ENV_VAR}secret injection - Response field tracking — extract and aggregate typed fields from response bodies across all requests
- Two-stage sampling — VU-threshold gate + Vitter's Algorithm R reservoir to bound memory while preserving statistical accuracy
- Threshold evaluation — pass/fail rules on latency percentiles, error rate, and throughput
- Structured reports — serializable
RunReportwith percentiles, per-stage breakdowns, status code distribution, and sampling metadata - OpenTelemetry tracing — all major operations are instrumented with named spans
Usage
[]
= "0.1"
= { = "1", = ["full"] }
= "1"
Key types
| Type | Module | Purpose |
|---|---|---|
RunCommand |
command::run |
Entry point — owns request spec, execution mode, and sampling config |
ExecutionMode |
command::run |
Fixed { request_count, concurrency } or Curve(LoadCurve) |
RequestSpec |
command::run |
Host, method, body, template paths, headers |
SamplingConfig |
command::run |
VU threshold and reservoir size |
RunStats |
command::run |
Raw output of a completed run |
RunReport |
output |
Serializable report built from RunStats |
LoadCurve |
load_curve |
Staged VU ramp definition (parses from JSON) |
Threshold |
threshold |
Single pass/fail rule on a metric |
Minimal example — fixed load test
use Instant;
use ;
use ;
use ;
async
Load curves
Define time-based VU ramps using LoadCurve, which parses from JSON:
use LoadCurve;
use ExecutionMode;
let curve: LoadCurve = r#"{
"stages": [
{ "duration": "30s", "target_vus": 5 },
{ "duration": "2m", "target_vus": 50, "ramp": "linear" },
{ "duration": "30s", "target_vus": 0, "ramp": "linear" }
]
}"#.parse.unwrap;
let execution = Curve;
Stage ramp defaults to "linear" if omitted. Use "step" for an immediate jump.
Request templates
Load a JSON template file with typed placeholder definitions:
use Template;
let template = parse.unwrap;
// Pre-generate N bodies at startup (used in fixed mode)
let bodies = template.pre_generate;
// Or generate on demand (thread-safe, used in curve mode)
let body = template.generate_one;
Template files embed placeholder definitions under _loadtest_metadata_templates:
Environment variables are resolved at template load time:
See Template Placeholders for the full reference.
Thresholds
use ;
let thresholds = parse_thresholds.unwrap;
let result = evaluate;
if !result.all_passed
parse_thresholds accepts both JSON and YAML strings. Available metrics: latency_p50, latency_p75, latency_p90, latency_p95, latency_p99, error_rate, throughput_rps. Operators: lt, lte, gt, gte, eq.
Configuration
If you prefer YAML-based configuration, lmn-core exposes a full config parser:
use parse_config;
let config = parse_config.unwrap;
See the Config File Reference for the full YAML schema.
License
Apache-2.0