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. Create extenstions folder
  • 2. Copy the below content in hypertest-mirror.config file
  1. Quick Set-up
  2. Mirror Traffic
  3. Using Goreplay

ElasticBeanStalk Script for Goreplay

PreviousUsing GoreplayNextUsing Apache

Last updated 1 year ago

If you are using where nodes comes and goes, you can initialize your environment with the following script to bring up the mirroring setup along with your application.

Brief Steps:

  1. Create a folder .ebextentions

  2. Create a .config file script containing HyperTest mirroring setup

  3. Include the .ebextentions folder when you deploy the source code

1. Create extenstions folder

mkdir .ebextensions
cd .ebextensions
vi hypertest-mirror.config

2. Copy the below content in hypertest-mirror.config file

hypertest-mirror.config
option_settings:
  - namespace: aws:elasticbeanstalk:application:environment
    option_name: SVC_NAME
    value: "<SERVICE_NAME>"
    
  - namespace: aws:elasticbeanstalk:application:environment
    option_name: APPLICATION_PORT
    value: "<application-port>"

  - namespace: aws:elasticbeanstalk:application:environment
    option_name: HT_VM_IP
    value: "<hypertest-vm-ip>"

  - namespace: aws:elasticbeanstalk:application:environment
    option_name: HT_LOGGER_PORT
    value: "<hypertest-logger-port>"

  - namespace: aws:elasticbeanstalk:application:environment
    option_name: HT_ENV
    value: "<env-name>"
    
    
commands:
  01_install_goreplay:
    command: |
      mkdir -p /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

  02_generate_goreplay_script_file:
    command: |
      export APPLICATION_PORT=$(/opt/elasticbeanstalk/bin/get-config environment -k APPLICATION_PORT)
      export HT_VM_IP=$(/opt/elasticbeanstalk/bin/get-config environment -k HT_VM_IP)
      export HT_LOGGER_PORT=$(/opt/elasticbeanstalk/bin/get-config environment -k HT_LOGGER_PORT)
      export HT_ENV=$(/opt/elasticbeanstalk/bin/get-config environment -k HT_ENV)
      export SVC_NAME=$(/opt/elasticbeanstalk/bin/get-config environment -k SVC_NAME)
      echo '#! /bin/sh
      # Change these variables according to your deployment
      APPLICATION_PORT='"$APPLICATION_PORT"'
      HT_VM_IP='"$HT_VM_IP"'
      HT_LOGGER_PORT='"$HT_LOGGER_PORT"'
      HT_ENV='"$HT_ENV"'

      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 the same goreplay mirror is already working. Please verify if the custom instance works or kill it and then run the script again."
          for process in "$process_names"; do
            echo "$process"
          done
      else
        echo "Starting goreplay..."
        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' > /opt/hypertest_goreplay/goreplay-$SVC_NAME.sh
      
  03_generate_goreplay_service:
    command: |
      export SVC_NAME=$(/opt/elasticbeanstalk/bin/get-config environment -k SVC_NAME)
      echo '[Unit]
      Description=goreplay
      After=network.target


      [Service]
      Type=simple
      Restart=always
      RestartSec=1
      ExecStart=/opt/hypertest_goreplay/goreplay-'"$SVC_NAME"'.sh

      [Install]
      WantedBy=multi-user.target' > /etc/systemd/system/goreplay-$SVC_NAME.service

  04_start-goreplay-service:
    command: |
      export SVC_NAME=$(/opt/elasticbeanstalk/bin/get-config environment -k SVC_NAME)
      chmod +x /opt/hypertest_goreplay/goreplay-$SVC_NAME.sh
      systemctl daemon-reload
      systemctl enable goreplay-$SVC_NAME --now
      systemctl start goreplay-$SVC_NAME.service
      systemctl restart goreplay-$SVC_NAME.service

Include the .ebextensions folder in your source code while you are deploying your application

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

Elasticbeanstalk