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
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
goreplay-{SERVICE_NAME}.sh
#! /bin/sh
# Change these variables according to your deployment
APPLICATION_PORT=8001
HT_VM_IP=<hypertest-vm-ip>
HT_LOGGER_PORT=<hypertest-logger-port>
HT_ENV=default-staging.example.com
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 ]
then
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"
done
else
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"
fi
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.
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.