JMeter Parameterized Plug-in doesn't work under Loop controller - jmeter

I've noticed that JMeter Parameterized Plug-in doesn't work under Loop
controller. It picks 1st value from CSV again and again..
Can someone help me with the steps?
Please find the attached Snapshot for CSV Data Set Configenter image description here
Please find the attached snapshot for CSV Dataenter image description here
Scenerio: User LogsIn and picks value from csv(1st row) and does a search, then picks second row value and search again(Loop) and logs off. i.e i need to do multiple iteration of search for single user

Change scope of your "CSV Data Set Config" to loop or Sampler instead of "Thread Group" or "Test Plan".
Means
Case 1: Won't work
[Does not work, if the scope of "CSV Data Set Config" to "Thread Group", as shown below]
Thread Group
|
---Loop
|
|
---CSV Data Set Config
Case 2: Should work
"CSV Data Set Config" Scope should be to "Loop controller" or "Sampler", as shown below
Thread Group
|
---Loop
|
------CSV Data Set Config
|
|

Related

JMeter - SubResults are not displaying in Summary table etc

JMeter 5.4.1.
JSR223 script contains several sub steps in complex transaction.
The sub step contains a code like that:
// SendMessage:
def myResult_SendMessage = new org.apache.jmeter.samplers.SampleResult()
myResult_SendMessage.setSampleLabel('SendMessage')
myResult_SendMessage.sampleStart()
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[contains(text(),'Send a message')]")));
WebElement Depot_SendMessage = driver.findElement(By.xpath("//a[contains(text(),'Send a message')]"));
Depot_SendMessage.click();
myResult_SendMessage.setResponseCodeOK()
myResult_SendMessage.setSuccessful(true)
myResult_SendMessage.sampleEnd()
myResult_SendMessage.latencyEnd()
myResult_SendMessage.setResponseData(driver.getPageSource());
SampleResult.addSubResult(myResult_SendMessage,false)
I want to see all sub results, not only the main result, in "Summary table" / "Aggregate report" / "Synthesis report".
Actually, I see subresults only in "View Results Tree", but not in "Summary table".
In user.property file:
jmeter.save.saveservice.subresults=true
in Summary table - configuration - "save sub results" are checked also,
but sub results are not displaying as a labels in resulting tables.
What should I do to collect sub results displayed in Summary table using defined setSampleLabel?
I think you need to add the following lines to user.properties file:
webdriver.sampleresult_class=com.googlecode.jmeter.plugins.webdriver.sampler.SampleResultWithSubs
jmeter.save.saveservice.subresults=true
JMeter restart will be required to pick the properties up
More information:
WebDriver Sampler
Configuring JMeter
Apache JMeter Properties Customization Guide

JMeter update user defined variable at run time

I am trying to update the user defined variable set at a test plan level from a thread group. This is my scenario:
Test plan> user defined variable (variable name/value: fBurst=0)
Test plan> Threadgroup1 > Once only controller> JSR223 test plan (inside the test plan I have the following code)
log.info("fBurst user defined value : " + ${fBurst})
vars.put("fBurst", Integer.toString(111))
log.info("fBurst user defined value vars.put' : " + ${fBurst})
props.put("fBurst", 222)
log.info("fBurst user defined value props.put' : " + ${fBurst})
What I am trying to do here is to update the fBurst user defined value from inside the once only controller sampler and so far not been able to do it using the vars.put or props.put. Is there another way to do this?
Take a look at JSR223 Sampler documentation:
The JSR223 test elements have a feature (compilation) that can significantly increase performance. To benefit from this feature:
Use Script files instead of inlining them. This will make JMeter compile them if this feature is available on ScriptEngine and cache them.
Or Use Script Text and check Cache compiled script if available property.
When using this feature, ensure your script code does not use JMeter variables or JMeter function calls directly in script code as caching would only cache first replacement. Instead use script parameters.
So replace ${fBurst} with vars.get('fBurst") or props.get('fBurst') correspondingly and it should start working as expected
More information: Top 8 JMeter Java Classes You Should Be Using with Groovy

In JMeter, "Save Responses to a File", how can I increment the file name while attaching a custom suffix to the end of the file names

In JMeter, when using "Save Responses to a File" to store http responses, how can I increment the file name while attaching a custom suffix to the end of the file names?
Here was my scenario
Recorded http traffic of a file conversion and download from a web site using the Recording Controller and HTTP(S) Test Script Recorder.
I then moved this recorded traffic from the Recording Controller up to my main Thread Group. This allowed me to rerun what I had recorded.
Then, I add a "Save Responses to a file" to the HTTP Request sampler for the "download" action that I had recorded from the web site.
However, I had trouble with the filename incrementing at the end of the file like this:
testFile.txt1
testFile.txt2
testFile.txt3
I wanted this:
testFile1.txt
testFile2.txt
testFile3.txt
Also, if I did not uncheck "Don't add suffix", then "octet-stream" was my file type, which is not what I wanted:
testFile1.octet-stream
testFile2.octet-stream
testFile3.octet-stream
So, how can I properly increment the file name with the correct file extension?
I'd suggest using __counter() function which can be either virtual-user-specific or global as follows:
testFile${__counter(FALSE,)}.txt - for GLOBAL counter
testFile${__counter(TRUE,)}.txt - for SEPARATE counter per Virtual User
I solved this by doing the following:
Right clicked on the HTTP Request I wanted to add the counter and chose Add -> Config Element -> Counter
Set "1" for "Start" and 1 for "Increment".
Named the Counter with the "Reference Name" of "counter"
In the "Save Responses to a file" mentioned above for the "download" traffic, I put "filename${counter}.xxx" for "Filename prefix:" where xxx is the file extension
Still in the "Save Responses to a file", I also checked the boxes for both "Don't add number to prefix" and "Don't add suffix"
I forgot to mention that, for my "Thread Group", I had set "Number of Threads(users)" to "5" and "Loop Count" to 3. This would give me 15 users.
So, keeping that in mind, my files were named all correctly from:
testFile1.txt
testFile2.txt
.
.
.
testFile15.txt
Hope this helps someone as I struggled with this for a little bit :-).

Apache Jmeter read SQL variables from csv file

Need to load test a Oracle database the requirement is to fire sql queries concurrently to the database reading the varaibles from a CSV file is this feasible ?
Have a CSV file with values like
Name Email
Justin justin#beiber.com
George george#washington.com
...
Micheal micheal#jackson.com
And then have 10,20,30 users fire of queries like
select name,phone,city
from address
where name = <<feild1-from-csv>>
and email = <<feild2-from-csv>>
...
I'd suggest splitting your test logic into 2 separate pieces:
Load information from CSV and store it as JMeter variables
Execute SQL code against Oracle using variables from point 1
In regards to implementation I'd suggest to use 2 separate Thread Groups, the first one will be loading stuff from CSV, the second one will be doing actual testing.
Important: don't forget to check "Run Thread Groups Consecutively" box at TestPlan level to assure that second thread group runs after first one.
Example configuration of 1st thread group:
Counter
Start - 1
Increment - 1
Reference name - counter
CSV Data Set Config
Filename - path to your csv file
Variable names - name, email
Delimiter - if you're using TAB - "\t", if comma - "," without quotes
Allow quoted data - False
Recycle on EOF - False
Stop thread on EOF - True
Sharing mode - All Threads
Beanshell Sampler (this one is optional, JMeter 2.10 is smart enough to store variables for you but I prefer to control everything myself)
Code for Beanshell sampler shoud look as follows:
props.put("name" + vars.get("counter"), vars.get("name"));
props.put("email" + vars.get("counter"), vars.get("email"));
It fetches current "name" variable and stores it as name + counter property.
So given 3 lines is CSV file you'll have following properties:
name1=Justin
email1=justin#beiber.com
name2=George
email2=george#washington.com
name3=Micheal
email3=micheal#jackson.com
You can use Debug Sampler to see JMeter Variables and Properties values
After that in second thread group you can refer stored properties as:
${__P(name1,)}
or
${__property(name1,,)}
in your JDBC Request Sampler.
Both should work.

How do I create a Crystal Report that lists members of Active Directory Groups

I have a task to automatically email a report of who is in a series of groups in AD. I'd like to schedule a report to run once a month from Crystal Reports.
I have followed the instructions to create the OLE DB (ADO) connections and everything connects fine.
In my SQL query, I try:
SELECT member, descripton from 'LDAP://ou=blah,dc=blach,dc=blah' where cn ='TheGroupName'
Crystal Reports allows this command to work. (of course with real server parameters) ;)
However, the member list is blank and the description list is blank. If I add distinguishedName to the SELECT, it returns, so I know it's able to get the object attributes.
Also, I've noticed nested groups. I would probably need to expand those out until I get the user list.
For example:
Group1
Joe
Jane
Group2
Group3
Group2
Larry
Michael
Group3
Tuan
Huyen
I saw a post that suggests doing a ldif to a file and then using CR to parse through it. I'd like to keep this report simple as possible.
Is it even possible to do this?
Thanks,
TT
OK. I got no one to respond... BUT I figured out how to do it.
What I did was I wrote a Powershell script (with AD 2008 modules) to create an XML file.
Then I use CR 2008 to feed from the XML and format it into a pretty report.
Here's my code. In my example, I have supergroups that nest other groups. I need to separate the nested groups from the supergroups and then list out the users.
$theFile = new-object system.IO.StreamWriter("c:\temp\myfile.xml")
$theFile.WriteLine('<?xml version="1.0" encoding="UTF-8"?>')
$theSuperGroupArray = #("SuperGroup1","SuperGroup2)
$theFile.WriteLine('<ADContentGroups>')
foreach ($aSuperGroup in $theSuperGroupArray) {
$strMembers = get-adgroupmember $aSuperGroup
# main element
$theFile.WriteLine('<ADGroup>')
$theFile.WriteLine('<ADSuperGroup>' + $aSuperGroup + '</ADSuperGroup>')
if($strMembers){
foreach($objitem in $strMembers){
if($objitem.objectClass -ne "user") {
$theFile.WriteLine("<ADGroupElement>")
$theFile.WriteLine("<GroupName>" + $objitem.name + "</GroupName>" )
$strNestedMembers = get-adgroupmember $objitem.name
foreach ($objNestedMembers in $strNestedMembers) {
$theFile.WriteLine("<Member>" + $objNestedMembers.name + "</Member>")
}
$theFile.WriteLine("</ADGroupElement>")
}}}
$theFile.WriteLine('</ADGroup>')
}
$theFile.WriteLine('</ADContentGroups>')
$theFile.Close()

Resources