0
votes

I have a small Spring Boot API running in docker. Shown below Is the command I used to up the container.

  docker run -d --rm --name factorialorialContainer --memory=$2 --cpus=$3 -p 8080:8080 -e JAVA_OPTIONS="$(cat /Users/sulekahelmini/Documents/fyp/fyp_work/MLscripts/flags.txt)" suleka96/factorial:latest

Then I have a dockerized JMeter which I up using the below command

  export volume_path=/Users/sulekahelmini/Documents/fyp/fyp_work/MLscripts/jmeter_resource && export jmeter_path=/jmeter && docker run --rm --name jmeterContainer --memory='512m' --cpus=2 -e JAVA_OPTS="-Xms512 -Xmx512" --volume ${volume_path}:${jmeter_path} egaillardon/jmeter --nongui -t factorial.jmx -l jmeter_results.jtl -q user.properties

but all the tests fail and requests are not getting sent to the API. This is how the CLI of JMeter looks

enter image description here

test config of request:
Protocol: htttp
Server: localhost
Port:8080
Method:GET
Path:/api/factorial

This is what the complete bash file looks like:

#!/bin/bash


  cd /Users/sulekahelmini/Documents/fyp/fyp_work/demo/target && docker build . -t suleka96/factorial
  docker run -d --rm --name factorialorialContainer --memory='512m' --cpus=2 -p 8080:8080 -e JAVA_OPTIONS="$(cat /Users/sulekahelmini/Documents/fyp/fyp_work/MLscripts/flags_base.txt)" suleka96/factorial:latest
  sleep 15
  #run test
  export volume_path=/Users/sulekahelmini/Documents/fyp/fyp_work/MLscripts/jmeter_resource && export jmeter_path=/jmeter && docker run --rm --name jmeterContainer --memory='512m' --cpus=2 -e JAVA_OPTS="-Xms512 -Xmx512" --volume ${volume_path}:${jmeter_path} egaillardon/jmeter --nongui -t factorial.jmx -l jmeter_results.jtl -q user.properties
  sleep 15
  #jtl split
  java -jar /Users/sulekahelmini/Documents/fyp/fyp_work/MLscripts/jtl-splitter-0.4.6-SNAPSHOT.jar -f /Users/sulekahelmini/Documents/fyp/fyp_work/MLscripts/jmeter_resource/jmeter_results.jtl -s -t 1;
  docker stop factorialorialContainer
  docker stop jmeterContainer

What am I doing wrong? How can I fix this?

1

1 Answers

0
votes

You're doing wrong absolutely everything.

  1. When it comes to Spring Boot even "small" API is not small at all, if you want something really small - consider i.e. Jersey
  2. I fail to see why do you need containers at all, in your situation they don't add any value but only consume resources
  3. You're running the application under test and the load generator at the same physical machine. Both can be very resource intensive when it comes to high load and you won't be able to tell for sure where is the bottleneck
  4. If you still want to ignore previous 2 points and proceed: you're using localhost in JMeter container and there is nothing deployed on port 8080 in that container. You need to run the following command:

    docker inspect factorialorialContainer
    

    you will see a line which looks like:

    "IPAddress": "xxx.xxx.xxx.xxx",
    

    you will need to get this IP address from the docker inspect command output and replace the localhost with this IP address in the JMeter's HTTP Request sampler

References: