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

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/

Related

JMeter won't write response data

I'm running tests with JMeter (master+10 slaves) on elasticasearch. I'm getting error 400 for some requests but they are a bit elusive:
When I run the requests manually with curl or pasting them on kibana's console, I don't get errors.
Every time I run the tests using jmeter, using the same requests and under the same conditions, I get a different number of errors.
So I was thinking of inspecting the response bodies from jmeter. But all the ways I've tried failed:
I've created a View Result Tree element and checked all boxes on the "configure" panel. When I run the script, it logs everything except response data
I've tried a BeanShell post processor to write all responses on a file. But it apparently is being 'ignored' when I run the script
Both these solutions work on my machine, but not on the server (which I don't have total control over). I'm passing jmeter.save.saveservice.response_data=true on the command line to start jmeter.
What else could I try?
This is an optimization that JMeter makes for distributed testing related to the mode:
https://jmeter.apache.org/usermanual/properties_reference.html#remote_batching_config
To avoid JMeter stripping the response data set in user.properties of servers snd controller:
mode=Batch
As by default it is:
mode=StrippedBatch
By default JMeter slaves don't send response data to the master, you can choose a different sample sender if you need more data.
Writing response data into a file using Beanshell should work in any case (however consider using JSR223 Test Elements and Groovy for this), just make sure that:
your Beanshell PostProcessor is placed correctly according to JMeter Scoping Rules
there are no Beanshell-related messages in jmeter.log files
you will need to collect the log files from each slave manually after test run, they will not be generated on the master

how to run tests as per respective suite in jmeter

I have created some testcases in Jmeter.
Now I want to run them separately example smoke testcases only.
Is there any way in Jmeter so I can run my JMeter project for a particular group/collection/suite only.
Is Jmeter provide any annotation or containers mechanism from where I can achieve same.
I have written my cases in Jmeter in below assertions
JSR223 Assertion
Response Code
Response Text
Any workaround will be helpful and appreciated in advance
The right way to module your JMeter scripts is to save small script in different JMXs and combined them by calling each or inside a bigger JMX file which uses Include Controller to execute different JMX files
The include controller is designed to use an external JMX file. To use it, create a Test Fragment underneath the Test Plan and add any desired samplers, controllers etc. below it. Then save the Test Plan. The file is now ready to be included as part of other Test Plans.
Inside JMX you can also use Module Controller to reduce code duplication
The Module Controller provides a mechanism for substituting test plan fragments into the current test plan at run-time.
If you want to execute specific test I suggest send specific properties and check the property inside an If Controller .
for example call with property jmeter -JexcludeTest1=true ...
And add an If Controller before test 1:
"${__P(excludeTest1)}" == "true"
The easiest way is using Taurus tool as a wrapper for your JMeter script, it has Modifications for Existing Scripts feature where you can define which test elements you want to enable/disable during test execution.
scenarios:
modification_example:
script: tests/jmx/dummy.jmx
modifications:
disable: # Names of the tree elements to disable
- Thread Group 1
enable: # Names of the tree elements to enable
- Thread Group 2
See Navigating your First Steps Using Taurus to get started.
Another option is putting requests you would like to enable/disable on demand under If Controllers so you could set "run/not run" condition dynamically.

JMeter - saving results to both CSV and XML

What I try to achieve is to get JMeter results in 2 formats, for the same test execution. CSV is the one I'm mostly interested in, unless there are failures - then I may need to use data which can be saved only to XML. I can't use XML for most occasions, due to misc reasons.
I was looking at jmeter.save.saveservice.output_format cfg entry, it doesn't seem to accept both as valid entry. I was also looking at JMeter code itself, it also clearly separates both options.
Did anyone invent a hack to get both JMeter outputs at the same time?
Solution for both standalone JMeter and jmeter-maven-plugin is welcome.
If you use JMeter Maven plugin, as per Five Ways To Launch a JMeter Test without Using the JMeter GUI guide the default output has to be XML.
If you need CSV output as well - just add Simple Data Writer listener. If you looking for CSV data to be in line with JMeter default CSV values configure it as follows:

Jmeter testing on multiple websites on the same server

I have a working script to login and get to one website on the webserver, what I need is how to get to the other 10 plus servers with Jmeter all at once to do a nice stress test on the websites and its interfaces.
Any help is greatly appreciated
I think that you need to use DNS Cache Manager available since JMeter 2.12
DNS Cache Manager allows each JMeter thread to resolve underlying IP address of the request endpoint on its own.
See The DNS Cache Manager: The Right Way To Test Load Balanced Apps guide for detailed explanation of background and configuration details.
This is pretty trivial using the CSV Data Set Config.
Let's assume you are using normal HTTP Request samplers and that these are already set up with a server and path. Let's say it is the server you want to change for each thread. Then you need to:
Create a text file with a different server you want to test on each line.
Add a CSV Data Config element to the top level.
Configure the CSV Data Config to use your text file and set the variable name of server.
In your samplers change the server name to ${server}.
You can use the same method to change the path and other details.

Distributed JMeter tests with per-slave CSV datasets

I'd like to run a distrubuted JMeter test on our site, following the
manual. My tests are parametrized via a CSV DataSet configuration element to simulate diffent users. The question is now: Will JMeter use the same DataSet for each slave, or can I somehow configure each slave with its own dataset? If the first is the case, slaves will steal each other's session which is of course undesired.
Jmeter use local CSV fiels in distributed mode. So you just place different files on each slave and it works. Nothing special to do.
You can choose the CSV Data behaviour with the Sharing mode option. Description of each option detailed in:
http://jmeter.apache.org/usermanual/component_reference.html#CSV_Data_Set_Config

Resources