How to run Jmeter tests from bamboo? - jmeter

How to run the Jmeter tests from bamboo?
I tried in Jenkins which has the 'Execute windows batch command' option and I just pasted these lines and worked fine
jmeter -n -t C:\apache-jmeter-2.13\apache-jmeter-2.13\bin\test.jmx
I need to work the same with bamboo as well. So I tried with the script task, selected Inline and in the script body I pasted the above lines
It failed with this error
/opt/bamboo/current/temp/TEST-NEW-NEW-33-ScriptBuildTask-6294682377804302931.sh: line 2: C:Jmeterapache-jmeter-2.13bin: command not found
/opt/bamboo/current/temp/TEST-NEW-NEW-33-ScriptBuildTask-6294682377804302931.sh: line 3: jmeter: command not found
I tried with the Command task also in bamboo but no luck.
I'm struggling how to run Jmeter tests from bamboo? Anyone please advise. I see that we can do it with maven I believe, but I don't know much about it, but if anyone has step by step instructions that I can follow that helps as well.
Thanks in advance

Define the jmeter executable as a remote capabiliety.
Then add a new command to your task and select jmeter as executable. Add your arguments and you are done.

It looks like that you need to either need to escape backslashes like:
C:\\apache-jmeter-2.13\\apache-jmeter-2.13\\bin\\test.jmx
or change them to forward slashes as:
C:/apache-jmeter-2.13/apache-jmeter-2.13/bin/test.jmx
Other options on how to kick off a JMeter test from Bamboo build step are:
bamboo-jmeter-plugin
JMeter Ant Task
JMeter Maven Plugin
existing JMeter tests can be executed from Java code, moreover, it is possible to create a JMeter test purely in Java.
See 5 Ways To Launch a JMeter Test without Using the JMeter GUI guide for detailed information on aforementioned options.

I assume your Bamboo is in a linux environment.
From Bamboo on Linux, create a new task and select script:
cd /<your path>/apache-jmeter-2.13/bin
./jmeter -n -t <your path>/test.jmx
If Windows, set environment variable JMETER_HOME to C:\apache-jmeter-2.13\apache-jmeter-2.13\ and then on Bamboo's command line:
cd C:\apache-jmeter-2.13\apache-jmeter-2.13\bin\
jmeter -n -t test.jmx

Related

The JMETER_HOME environment variable is not defined correctly

I'm getting this error when trying to run this jmeter sentence from a maven project in java.
jmeter -g DIRECTORY -o DIRECTORY
When I run it in cmd it works perfectly but when I try to run it using this:
processBuilder.command("cmd.exe","/c","jmeter -g DIRECTORY -o DIRECTORY");
processBuilder.directory(new File("C:\\apache-jmeter-5.3\\bin"));
try {
Process process = processBuilder.start();
It says The JMETER_HOME environment variable is not defined correctly
When I run the command echo %JMETER_HOME% it returns C:\apache-jmeter-5.3
What I found weird is that in other PC it all works fine and that one doesn't have the JMETER_HOME variable defined, so I tried deleting the variable from this PC but it won't delete, it's not appearing in the system variables window but when I echo it's there.
What is going on?
Thanks in advance
So you want us to guess what is the difference between one your PC and the other one without providing any information apart from incomplete code?
I can only state that I cannot reproduce your issue and yes, I don't have JMETER_HOME variable set anywhere.
If you're using Maven maybe it worth considering looking at JMeter Maven Plugin which can automatically download JMeter, run the test and generate the HTML reporting dashboard.
Also be informed that according to JMeter Best Practices you're supposed to use the latest version of JMeter so consider upgrading to JMeter 5.4.3 (or whatever is the latest version of JMeter available at JMeter Downloads page) on next available opportunity.
I faced same issue of JMETER_HOME not been set, even though I tried setting that Env variable.
I was tying to launch the Jmeter on the Virtual system (VM) using command prompt, and didn't succeed.
I able to solve it by running the command prompt as admin and launching Jemter, it worked fine.
Note: make sure you have the set the Env. PATH set to the bin folder of Jmeter

Additional property files to load in JMeter

My performance test setup
Jmeter 5.3
1 JMX File that contains my test plan.
1 default properties file. This is named 'user.properties'.
1 custom properties file. I pass this when I run my test plan headless.
I have a test plan that I run in the following ways,
headless
jmeter -p "customProp.properties" -n -t "myTestPlan.jmx"
GUI
Open > myTestPlan.jmx and like above I want the customProp.properties also to come into effect with myTestPlan.jmx in play.
What I've done so far?
I've used the 'user.properties' attribute within the 'user.properties' file in the bin directory as follows,
user.properties=customProp.properties
I know how to do add properties files when running headless. Just now sure how to do it with GUI. Any pointers?
Just proceed as for Non GUI, but note it’s better to make -p point to jmeter.properties and -q to user.properties and your additional properties file:
jmeter -p path_to_jmeter.properties -q path_to_user.properties -q path_to_custom.properties
See:
https://jmeter.apache.org/usermanual/get-started.html#options
If you don't have any customizations under user.properties file and don't plan to have them in the future - locate the following line in the jmeter.properties file:
user.properties=user.properties
and change it to point to your "custom" properties file:
user.properties=customProp.properties
it will make the change permanent and you won't have to play with command-line arguments no matter whether you run JMeter in GUI or non-GUI modes (JMeter restart will be required to pick the properties up)
More information:
Configuring JMeter
Apache JMeter Properties Customization Guide

How to run a specific testsuite/test of Robot framework on Jenkins CI with maven plugin

I am tring to create a job that can help in running a specific test suite on CI and not the whole set of tests.How can I do that.I know I have to use run command,but not sure how to use it.
The Robot Framework Guide has a seperate section on Command Line Options.
An example (for Windows):
python -m robot.run -P C:\Python27\lib\site-packages -s MyFolderName.RobotFileName -t "MyFolderName.RobotFileName.Test Case Name" C:\Workspace\MyFolderName

Automatically running the same test plan multiple times with different variables

I've created a test plan to do some load testing against HTTP endpoints. I want to run the same test plan against multiple endpoints, and find myself having to do the following each time:
Change variable that determines which endpoint I'm hitting.
Run the test.
When complete, record results.
Clear all results.
Back to step 1.
I want to automate this. Is the following possible?
Define a list of endpoints as a variable.
For each endpoint in endpoints
Run test against endpoint
When complete, save results
Clear all results.
The things in particular that I don't know how to automate are:
Starting a test
Defining an list-style variable
Clearing all results
Any help would be greatly appreciated!
Please see answers below:
Starting a test
Apart from running JMeter from GUI there are several execution options such as:
Command line non-GUI mode - you can wrap JMeter execution line in operating system batch file
JMeter Ant Task - integration with Apache Ant build system, more powerful if you're comfortable with it
JMeter Maven Plugin - the same as Ant but for Apache Maven
Option to run JMeter with CI systems like Jenkins
Defining an list-style variable
JMeter offers "properties" which can be set via .properties files (see user.properties in /bin folder of your JMeter installation for example) or passed as name/value pairs to JMeter startup script. For instance instead of hard-coding your host in .jmx file you can use read a property function.
Set "Server Name or IP" field value to ${__P(myhost,)}
Add myhost=example.com line to user.properties file in /bin folder of your JMeter installation, restart JMeter and run the test. Request will go to example.com.
Alternatively you can pass myhost property to JMeter in command-line mode as follows
jmeter -Jmyhost=example.com
Multiple properties can be passed this way:
jmeter -Jproperty1=value1 -Jproperty2=value2 ....
And even files via -p or --propfile JMeter command line argument
See Apache JMeter Properties Customization Guide for more options and information.
Clearing all results
It depends on unattended execution option you'll choose, all of them provide at least one way to delete file and/or folder. Personally I wouldn't delete any results and would rather keep them for future reference. To distinguish different endpoints test runs and to avoid overwriting I would use timestamps like:
jmeter -Jhttp.endpoint=my.test.host -n -t your-script.jmx -l my-test-host-results-${date}.jtl
where
-J - sets endpoint to my.test.host
-n - tells JMeter to run in non-GUI mode
-t - specifies .jmx file to use
-l - specifies name and location of results file

TeamCity: How to show parameters in the history

I have 3 servers for PROD, with the same deployment build configuration, I choose which server to deploy depending on a build parameter.
The issue is that reviewing the history you can't check which environment are you deploying.
I wonder if it's possible one of this solutions:
- Show parameters in the history of a build
- Autotag a build with parameters
I hope I had explained well enough.
Thanks in advance
You can accomplish this with a Command Line build step that echoes the relevant parameters to the build log. For a Windows-based agent, you could do something like:
Run: Executable with parameters
Command Executable: echo
Command Parameters: Deployed to server %your.server.host%
This would simply add a line to the build log that reads, Deployed to server FOO
Autotagging would be pretty cool, but I don't know of a way to do that.

Resources