Text intent driven test framework for Starcoin network validation after libp2p and jsonrpsee upgrades.
Allow R&D, QA, and users to add tests in readable text, for example:
测试一个节点失效,网络正常运行
The framework parses this intent and generates:
- Canonical scenario JSON (for audit and review).
- Artillery load scenario JSON (HTTP/WS).
- Chaos execution plan shell script.
intents/: human readable test cases.framework/: parser, translator, and compiler.generated/: compiled artifacts.docs/: templates and conventions.tests/: unit tests.
cd starcoin-nettest
./scripts/prepare_env.sh --check-only
python3 -m framework.cli validate intents/*.md
python3 -m framework.cli compile-all --intent-dir intents --out-dir generatedUse the built-in script to check or install prerequisites:
# check only (safe default)
./scripts/prepare_env.sh --check-only
# auto install missing packages where possible
./scripts/prepare_env.sh --install --yesThe script detects OS and prepares:
- Common tools:
python3,node,npm,artillery,docker - Network fault backend:
- Linux:
tc(iproute2) - macOS:
dnctl + pfctl
- Linux:
- Docker compose availability (
docker composeordocker-compose) - Starcoin binary existence (
--starcoin-binoptional)
python3 -m framework.cli list --intent-dir intents
python3 -m framework.cli validate intents/02-node-down.md
python3 -m framework.cli compile intents/02-node-down.md --out-dir generated \
--http-target http://127.0.0.1:9850 --ws-target ws://127.0.0.1:9870
python3 -m framework.cli run intents/02-node-down.md \
--starcoin-bin /Users/simon/starcoin-projects/starcoin/target/debug/starcoin \
--base-port 26000 \
--duration-override 60 \
--fault-duration 30
python3 -m framework.cli run intents/10-tls-pubsub.md \
--http-target https://rpc.example.com \
--ws-target wss://rpc.example.com/ws \
--duration-override 60
python3 -m framework.cli run-docker intents/01-baseline.md \
--compose-file docker/starcoin-4node.compose.yml \
--project-name starcoin-nettest \
--duration-override 60
# wrapper script
./scripts/run_docker_intent.sh intents/01-baseline.md \
--compose-file docker/starcoin-4node.compose.yml \
--duration-override 60
# wrapper script
./scripts/run_intent.sh intents/02-node-down.md --node-count 2 --fault-duration 20run command does:
- Start local Starcoin multi-node cluster with dedicated ports.
- Compile intent into scenario/artillery/chaos artifacts under run folder.
- Run fault injection (
node_down/node_restart/network_partition). - Run Artillery load test (if installed).
- Collect pre/post snapshots through both JSON-RPC and
starcoinCLI commands. - Run a dedicated PubSub probe for event delivery, disconnect, and reconnect metrics.
For TLS scenarios, use remote target mode instead of the local binary runner:
- The local Starcoin binary runner does not expose HTTPS/WSS endpoints.
- Pass
--http-targetand--ws-targetto run against an existing TLS-enabled deployment. - Add
--tls-insecureonly when you intentionally want to bypass certificate validation in a test environment.
Useful for faster local iteration:
python3 -m framework.cli run intents/09-pubsub-reconnect.md \
--starcoin-bin /Users/simon/starcoin-projects/starcoin/target/debug/starcoin \
--base-port 48000 \
--node-count 2 \
--fault-duration 8 \
--duration-override 30 \
--skip-artilleryRun outputs:
runs/<timestamp>-<intent-id>/generated/*.jsonruns/<timestamp>-<intent-id>/snapshots/pre/*runs/<timestamp>-<intent-id>/snapshots/post/*runs/<timestamp>-<intent-id>/pubsub-probe.jsonruns/<timestamp>-<intent-id>/run-summary.json
run-docker does:
- Start a docker compose cluster.
- Wait for all configured HTTP RPC endpoints to answer
chain.info. - Reuse the existing remote runner for intent compilation, Artillery, PubSub probe, and threshold evaluation.
- Capture docker-cluster snapshots for every configured node before and after the run.
- Tear the compose stack down by default.
Defaults:
- If
--http-targetor--ws-targetare omitted, the command infers local endpoints from the compose file's published9850/9870ports. - First endpoint is used as the primary target for load and PubSub execution.
- All configured HTTP endpoints are included in docker pre/post snapshots.
- The inferred endpoint count must match
--node-countor the intent'sscope.nodes; otherwiserun-dockerfails fast with a topology mismatch error.
Useful options:
--keep-running: leave the compose stack up after the run.--remove-volumes: delete compose volumes on teardown.--http-target/--ws-target: override inferred endpoints for custom compose files.- Use
docker/starcoin-4node.compose.ymlfor the default 4-node intents; keepdocker/starcoin-3node.compose.ymlfor explicit 3-node runs with--node-count 3.
- Generated Artillery config is scaffold-level and can be extended by QA.
- Chaos script is a plan template; adapt stop/start commands to your node orchestration.
- Keep
intents/*.mdas source of truth for test evolution. net_delay/net_lossin integrated runner are OS-aware:- Linux uses
tc netem - macOS uses
dnctl + pfctlBoth require root privileges.
- Linux uses
- PubSub metrics prefer
pubsub-probe.jsonover Artillery summary heuristics when available. pubsub-probe.jsonseparates transient reconnect noise from unexpected probe errors so restart scenarios stay readable.- Remote target mode requires the target chain itself to progress; otherwise
chain_progresswill fail even if transport setup is healthy.