How run specific csv file based on specific users using jmeter - jmeter

I have test plan like this:
Thread group
|---User parameter(user'scredentials mention there)
|--Request body (same for the users)
|----csv file1
|-----csv file2
Now if it is users.name==joe, this should execute csvfile1 if it is user.name==nmeon, execute csvfile2 through user parameter I got user name in the JMeter console.
How to write the script using IF controller/ bean shell If I use what would the script written for this?

You basically have 2 options:
Change your file names to be nmeon.csv and joe.csv and use ${user.name} in the CSV Data Set Config "Filename" section
Use 2 If Controllers like:
If Controller, condition: ${user.name} == "joe"
test logic specific for joe
If Controller, condition: ${user.name} == "nmeon"
test logic specific for nmeon
Use Switch Controller (the approach is similar to If Controllers)

Related

How to pass the Variable values(VM Name) form text file to jenkins job so that it should perform the task in each VM

I have file consist of 10 VM name.I want to pass the each VM name as parameter for a jenkins job.so that my jenkins job should perform task specified in each machine.Can some one suggest how it can be done.How it can be done using pipeline script.
Example
File.txt consist below variables
VM1
VM2
VM3
..
vm10
and I want to pass the values to jenkins job name called "Setupenvironment"
Please suggest.
You can use the file parameter to pass a file to your job. For a declarative pipeline it looks like the following
pipeline {
parameters {
file(name: 'FILE', description: 'Some file to upload')

Replacing variable value in ruby while setting the value using "set" command

I have a .properties files as below:
user:abcd
pwd:xyz
system:test
Next, I have a ruby script with Watir for browser automation. In this script, I have statements like
browser.text_field(:id => 'identifierId').set "#{user}:variable to be replaced by its value from .properties file".
Similarly, other values need to be replaced for "pwd" and "system".
I tried the solution per below posts:
Replace properties in one file from those in another in Ruby
However, "set" command is setting whatever has been paased as arguments to it instead of replacing the variable with its value.
Please help.
You have to read the information out of the file.
Most Watir users leverage yaml files for this.
config/properties.yml:
user: abcd
pwd: xyz
system: test
Then read the yaml file & parse your data:
properties = YAML.safe_load(IO.read('config/properties.yml'))
text_field = browser.text_field(id: 'identifierId')
text_field.set properties['user']
Alternately you can take a look at Cheezy's Fig Newton gem, which is designed to work with his Page Object gem

How to automatically running multiple load tests in SOAP UI free version?

I have two load tests below with each one being in their separate test cases. This is using SOAP UI free:
Currently I have to manually select a load test, run it manually, wait until it finishes and then manually export the results before manually moving onto the next load test and performing the same actions.
Is there a way (and if so how) to be able to automatically run all the load tests (one by one) and extract each of it's own set of results in a file (test step, min, max avg, etc). This is to save the tester having to do manual intervention and can just let the test run whilst they do other stuff.
You can use the load tests command line, the doc is here.
Something like
loadtestrunner -ehttp://localhost:8080/services/MyService c:\projects\my-soapui-project.xml -r -f folder_name
Using these two options:
r : Turns on exporting of a LoadTest statistics summary report
f : Specifies the root folder to which test results should be exported
Then file like LoadTest_1-statistics.txt will be in your specified folder with csv statistics results.
inspired with answer of #aristotll )
loadtestrunner.bat runs the following class : com.eviware.soapui.tools.SoapUITestCaseRunner
from groovy you can call the same like this:
com.eviware.soapui.tools.SoapUITestCaseRunner.main([
"-ehttp://localhost:8080/services/MyService",
"c:\projects\my-soapui-project.xml",
"-r",
"-f",
"folder_name"
])
but the method main calls System.exit()...
and soapui will exit in this case.
so let's go deeper:
def res = new com.eviware.soapui.tools.SoapUITestCaseRunner().runFromCommandLine([
"-ehttp://localhost:8080/services/MyService",
"c:\projects\my-soapui-project.xml",
"-r",
"-f",
"folder_name"
])
assert res == 0 : "SoapUITestCaseRunner failed with code $res"
PS: did not tested - just an idea

In Jmeter how to pass beanshell sampler result to Thread group

In Bean shell sampler I am getting the line count how to pass the line count to the Threadgroup
import org.apache.commons.io.FileUtils;
int lines = FileUtils.readLines(new File("path to data file")).size();
vars.put("lines", String.valueOf(lines));
this lines variable I want to use to thread group how I can achieve this
please help me on this
Updating the output of Debugsampler
JMeterVariables:
JMeterThread.last_sample_ok=true
JMeterThread.pack=org.apache.jmeter.threads.SamplePackage#1e59359f
START.HMS=081505
START.MS=1449648905577
START.YMD=20151209
TESTSTART.MS=1449652524822
applicationname=test
buildinfo=../data/Test.csv
env=Test
lines=77
package=.zip
First, you can use Debug sampler to verify if you are successfully getting the desired value in your variable.
Second, you can simply call the this variable just like other user defined variables in JMeter. Put ${lines} where required.
If you still face any issues, then let me know in comment or edit your question to add further details.
You cannot configure Thread Group loop count this way as it is being populated on JMeter launch. Here are the options:
Use Loop Controller instead, it is possible to set the number of loops via variable
Define "Loop Count" in Thread Group as a property, like ${__P(loops,)}. In that case you can get CSV file lines count before the test i.e. using the relevant OS command like:
type c:\temp\file.csv | find /c /v "~~~" - for Windows
cat /tmp/file.csv | wc -l for *nix
and pass the resulting value to JMeter via -J command line key as:
jmeter -Jloops=XX -t /path/to/your/testplan.jmx ...
See Apache JMeter Properties Customization Guide for more information on JMeter properties and ways of setting and overriding them.

How can I run a specific 'thread group' in a JMeter 'test plan' from the command line?

How can I run a specific thread group in a Test Plan from the command line? I have a Test Plan (project file) that contains two "thread groups": one for crawling a site and another for calling specific urls with parameters. From the command line I execute with Maven, like so:
mvn.bat -Dnamescsv=src/test/resources/RandomLastNames.csv
-Ddomainhost=stgweb.domain.com -Dcrawlerthreads=2 -Dcrawlerloopcount=10 -Dsearchthreads=5 -Dsearchloopcount=5 -Dresultscsv=JmeterResults.csv clean test verify
I want to pass an argument to run only one of the two "thread group" in that project file. Can you do that with JMeter? I don't want to use an IF controller unless I have to because it feels like a "hack". I know that SoapUI lets you do this with the '-s' option.
I asked this question on the JMeter forum also.
In our tests we use the while controller. It doesn't look like a hack to me and works well. You can turn thread groups on and off easily with the JMeter properties. Note you can't change its status when the test is already running though.
Add While controller - ${__P(threadActive)}
Set JMeter property on JMeter load ( -JthreadActive = true )
Run test
Please note ${__P(threadActive)} equates to ${__P(threadActive)} == true, anything other than true will result in that thread group not running

Resources