mountebank

mountebank - over the wire test doubles


the apothecary

Fault Simulation

Fault simulation allows us to check how our application behaves when downstream dependencies don't respond as expected due to network failures. Mountebank already has the ability to specify delays via "wait" but we may also want to test when the connection is abruptly reset or garbage data is returned, similar to some of Wiremock's fault simulation functionality

Fault simulation has only been implemented for http, https and tcp protocols. The "fault" response type is mutually exclusive with respect to the other response types as it necessarily prevents any normal response being returned to the client.

The fault response type takes a single parameter specifying which fault to simulate.

Parameter Description
CONNECTION_RESET_BY_PEER Close the connection.
RANDOM_DATA_THEN_CLOSE Send garbage then close the connection.

Select the behavior of the fault below for a relevant example:

Connection Reset by Peer
POST /imposters HTTP/1.1
Host: localhost:35553
Accept: application/json
Content-Type: application/json

{
  "port": 4554,
  "protocol": "tcp",
  "mode": "text",
  "stubs": [
    {
      "responses": [
        {
          "fault": "CONNECTION_RESET_BY_PEER"
        }
      ]
    }
  ]
}
Random Data then Close
POST /imposters HTTP/1.1
Host: localhost:35553
Accept: application/json
Content-Type: application/json

{
  "port": 4554,
  "protocol": "tcp",
  "mode": "text",
  "stubs": [
    {
      "responses": [
        {
          "fault": "RANDOM_DATA_THEN_CLOSE"
        }
      ]
    }
  ]
}