Using Goreplay

In this guide, we will use Goreplay to mirror the traffic to HyperTest. Goreplay will run as a systemctl service in your VM.

1. Download goreplay

mkdir /opt/hypertest_goreplay
cd /opt/hypertest_goreplay
wget -O gor.tar.gz
tar xvf gor.tar.gz
sudo mv ./goreplay /usr/local/bin

To avoid typing in the absolute path to run the goreplay binary, copy it to /usr/local/bin for ubuntu and /usr/localfor linux VM. This document assumes the same.

You should run goreplay as a service using systemctl, monit, pm2 etc so that it restarts on boot or failures

2. Run goreplay as a service using systemctl

  1. Create a bash script goreplay-<SERVICE_NAME>.sh, copy the following into it. Update the script as specified in the script itself.

touch goreplay-<SERVICE_NAME>.sh
vi goreplay-<SERVICE_NAME>.sh
#! /bin/sh

# Change these variables according to your deployment

process_count=$(pgrep -a -f -c ".--input-raw :$APPLICATION_PORT --output-http $HT_VM_IP:$HT_LOGGER_PORT")
process_names=$(pgrep -a -f ".--input-raw :$APPLICATION_PORT --output-http $HT_VM_IP:$HT_LOGGER_PORT")

if [ "$process_count" -gt 0 ]
    echo "At least one instance of same goreplay mirror is already working. Please verify if the custom instance works or kill it and the run script again."
    for process in "$process_names"; do
      echo "$process"
  echo "starting goreplay..."
  sudo goreplay --input-raw :$APPLICATION_PORT --output-http $HT_VM_IP:$HT_LOGGER_PORT --http-disallow-header "fromhypertest: y" --http-set-header "x-ht-env: $HT_ENV"

Make the file executable by

chmod +x /opt/hypertest_goreplay/goreplay-<SERVICE_NAME>.sh

2. Create a file named /etc/systemd/system/goreplay-{SERVICE_NAME}.service

3. Copy the following content and paste it into the goreplay-{SERVICE_NAME} file created in above step. Add the absolute path of the bash script you created in step 1.




4. Save the file and run

systemctl daemon-reload
systemctl enable goreplay-{SERVICE_NAME} --now
systemctl start goreplay-{SERVICE_NAME}.service
systemctl status goreplay-{SERVICE_NAME}.service

Check the status of goreplay service and verify it is running.

To Verify the mirroring setup, hit any api on the application and check for request in "last mirrored requests" section or Session page in HyperTest.

Debug mirroring setup via Goreplay

To debug if goreplay is receiving the traffic from your application, we will output the incoming traffic to stdout, so we can see if Goreplay is receiving requests.


goreplay --input-raw :<application_port> --output-stdout

Now hit any api on your application and verify if Goreplay is able to receive it.

Last updated