Skip to main content

Record Many Mode

One of the Runner’s available modes is record-many mode. The runner can be started in record-many mode by setting the WMC_DEFAULT_MODE environment variable to record-many, or switched to this mode using the Runner’s switch endpoint. This mode starts a multi-domain recording session that will continue to record until the runner is stopped or its mode is switched.

Record Many Configuration

The record many session started by the Runner can be configured via the same mechanism as the record-many command of the WireMock CLI - either via a values file or via environment variables. Additionally, configuration can be provided at switch time via the HTTP request body. All options available to the record-many CLI command are also available to the Runner’s record-many mode. When specifying an option in the "config" field of the HTTP switch request, remove the dash (-) prefix that would normally be used when provided on the command line. For instance, the --include-services option would become "include-services" in the request body, like so:
{
  "mode": "record-many",
  "config": {
    "include-services": "invoicing-api,payment-api"
  }
}
Just like the WireMock CLI, by default the Runner will expect a WireMock environment file in the .wiremock directory in the current working directory of the container.

Flushing Recordings

The record-many mode will honour the batching configuration you have specified in your config file. The Runner also defines an endpoint which can be used to flush the recorded requests to WireMock Cloud independently of the batching configuration:
  • POST /v1/record-many/flush
When the Runner is stopped or switched out of record-many mode, recorded requests will not be flushed automatically. To ensure all your recordings are saved to WireMock Cloud, call POST /v1/record-many/flush before stopping the recording session.

Starting the Runner In Record Many Mode

When starting the runner in record-many mode you will need to publish the appropriate ports for the services you are running along with the port you have configured for the Runner. Here is a typical example on Linux or macOS when running the Runner on port 9999 and recording to two Mock APIs:
docker run \
  -e WMC_DEFAULT_MODE='record-many' \
  -e WMC_ADMIN_PORT='9999' \
  -e WMC_API_TOKEN='<wmc-api-token>' \
  -v ./.wiremock/:/work/.wiremock/ \
  -p 9999:9999 \
  -p 8080:8080 \
  -p 8081:8081 \
  wiremock/wiremock-runner:latest