How to set parameters in .jmx file via Jenkins in Blazemeter test - jmeter

What I need to do - create Jenkins job which runs Jmeter test in Blazemeter with some parameters such as a test URL. The parameters should be set in Jenkins before job starts.
What I have done:
Added Blazemter plugin for Jenkins.
Created an appropriate Jenkins job which will use the Blazemeter plugin for building.
Created Jmeter scenario and saved it in the .jmx format. I added a variable ${baseURL} with null value in the Jmeter's test plan which is used in the HTTP request as a Server Name or IP value.
Created a Jmeter test in Blazemeter and uploaded the jmx file. Saved the test.
Tried to run a job with the following parameters described in the session properties field in the Blazemeter plugin baseURL=${baseURL}. I set google.com as a property value in Jenkins.
Results - Blazemeter test has up and ran, it tested http:// however it had to http://google.com.
So the question is - What I did wrong or may be the Blazemeter plugin is not what i need or may be general approach is wrong.

The solution is the following: - use function __P or __property to get parameters into .jmx file. So i put ${__P(baseURL,)} function in the Server Name or IP statement and the Blazemeter successfully tested http://google.com.

Related

Openapi-generator to create jmeter script

I'm using an openapi-generator-cli(5.4.0 v) jar to create a JMeter script. However, it is throwing errors for all the API's in swagger JSON.
I tried generating the script for pet store JSON. It's working.
Please let me know what could be the issue.
I don't think it's possible to use "openapi-generator-cli(5.4.0 v) jar to create a JMeter script", if you want to generate a JMeter test plan from the OpenAPI definition I would suggest doing this like:
Obtain Taurus tool
Use swagger2yaml tool to generate Taurus YAML file from the API specification
Run Taurus as bzt yaml-from-step-2.yml -gui - it will open JMeter with the generated test plan
Save the test plan as JMeter .jmx file

How to pass properties files to Jmeter server in distributed setup

I have Jmeter distributed setup (One client and one server).
In single jmeter instance I'm using the below command to execute jmeter with a properties file that will pass the user defined variables to my test script
/apache-jmeter-5.3/bin/jmeter -p reco.properties -n -t Performance.jmx -l test2server.csv
When I tried to use the same command including the server configurations I noticed that the values defined in my "reco.properties" are not picked at the test execution.
Instead I need to pass all the variables with "-G" argument. Ex:
/apache-jmeter-5.3/bin/jmeter -GENV=test -n -t Performance.jmx -l test2server.csv
is it possible that I can pass all variables in a properties file for Jmeter Server as I do in the normal execution with "-p"?
Thank you
As per JMeter Documentation:
If the test uses any data files, note that these are not sent across by the client so make sure that these are available in the appropriate directory on each server. If necessary you can define different values for properties by editing the user.properties or system.properties files on each server.
So currently as per JMeter 5.4 this is not supported, you either need to pass the properties one-by-one like -Gprop1=value1 -Gprop2=value2 or to copy the .properties file to all the slave machines
The limitation can be also worked around via getting the properties from a dataabse using JDBC Request sampler or with plugins like HTTP Simple Table Server or Redis Data Set
If you do believe that the feature is essential you can try raising an enhancement request in JMeter Bugzilla

Performance Test - Distributed mode with jtl and smtp listener

My test consists of tear down thread that sends the JTL report in the email through SMTP listener. This works fine when I run the tests in non distributed model as the JTL file is in one machine.
The issue I am facing is when I run these tests in distributed mode ( for some heavy loads). SMTP listener fails as the file is not found in the slave where the tests are running since JTL file is in the master. is there anyway I can make this work within the JMeter tests or do I need to create a separate script once the test is done to send the final report through email.
The easiest option would be indeed creating a separate test script for sending the results.
Alternative option would be
kicking off another JMeter Slave instance at the same host with the master
Limiting the SMTP Sampler to be executed only on that host via If Controller and __machineName() or __machineIP() functions combination like this:
This way you will be able to run SMTP Sampler only on the machine where the .jtl file lives.

Save File and close Jmeter GUI with command line

I am currently trying to automatically record a JMeter script using Selenium. Therefore i start Jmeter in GUI-Mode through Jenkins (using a batch file) with activated Script Recorder.
Then i run a Selenium-test also through Jenkins and a batch file. The requests that this Selenioum script is doing are successfully being recorded.
The only step that i was not able to figure out yet is to save the recorded JMX-Script and close JMeter.
Is there a way to do this through command line, batch file or other? Doing it manually is not an option since JMeter is running on a remote node through Jenkins.
I was able to close JMeter through a system exit/kill command but this way the jmx-file is not being saved.
I don't think it's possible as of JMeter 5.2.1, you will need to automate JMeter GUI separately using Appium or Sikuli or ldtp
However I believe it will make more sense to reconsider your approach and go for one of the following options:
Replay your Selenium test using JMeter's HTTP(S) Test Script Recorder as the proxy
Use Taurus tool which has Proxy2JMX Converter
If above 2 options for some reason cannot be used in your environment you can automate i.e. JMeter Chrome Extension from Selenium (check out 6 Easy Steps to Testing Your Chrome Extension With Selenium for details) so you will be able to start the recording and export resulting .jmx script directly from your browser without having to communicate with the remote Jenkins/JMeter instances.

Is it possible to reuse created jmeter test plan for another test environment?

I have recorded a jmeter script for wiki page. That record was done in one of our test environment. That script is working fine and now i want to perform same load test for another test environment(Both environments are same, only urls are different).Is it possible to reuse?How can i do it?
I have added HTTP Request default element at the begging of test plan creation. Now recorded script consist of many HTTP Request element. Each request element contains Server IP of test instance.
Extract IPs and other env-specific data to .properties file:
http://jmeter.apache.org/usermanual/get-started.html#options
Read them in your JMeter with JMeter built-in function ${__P(someName)} as you see fit
Run your generic JMeter test with env-specific config data in .properties file
Yes. It is possible to run the same test in multiple environments. It all depends on how you design your test plan.
This site has exact details you are looking for.
http://www.testautomationguru.com/jmeter-manage-test-plan/

Resources