Action Executor
Overview
The action executor maps command strings to callable functions. Action scripts are JSON lists, so the same script can be hand-authored, generated by HAR import, scheduled by an MCP tool, or sent over the control socket.
Every shipped command starts with the LD_ prefix; safe Python
built-ins (print, len, range…) are also available, but
eval, exec, compile, __import__, breakpoint,
open, and input are explicitly blocked.
Action format
["command_name"] # No parameters
["command_name", {"key": "value"}] # Keyword arguments
["command_name", [arg1, arg2]] # Positional arguments
The top-level document is either:
{"load_density": [["LD_start_test", {...}], ...]}
or a bare list of actions.
Quick example
from je_load_density import execute_action
execute_action({"load_density": [
["LD_register_variables", {"variables": {"base": "https://api.example.com"}}],
["LD_start_test", {
"user_detail_dict": {"user": "fast_http_user"},
"user_count": 20,
"spawn_rate": 10,
"test_time": 30,
"tasks": [{"method": "get", "request_url": "${var.base}/health"}],
}],
["LD_generate_summary_report", {"report_name": "smoke"}],
]})
LD_* commands
The executor exposes the following commands. Each is implemented in the
matching module under je_load_density.
Core:
Command |
Summary |
|---|---|
|
Run a Locust load test (HTTP / FastHttp / WebSocket / gRPC / MQTT / Socket). |
|
Execute a nested action list. |
|
Execute every action JSON file in a list. |
|
Register a Python package’s functions into the executor. |
|
Start the hardened TCP control plane. |
Reports:
Command |
Summary |
|---|---|
|
HTML report generators. |
|
JSON report generators. |
|
XML report generators. |
|
One-row-per-request CSV export. |
|
JUnit XML for CI consumers. |
|
JSON summary with per-name p50/p90/p95/p99 latencies. |
|
In-memory dict of the same summary. |
Test record persistence:
Command |
Summary |
|---|---|
|
Save the in-memory records to a SQLite database. |
|
List recent runs in a database. |
|
Load every record for one run. |
|
Drop the in-memory record list. |
Parameter resolver:
Command |
Summary |
|---|---|
|
Register one or many |
|
Bind a CSV file to a |
|
Reset every registered variable / source. |
Recording / replay:
Command |
Summary |
|---|---|
|
Read a HAR JSON file from disk. |
|
Convert a HAR document into a list of LoadDensity tasks. |
|
Convert a HAR document into a runnable action JSON. |
Metrics exporters:
Command |
Summary |
|---|---|
|
Toggle the Prometheus HTTP endpoint. |
|
Toggle the InfluxDB UDP / HTTP sink. |
|
Toggle the OTLP gRPC exporter. |
Adding custom commands
from je_load_density import add_command_to_executor
def slack_notify(message: str) -> None:
...
add_command_to_executor({"LD_slack_notify": slack_notify})
Once registered, the new command is callable from any action JSON.