Skip to content

Chaos testing ​

The chaos middleware evaluates every AWS request. With no rules or effects configured it does nothing. Configure it at runtime through /_gopherstack/chaos.

EndpointPurpose
GET /queryFaults, effects and recent activity together
GET /faultsCurrent fault rules
POST /faultsReplace all rules
PATCH /faultsAppend rules
DELETE /faultsRemove matching rules (body: rules to remove)
DELETE /faults/by-indexRemove one rule; body {"index": N}
POST /faults/clearClear all rules
GET /effectsCurrent network effects
POST /effectsSet network effects
POST /effects/resetReset effects to zero
GET /activityRecent injected faults, newest first (last 100)
GET /targetsDiscovered services, operations and regions you can target

All paths are under /_gopherstack/chaos. A LocalStack-compatible subset is at /_localstack/chaos/faults and /_localstack/chaos/effects; see Migration.

Network effects ​

json
{"latency": 100, "jitter": 50, "latencyRange": {"min": 50, "max": 200}}

All fields are optional, in milliseconds. Total delay = latency + random 0..jitter + random min..max. Effects supersede --latency-ms while any field is non-zero.

Fault rules ​

POST /faults takes an array:

json
[
  {"service": "dynamodb", "operation": "PutItem", "region": "us-east-1",
   "probability": 0.5,
   "error": {"code": "ProvisionedThroughputExceededException", "statusCode": 400}},
  {"service": "s3", "error": {"code": "ServiceUnavailable", "statusCode": 503}}
]
FieldMeaning
service, operation, regionMatch fields. An omitted field matches anything
probability0.0 to 1.0. Omitted always fires; an explicit 0 never fires
errorcode and statusCode. Default: 503 ServiceUnavailable

dynamodb:transaction-conflict ​

A rule with effect is applied by the owning service instead of returning an HTTP error. This one makes targeted DynamoDB items behave as if an unfinished TransactWriteItems held them:

  • PutItem, UpdateItem, DeleteItem fail with TransactionConflictException.
  • Transactions fail with TransactionCanceledException and TransactionConflict reasons.
  • BatchWriteItem returns UnprocessedItems.
  • GetItem is never affected.

Without a rule, DynamoDB still raises these errors when requests genuinely overlap.

json
[{"effect": "dynamodb:transaction-conflict", "operation": "PutItem",
  "target": {"table": "orders", "key": {"pk": "order-1"}},
  "probability": 0.3, "holdOps": 2, "holdMs": 500}]
  • target.table and target.key narrow the rule. Key values use the scalar string form of the key attributes.
  • holdOps: after the first forced conflict on an item, the next N operations on it also conflict. holdMs: the same for N milliseconds.

Fault Injection Service ​

Running a FIS experiment with aws:fis:inject-api-* actions creates chaos rules for its duration and removes them afterwards.

Released under the MIT License.