Skip to main content
Faults change how a completed service result reaches the caller. They do not change which result the service produces. That distinction keeps Simile useful for integration tests:
  • a declined payment, invalid parameter, or forbidden state is a deterministic outcome selected by a public request condition or an opaque scenario;
  • high latency and a lost connection are environmental faults applied to an operation attempt; and
  • asynchronous work is declared separately and is not a fault.
Simile models those concepts separately all the way from HCL to the HTTP adapter. A stochastic profile can therefore disrupt delivery, but it cannot invent a bad payment method when the caller sent a valid one.
Need an exact catalog name or execution term? Use the Fault glossary.

Use the built-in HTTP catalog

Simile includes complete, provider-neutral HTTP faults with sensible defaults. Select only the faults the service needs:
Catalog selection is set-based. Import the complete catalog in one line:
Import one complete namespace with a suffix wildcard:
Prefix a selector with ^ to subtract it. Exclusions apply to the complete configuration, so a later positive selector cannot accidentally add the fault again:
Exact selectors, namespace selectors, and exclusions may be composed across inline configuration and imported HCL modules. Repeated selection of the same unchanged fault is idempotent. Selectors that match nothing fail compilation, catching misspelled names and namespaces. http.slow delays a response by one second. http.response_lost completes and commits the operation, then closes delivery before the response reaches the caller. Catalog entries compile into the same self-contained artifact records as provider-authored faults; starting the service does not fetch or resolve a remote catalog. Defaults are optional, not restrictive. Override only the property that matters to the service:
Latency accepts whole-number durations from 1ms through 24h, using ms, s, m, or h. An exact import keeps its catalog name, so scenarios and profiles refer directly to http.slow. Use an alias when the same preset needs more than one configuration:
Unknown catalog names, unsupported overrides, aliases that collide with another fault, and invalid durations fail compilation. Wildcards and exclusions cannot contain aliases or overrides; configure an exact import instead. Simile never silently substitutes a different fault.

Define a custom fault

The initial action vocabulary is intentionally small. Define a custom fault when a catalog preset does not express the service’s public testing contract:
before_response currently accepts delay; after_commit currently accepts disconnect. Compilation rejects mismatched phase/action pairs. A delay must be from 1 millisecond through 24 hours. These narrow combinations make ordering explicit and prevent a transport label from quietly changing service semantics.

Deterministic scenarios

Use a scenario when a test must reproduce the same disruption every time:
The label on inject is an exact contract operation ID. The referenced fault must exist. A scenario may also select named outcomes, so one opaque test setup can choose a public service result and a delivery failure without exposing a provider’s private decision tree.
Scenario injection is attempt-scoped. If createOrder commits and the connection is lost, a retry with the same idempotency key returns the stored result normally. Simile stores the operation outcome in the replay index, not the transport failure that affected its first delivery.

Bounded stochastic profiles

Use a profile to exercise resilience over a longer local or CI session:
  • probability is per eligible attempt, from 0.000001 through 1.
  • faults is a non-empty set of declared environmental faults.
  • operations is an optional list of contract operation IDs; omit it to cover all operations.
  • max_consecutive defaults to 1 and limits uninterrupted activations.
  • cooldown_requests defaults to 20 and counts eligible clean attempts after that limit.
  • seed is optional. When omitted, Simile creates a session seed and reports it at startup.
Record the reported seed with a failing test. Adding it to the same profile reproduces the random sequence for the same compiled service and Simile release. --output json includes activeFaultProfile and faultSeed so CI can retain the same evidence without parsing human output. Profiles cannot name domain outcomes and currently support only transport-safe fault actions. This is deliberate: random network adversity is useful; random business rejection makes an integration test untrustworthy.

Runtime and adapter boundary

The runtime completes an OperationOutcome first, then returns an OperationExecution containing an optional fault activation and a protocol-neutral transport plan. The replay store contains only the outcome. simile-server owns the concrete HTTP behavior: sleeping before a response or ending the response stream after commit. That split lets future adapters implement the same plan without importing HTTP into the runtime, and lets future fault actions grow without becoming response-selection rules. Read Outcome fidelity for deterministic error selection, Fault glossary for catalog names and terminology, State, identity, and replay for retry semantics, and Operation execution for the runtime pipeline.