Skip to content

Replay

Nibbler is a tool that stores real requests captured from prod. The replay command replays this captured traffic against a dedicated environment (develop, a PR, or prod).

The replay feature can take a directory or a .tgz file as input via the --dataDir option.

zoidberg replay -d ./path/to/nibbler/data
Replay requests captures by nibbler

Usage:
  Zoidberg replay [flags]

Flags:
  -c, --check string     Check the response content
  -d, --dataDir string   Directory with the datas (default "./data/nibbler")
  -h, --help             help for replay
  -r, --hitRate int      Define the hit rate for the replay in milliseconds (default: 500)
  -i, --isoWith string   Environment ( develop | prod | local )
  -l, --limit int        Limit the number of requests to replay
  -s, --stats            Display a stats summary after the replay

Global Flags:
  -e, --environment string   Environment ( develop | prod | local ) (default "develop")
  -k, --publicKey string     Override public key from environment variable
  -v, --verbose              Verbose Mode
  -p, --versionPR string     Run the tests on a specific PR

Note

--hitRate is ignored when --isoWith is set.

Stats summary

Use the --stats flag to print a summary at the end of the replay:

zoidberg replay -d ./path/to/nibbler/data --stats

The summary includes:

  • Status code distribution: number of responses per HTTP status code
  • Average response time: mean response time across all replayed requests
  • Min response time: fastest response observed
  • Max response time: slowest response observed
  • P50 response time: median response time (50th percentile)
  • P90 response time: 90th percentile response time
  • Actual hit rate: effective throughput in requests per second

Example output:

Status code distribution:
  200: 38
  404: 4
Average response time: 142ms
Min response time: 45ms
Max response time: 612ms
P50 response time: 128ms
P90 response time: 380ms
Actual hit rate: 1.98 req/s

Check response content

With the option --check json.path=regexp, Zoidberg checks that the response content matches the regexp.

  • When just replaying requests: the regexp is matched against the whole response body, not against the value at the gjson path. The check passes if the regexp matches anywhere in the body; the path is only used to report the resolved value on failure.
  • When replaying with --isoWith: it checks that the subpart of the response selected by --check matches between the two environments.

The path uses the gjson syntax.

Create a nibbler archive

To create a .tgz archive with a subset of nibbler capture, use the tools/extract_nibbler.py script. At the top of the script you can define the list of API endpoints to parse and the number of requests to retrieve for each one.