Skip to content

Add a chaos behavior for probabilistic fault injection #918

@tugkanboz

Description

@tugkanboz

Mountebank can simulate fixed delays (wait) and fixed errors (static is responses), but there is no built-in way to inject random faults. Today people either write inject JavaScript or put Toxiproxy in front of mb.

Proposal: a new chaos behavior alongside wait, copy, etc.

{
  "responses": [{ "is": { "statusCode": 200, "body": "ok" } }],
  "_behaviors": {
    "chaos": {
      "errorRate": 0.1,
      "errorStatusCode": 500,
      "latencyRate": 0.05,
      "maxLatencyMs": 5000
    }
  }
}

All fields default to 0. No new dependencies (just Math.random). Protocol-agnostic, composable with other behaviors.

Happy to send a PR if this sounds reasonable. One open question: should the behavior be named chaos, fault, or faults?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions