Chaos test

From robustmq/robustmq · View interactive version

Chaos test is an AI agent skill from the GitHub repository robustmq/robustmq. 7×24 chaos testing for RobustMQ. Injects broker-kill and network-delay faults, validates SDK client resilience across Python/Go/Rust/Java, and publishes a Markdown + JSON report to GitHub after each run.

How to use this skill

Skill file

RobustMQ Chaos Test Skill

When to Use

Cron trigger (every 4 hours): the system message will say

"按 P0 跑一轮 RobustMQ 故障场景"

Manual CLI: user says something like

"帮我跑一轮 RobustMQ chaos 测试" / "run a chaos test round"

In both cases execute the Full Run below.

If the user says "按 P1 跑一轮" or names a specific scenario, execute the

Single Scenario flow for that scenario only.


Pre-check

Before starting any run:

  1. Call cluster_manage(action=status).

any leftover state from a previous run.

  1. Verify chaos-test/config.yml has cluster.binary and cluster.project_root

filled in correctly (the cluster tool fails fast if binary is missing —

surface that error immediately and stop).


Scenario Catalogue

| Scenario name | fault_type | target | params | Core? |

|---|---|---|---|---|

| broker-kill-single | broker-kill | robustmq-server | — | ✅ |

| network-delay-100ms | network-delay | eth0 | delay_ms=100, jitter_ms=10 | — |

| leader-transfer | broker-kill | robustmq-server | — | ✅ |

Note: Update this table when new scenarios are added. Target names and

interface names depend on the deployment environment — verify before running.

Core scenarios: broker-kill-single, leader-transfer.

Run passed = all core pass AND non-core pass rate ≥ 75%.


Single Scenario — 5-Step Flow

Execute these steps sequentially. Do NOT skip steps.

Step 1 — Baseline Snapshot

observability(action=snapshot, data_dirs=<from cluster start>)

Record the snapshot as baseline. Proceed even if some metrics are unavailable;

log a warning but do not abort.

Step 2 — Inject Fault

chaos(action=inject, fault_type=<type>, target=<target>, params=<params>)

Save the returned fault_id. If inject returns an error, mark the scenario

passed=False with status=inject_error and skip to Step 5 (skip recover).

Step 3 — Fault-Period SDK Observation (record only)

client(action=run, scenario=<scenario>, cluster_endpoint=<endpoint>)

Record all results. Do NOT use these results to determine pass/fail.

Their only purpose is observability — they show what clients experienced

during the fault. A high loss rate here is expected and normal.

Step 4 — Recover

chaos(action=recover, fault_id=<fault_id>)

If recover returns an error, log it and continue — attempt self-healing

validation anyway.

Step 5 — Self-Healing Validation (sole pass/fail basis)

Wait 60 seconds after recovery, then run:

client(action=run, scenario=<scenario>, cluster_endpoint=<endpoint>)

Pass criteria (ALL must hold):

If any criterion fails → scenario passed=False.

If status=script_format_error → scenario passed=False, note the format error

separately (this is a test-infrastructure issue, not a RobustMQ bug).


Full Run Flow

  1. Pre-check (see above).
  2. Start cluster: cluster_manage(action=start) → save endpoint and data_dirs.
  3. Run each scenario using the Single Scenario flow.

continuing: cluster_manage(action=stop) → cluster_manage(action=start).

  1. Stop cluster: cluster_manage(action=stop).
  2. Generate report: report(action=generate_and_push, run_data={...}).

p99_ms, duration_seconds, errors, status.

  1. Send Feishu notification:

Circuit Breaker

Track consecutive_failures across runs (persist in your memory or state):

the cron schedule. Do NOT continue running automatically until a human

acknowledges and resets the counter.


Feishu Message Templates

Pass:

✅ RobustMQ 故障测试通过
Run ID: {run_id}  时间: {finished_at}
核心场景: 全部通过  总通过率: {pass_rate}%
报告: {github_url}

Fail:

❌ RobustMQ 故障测试失败
Run ID: {run_id}  时间: {finished_at}
失败场景: {failed_scenario_list}
报告: {github_url}

Circuit breaker:

🚨 连续 {consecutive_failures} 轮失败,请人工介入
最后失败: {run_id}  {finished_at}
报告: {github_url}

Pitfalls

post-recovery validation counts.

inflate the failure count. Fix the script first.

error immediately if it is not — surface it and stop rather than retrying.

One run with two failed scenarios = 1 failure, not 2.

host. Verify it before running in a new environment.

still written locally at json_path / markdown_path. Investigate the key

before declaring the run lost.

election and connection re-establishment take time.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.