Using Docker

Find the video guide for below instructions over here.

In this guide, we will be using Goreplay to mirror the traffic to HyperTest. We will install and start Goreplay in your Dockerfile itself.

Update your application's Dockerfile as per the below example or create a new one

1. Required Parameters to run Goreplay:

  1. application_port: <port on which your app is running>

  2. hypertest_logger_url: <hypertest-vm-ip>:<hypertest-logger-port> or <hypertest_service_logger_ingress_url>

2. Dockerfile Changes:

  1. Comment your CMD or ENTRYPOINT line to start your application

  2. Download goreplay binary and extract it

  3. Start Goreplay

  4. Add your entrypoint command to start your application in the end

Only copy the parts from ## copy from this till ## to this. Rest is just sample Dockerfile.

Dockerfile
FROM node:10-alpine
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
ENV HYPER_TEST_BRANCH candidate
EXPOSE 3001
#CMD ["npm", "start"]

## copy from this ##
# add next line only for alpine-based images
RUN apk add --no-cache ca-certificates openssl
RUN wget https://github.com/buger/goreplay/releases/download/v0.16.1/gor_0.16.1_x64.tar.gz -O gor.tar.gz
RUN tar xzf gor.tar.gz
CMD [ "sh", "-c", "./goreplay --input-raw :<application-port> --output-http <hypertest_logger_url> --http-disallow-header "fromhypertest: y" --http-set-header "x-ht-env: <your-env>" & npm start" ]
## to this

Build a new docker image using the modified Dockerfile. Deploy your application using the new image.

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:

  1. Exec into the goreplay container using below command:

kubectl exec -it <pod-name> sh

if you are running as a docker container use the below command:

docker exec -it <container-name> sh

2. Run the following command:

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

The goreplay binary will be in your work directory set in Dockerfile.

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

Last updated