java.io.FileNotFoundException With jmeter testplan while running it from Jenkins-Maven build - maven

I am using File Upload (Post) Rest API in jmeter. file Path in the file upload section I have given as "File name" directly as its in the same folder where jmx file is.
Its working fine in jmeter ui but when running it through Jenkins I am getting file not found Exception.
how ever I am not sure whether I need to update anything in POM file or my jmx file it self to make jenkins find file path.
Current Scenario Jmeter:
jmx file location: xyz/test.jmx
Fie upload location: xyz/abc.file
file path in Jmeter UI(HTTP POST request): abc.file
Result: Working Fine
Current Scenario Jenkins:
jmx file location: xyz/src/test/jmeter/test.jmx
Fie upload location: xyz/src/test/jmeter/abc.file
file path in Jmeter UI(HTTP POST request): abc.file
Result: getting file not found exception
please suggest me solution if any I have already checked many blogs/answers. but none of them result my situation.
Thanks,
Divyang Raval

I believe when JMeter is being run from Maven it tries to look for files under the following folder:
target\jmeter\bin
So the options are in:
use full path instead of relative
copy the file from its original location to target\jmeter\bin folder using i.e. OS Process Sampler from setUp Thread Group
given you don't execute mvn clean copy the file to target\jmeter\bin folder once
The best solution would be using Jenkins Parameterisation, i.e. pass WORKSPACE Jenkins Variable property value to Maven build and access it in JMeter via __P() function

Related

Build passes but seems JMeter test is not running through Maven CMD command

I am trying to execute my JMeter scripts through Maven. I am using Jmeter 5.3 and I am using below pom.xml.
When I execute it through command prompt mvn verify -Dusers=1 -DrampUp=1 -Dloopcount=1 -Durl=1 -DSmokeDemoTest=1, it shows me the build success message but seems it is not executing my JMeter test script that's why I am not getting JTL report file in target folder. I am attaching command prompt execution screenshot. Could you please suggest and help me out on this issue.
POMXML:
CommandPromptExecution Image:
Your test is running fine, the only problem is that there are 0 samplers executed therefore there are no results.
From your very beautiful screenshot of the pom.xml file it's not very clear how do you define the users property, you should have something like:
<properties>
<users>1</users>
<rampUp>1</rampUp>
<loopcount>1</loopcount>
<url>http://example.com</url>
<suite>foo</suite>
</properties>
in the beginning of your pom.xml file.
Once done the properties will be declared and you will be able to override them via -D command-line argument.
Also make sure to properly reference the properties in JMeter test plan using __P() function
If you will still be experiencing problems check the jmeter.log file(s) under target/jmeter/logs folder for any suspicious entries
More information:
How to create user defined properties in Maven
How to Use the JMeter Maven Plugin

Executing Jmeter script using TestNG does not execute JMX script under Include controllers

We are using TestNG framework to run JMeter script. Our Jmeter script includes few include controllers. When we execute using JMeter UI, the script gets executed successfully. But when script is executed using TestNG frame work either it throws error like path not found (for relative coded path) or include controller step is skipped (for Hard coded path)
Tried with Hard coded path as well as relative path to include the other test fragment
Relative Path for JMX file in include controller: "../../../lib/SM_TestFragments/XML/clearDBTables.jmx"
Absolute Path for JMX file in include controller: "/home/test/REMS_CI_Test/AutomationHome/lib/SM_TestFragments/XML/clearDBTables.jmx"
When include controller have "../../../lib/SM_TestFragments/XML/clearDBTables.jmx" path, it throws error as:
09:27:19.603 [StandardJMeterEngine] ERROR org.apache.jmeter.control.IncludeController - Include Controller 'Include Controller' can't load '../../../lib/SM_TestFragments/XML/clearDBTables.jmx' - see log for details
09:27:19.623 [StandardJMeterEngine] ERROR org.apache.jmeter.util.JMeterUtils - Including file "../../../lib/SM_TestFragments/XML/clearDBTables.jmx" failed for Include Controller "Include Controller", unexpected error - see log for details
Including file "../../../lib/SM_TestFragments/XML/clearDBTables.jmx" failed for Include Controller "Include Controller", unexpected error - see log for details
When include controller have "/home/test/REMS_CI_Test/AutomationHome/lib/SM_TestFragments/XML/clearDBTables.jmx" path, There is no entry in log. The step is skipped.
Consider checking jmeter.log file, it should contain more information regarding what went wrong.
One of possible reasons I can think of is that the .jmx script you're referencing using hte Include Controller has one or more JMeter Plugins and when you run the test using TestNG the plugin(s) is(are) not in Java Classpath
If you don't have jmeter.log file generated as the result of your test run consider setting log4j.configurationFile property pointing to the log4j2.xml file location

How to set path to the file location in the "CSV Data Set Config" if csv.file is located in bitbucket

I want to run Jmeter project in Jenkins. I commited project.jmx and related csv files in bitbucket. How can I set the path to the csv file located in bitbucket
CSV Data Set config will accept
Absolute path (the complete path like c:\path\to\csv\file.csv)
Relative path from the test (csvfolder\csvfile.csv)
csvfolder
csvfile.csv
.jmx
Assuming the 'csvfolder' folder is present where you have .jmx
If your folder structure is as given below,
csvfolder
csvfile
jmxfolder
jmx
then your CSV file path should be ../csvfolder/csvfile
Not sure about you specific combination, but usually if your files are in the same location you can refer to them by name only.
Let's say
%JMETER_HOME%\jmeter -n -t %LOAD_TESTS_RUNNER_%/_warmup.jmx
-Jusers=1 -Jrampup=5 -Jloop=2 -JpathToToken=Token.txt
Token.txt is just located in the same directory as *.jmx file.
Optionally, you could use system variables to contain your paths.
Depending on your Bitbucket underlying repository type you can configure Jenkins job to be triggered by commit using
Jenkins Git Plugin
Jenkins Mercurial Plugin
So you will be able to refer paths to JMeter .jmx and .csv files just using their names. Or if you prefer full paths - you can use WORKSPACE Jenkins variable like:
%WORKSPACE% - for MS Windows Family
$WORKSPACE - for Linux/Unix/MacOSX
See Continuous Integration 101: How to Run JMeter With Jenkins article for more information on running JMeter tests from Jenkins
How to read data from CSV File and run jmx for linux
If my jmx file is login.jmx
my input file is users.csv
what should be the syntax or command in linux

Atlassian Bamboo - Display JMeter test results using JMeter Aggregator plugin

I've been tasked to install and figure out how to use the JMeter Aggregator plugin for Bamboo on a locally built vagrant server with Bamboo on it on my machine so I can learn how to use it before putting it on the project that I'm working on's Bamboo instance but I can't figure out how to get the Aggregator plugin to actually read any of the test results properly so it keeps failing the assertions.
Currently, I've just set up a JMeter test through the gui client and saved the .jmx to my jmeter folder on the vagrant server so I can run it headless from a bash script and send the results to a .jtl file in another directory. Below is the bash script:
I've got the Aggregator plugin installed and I've pointed it to the resulting .jtl file but when I try and put any assertions on it, it breaks the build and says the assertion failed because the value was 0, which is not actually the case. Below is the current configuration I've got on the plugin - I've tried changing the filepath to an absolute one but that didn't fix it so I don't know if it's pointed at the wrong file or if it needs to be XML to do anything with the data it gets out?
If anyone could offer any guidance on this, I'd really appreciate the assist - been struggling with this for a couple of days now and there's precious little in the way of documentation on it...
I know it is an old post, I recently came across a similar issue.
hope this helps.
Bamboo looks for .jtl files in working directory of the job. So instead changing directory give absolute/relative path of the JMeter executable file changing the command to
bash <path to jmeter executable>jmeter -n -t <path to jmx>/steve.jmx -l results.jtl
While giving Build log file path use expression like
**/<file_name>.jtl (for picking up specific file)
or you can also use
**/*.jtl (to pickup all files available in working dir).

Create multiple jmeter.log files

I am using Jmeter for performance testing and running our tests via Jenkins build server.
We have Jmeter installed on our jenkins box and I am using an Ant build file to launch the jmx file and create the jtl report; which is then evaluated via the Performance plugin in Jenkins.
My problem is that we only have one instance of Jmeter and as such it only creates one jmeter.log file in the /bin directory.
As we will have multiple jobs calling the one Jmeter installation I don't want it, potentially, writing to the same log.
Is there a way of specifying multiple jmeter.log files per plan/job or amending the location?
Thanks for your suggestions. Using a Jmeter Ant Task and have managed to place the log file into the workspace of the jenkins job by the following:
jmeterlogfile="${basedir}/jmeter.log"
This sits within the JMeter tags within the build file.
Without changing .properties file, running jmeter from Windows cmd, simply navigate to bin folder and pass the argument -j[yourLogFileName.log], if you want log entries in a different log file.
C:\apache-jmeter-2.11\bin>jmeter.bat -j myLog.log

Resources