Hypertest Docs
HyperTestKnowledge Base
  • Quick Set-up
    • Install HyperTest
    • Deploy your application
    • Mirror Traffic
      • Using Kubernetes
      • Using Amazon ECS
      • Using Docker
      • Using Nginx
      • Using Goreplay
        • ElasticBeanStalk Script for Goreplay
      • Using Apache
      • Using IIS
      • Using Istio
      • Using Kong
      • Using HAProxy
      • Others
  • HyperTest Overview
    • Introduction
    • Architecture
  • Detailed Setup Guide
    • Detailed Setup Guide
      • Installation
        • Linux VM
        • Kubernetes Cluster
          • Hardware Requirements
          • Cluster Setup
            • EKS
              • Existing Application Load Balancer
              • Calculate Setup Cost for EKS Cluster
            • GCP
            • AKS
            • Self Managed
              • Microk8s with EKS-D
          • HyperTest Installation
      • Mirror Traffic
      • Configure HyperTest
      • Automate Starting a Test
        • CI Integration
          • GitHub Checks Integration
            • Mandatory checks
          • Gitlab Integration
          • Bitbucket Integration
          • Jenkins Pipeline
            • Jenkins Plugins for PR events
  • Upgrade HyperTest
    • Upgrade HyperTest
      • Linux VM
      • Kubernetes Cluster
  • User Guides
    • Usage Guide
      • Install and Configure HyperTest
        • Install HyperTest
        • Configure Base DNS
        • Add New Service
      • Tests Runs and Analysis
        • View Test Cases
        • Start New Test Run
        • Understand Your Test Run Analysis
        • Prioritize Your Error Types
        • Track Bugs
        • Ignore Errors/Desired Changes
        • View/Download Report
        • View Consolidated Dashboard Reports
        • Sign-off Reports
        • Reduce Execution Time
        • Deduplication Rules
      • Troubleshooting and FAQs
    • Best Practices Guide
      • Cost Optimization
    • Dashboard Tour
      • Dashboard
      • All Sessions
      • Regression Report
      • Notifications
      • First Test Run
      • Interactions
      • Custom Analysis
      • Configuration
    • User Management
      • Create Admin User
      • Roles, Groups & Users
      • Enabling User Signup
    • Other Guides
      • Basic Nginx Auth for Linux HT
  • Middleware
  • Advanced Features
    • Import test cases from Postman
  • Change Log
  • Troubleshooting
  • FAQs
    • Setup
    • General
    • Regression Report
  • Glossary
    • Session
Powered by GitBook
On this page
  • 1. Download goreplay
  • 2. Run goreplay as a service using systemctl
  • Debug mirroring setup via Goreplay
  1. Quick Set-up
  2. Mirror Traffic

Using Goreplay

PreviousUsing NginxNextElasticBeanStalk Script for Goreplay

Last updated 1 year ago

In this guide, we will use 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 https://github.com/buger/goreplay/releases/download/v0.16.1/gor_0.16.1_x64.tar.gz
tar xvf gor.tar.gz
sudo mv ./goreplay /usr/local/bin

For arm architecture VM, use this link to download goreplay

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
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

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.

goreplay-{SERVICE_NAME}.service
[Unit]
Description=goreplay
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=/opt/hypertest_goreplay/goreplay-<SERVICE_NAME>.sh

[Install]
WantedBy=multi-user.target

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.

Steps:

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

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

Goreplay
https://hypertest-binaries-1.s3.ap-south-1.amazonaws.com/mirror-tool/goreplay-0.16.1-arm.tar.gz