I am using jmeter in Non GUI mode. I have set up the distributed environment with 15 servers. Now I want to run 2 test at a time. With each tests on different set of servers.
Test1 : server1, server2
Test3 : server3, server4,server5
Below is the command I used:
./jmeter -n -t pathtojmx -R server1,server2
But this shows below error:
An error occurred: Unknown arg: server2
errorlevel=1
I can run the same command after removing server2.
Jmeter version: 2.13
Thanks in advance.
Parameters with commas need to be quoted:
./jmeter -n -t pathtojmx -R "server1,server2"
Otherwise they are considered separate arguments.
Related
I use Jenkins to trigger a deployment of multiple services (using a deployment script)
There are 6 services in total and have used Jenkins Boolean Parameter to select which services to be deployed.
So, if 1st, 4th and 5th services are to be deployed, the input to the deployment script looks like below in the Jenkins Execute shell tab.
#!/bin/bash
sshpass -p <> ssh username#host "copy the deployment script to the deployment VM/server and give execute persmission...."
sshpass -p <> ssh username#host "./mydeploy.sh ${version_to_be_deployed} ${1st_service} ${4th_service} ${5th_service}"
Note: Deployment happens in a differnt server with very restricted access, so the deployment script - mydeploy.sh has to be copied from the Jenkins slave to the deployment server, then executed with the respective arguments.
How can I make this setup more robust and elegant. I dont want to pass 6 arguments, if all the 6 services are selected. What's the better way to do it ?
An array would help here.
#!/bin/bash
#hardcoded for demo purposes, but you can build dynamically from arguments
services_to_deploy=( 1 4 5 )
sshpass -p <> ssh username#host "copy the deployment script to the deployment VM/server and give execute persmission...."
sshpass -p <> ssh username#host "./mydeploy.sh ${version_to_be_deployed} ${services_to_deploy[#]}"
${services_to_deploy[#]} will expand to the list of all the services you want to deploy so that you don't have to set a unique variable for each one.
One caveat though is that running a command over ssh is similar to running a command using eval because the remote shell will reparse whatever comes through before executing it. If your services have simple names this might not matter, but if you had a hypothetical Hello World service then the remote script would treat Hello and World as two separate arguments due to Word Splitting which probably isn't what you want.
If this is a problem for you, you could fix this with either printf %q (supported by most Bash shells) or by expanding the array as "${services_to_deploy[#]#Q}" if you have Bash 4.4 or higher.
An example using printf %q might look like:
#!/bin/bash
services_to_deploy=( 1 4 5 )
remote_arguments=()
for s in "${services_to_deploy[#]}" ; do
remote_arguments+=( "$( printf '%q' "${s}" )" )
done
sshpass -p <> ssh username#host "copy the deployment script to the deployment VM/server and give execute persmission...."
sshpass -p <> ssh username#host "./mydeploy.sh ${version_to_be_deployed} ${remote_arguments[#]}"
How about you improve your script and introduce some flags.
# --all : Deploys all services
./mydeploy.sh --version 1.0 --all
# --exclude : Deploys all services other than 5th_service and 4th_service (Excludes 4th and 5th)
./mydeploy.sh --version 1.0 --exclude ${5th_service} ${4th_service}
# --include : Deploys just 4th_service and 5th_service
./mydeploy.sh --version 1.0 --include ${5th_service} ${4th_service}
I have a working command using a windows machine like this:
jmeter -g /Users/magnus/Desktop/apache-jmeter-5.1/bin/report_QA/sfm_qa_Oppdater.csv -o /Users/magnus/Desktop/apache-jmeter-5.1/bin/result_QA_oppdate
given I am standing in the directory where JMeter is installed.
However if I run the same command on my Mac I get: jmeter not found
How do I run the same command on a mac using "terminal"
?
If you call jmeter then MacOS is trying to find this binary or script under system PATH, if it is not there - you will get not found error.
So either you need to put "bin" folder of your JMeter installation under your system PATH like:
PATH=/Users/magnus/Desktop/apache-jmeter-5.1/bin:$PATH && export PATH
then you will be able to run it as jmeter
Or change your command to explicitly invoke the jmeter.sh startup script like:
./jmeter -g /Users/magnus/Desktop/apache-jmeter-5.1/bin/report_QA/sfm_qa_Oppdater.csv -o /Users/magnus/Desktop/apache-jmeter-5.1/bin/result_QA_oppdate
this ./ bit is uber important
More information: How to Get Started With JMeter: Installation & Test Plans
And last but not the least, you can install JMeter via Homebrew, the formulae will download the latest JMeter version and put it into your PATH
To run the script in non-GUI mode, you have to just add sh before the same windows non-GUI command.
Go to your bin directory and run like:
sh jmeter -n -t Test.jmx -l Test1.jtl -g test.csv
I have below test infrastructure:
3 instances (master + 2 slaves), dockerized
Run command from jmeter master (default 512m is used in all 3 machines) sudo docker exec -i master /bin/bash -c "/jmeter/apache-jmeter-3.1/bin/jmeter -n -t /home/librarian_journey_Req.jmx -Djava.rmi.server.hostname=yy.yy.yy.yy -Dclient.rmi.localport=60000 -R1xx.xx.xx.xx -j jmeter.log -l result.csv"
the above command works fine and getting results also. however wanted to increase the heap size to 3gb at run time.
I had tried using below command:
sudo docker exec -i master /bin/bash -c "JVM_ARGS="-Xms1024m -Xmx1024m" /jmeter/apache-jmeter-3.1/bin/jmeter -n -t /home/librarian_journey_Req.jmx -Djava.rmi.server.hostname=10.135.104.138 -Dclient.rmi.localport=60000 -R10.135.104.135,10.135.104.139 -j jmeter.log -l result.csv"
after running the above command nothing happens. Please guide how can it be increased.
You can override environment variables when running containers. Also, usually you don't need to use sudo to execute docker. So try this:
docker exec -i -e JVM_ARGS="-Xms1024m -Xmx1024m" master /bin/bash ...
Thanks for all help and guidance from all. Able to set heap size to master and slave machines by setting ENV variable at docker jmeter base image as below. Thanks to #vins.
ENV JVM_ARGS -Xms3G -Xmx3G
I'm trying to get My jmeter test plan to execute in Jenkins. Both jmeter and Jenkins are installed on my local windows machine. I've set up some properties in Jmeter and verified that I can run them from the cmd line successfully with this command: C:\Users\MikeL\Documents\apache-jmeter\bin>jmeter -n -t testApp.jmx -l log.jtl -Jenv=dev -JloopCount=2 Now in Jenkins I've created a new project, create two new parameters and entered the following in "execute shell" based off of exapmples I was able to find on the web.I haven't configured anything else in Jenkins. sh jmeter.sh -n -p user.properties -t C:/Users/MikeL/Documents/apache-jmeter/bin/testApp.jmx -l log.jtl -Jenv=dev -JloopCount=1 suffice to say this script won't build my jmeter test. I recieve this error: Cannot run program "sh" (in directory "C:\Program Files (x86)\Jenkins\workspace\LOS API Regression Tests"): CreateProcess error=2, The system cannot find the file specified
If anybody has any clues I'd be very grateful!
Add this path C:\Users\MikeL\Documents\apache-jmeter\bin to your Environment Variables PATH.
Then Jenkins Build step should be Windows Batch Command
Then the command should be jmeter -n -t testApp.jmx -l log.jtl -Jenv=dev -JloopCount=1
Update:
If you do not want to set the path, just directly give below command as Windows Batch Command.
C:\Users\MikeL\Documents\apache-jmeter\bin\jmeter.bat -n -t C:\Users\MikeL\Documents\apache-jmeter\bin\testApp.jmx -l log.jtl -Jenv=dev -JloopCount=1
Use either Ant/Maven/Gradle to run jmeter tests in the non-gui mode. They can also be integrated with Jenkins
JMeter-Ant
JMeter-Maven
The problem here is cross environment. you need to be running this with windows batch command instead of execute shell. windows wont recognize sh as executable.
C:\Users\MikeL\Documents\apache-jmeter\bin>jmeter -n -t testApp.jmx -l log.jtl -Jenv=dev -JloopCount=2
Run the above in execute windows batch mode
I am running jmeter without UI MODE. Here is my script:
nohup ./jmeter.sh -n -t /home/gdev/jmeter/apache-jmeter-23/project.jmx -l /home/gdev/jmeter/apache-jmeter-2.13/ResultsTest.jtl
Error in NonGUIDriver com.thoughtworks.xstream.io.StreamException: : input contained no data
Look into jmeter.log file and show its content so that we have more details on error.