Regarding WebDriver Sampler and Config/Listener Folder Path - jmeter

While trying to write Webdriver sampler with Config/listener element ,I have below issue ,Could any team assist me for the same?
1:- In config /listener element/webdriver browser setup file , if we want to enter some value from external resource (' or if we want to save summary report in PC, Is there any procedure to give unique path that can be run in any workstation /pc/ any directory after giving file name only because if we execute in other station or move file in other directory, everytime we need to change file location?Could you please guide me for the same?
While writing webdriver sampler request,I am able to execute script but i am getting below error in log viewer window and also wanted to break functionality as very small unit label for one webdriver sampler request{launch site/login successfully,validate record, logout} so after searching on google , i used sub sample start or samplestart function multiple time , but i am not getting label name in view tree listener result after setting one jmeter property. Could you please guide me for the same?
3:- Could we run three thread group at same time(all three thread run at same time) or some interval (first and sec run on same time but third start after 10 minute)
Thanks you for giving valuable time in advance?
Thanks Amit

You can give only the filename and JMeter will look for the CSV file and write results file into JMeter's "bin" folder (or the place where you launched JMeter from). You can also use __P() function to parameterize the file name or even path, for example if you do set your CSV Data Set Config like:
${__P(testdata,TestData.csv)}
you will be able to override the path using -J command-line argument like:
jmeter -Jtestdata=/path/to/somefile.csv
If you don't provide the property, default value of TestData.csv will be used. More information: Apache JMeter Properties Customization Guide
You're getting this "Invalid call sequence" error because you have duplicate WDS.sampleResult.sampleStart() function call, just remove one of them and that would be it.
Add a Constant Timer as a child of the first request or Flow Control Action sampler at the beginning of the Thread Group 3 and configure them to sleep for 600000 milliseconds.

Related

JMeter: CSV Data Set Config "Lines are read at the start of each test iteration." - how exactly should it work?

I'm concerned with work of CSV Data Set Config along JMeter rules set with scoping rules and execution order.
For CSV Data Set Config it is said "Lines are read at the start of each test iteration.". At first I thought that talks about threads, then I've read Use jmeter to test multiple Websites where config is put inside loop controller and lines are read each loop iteration. I've tested with now 5.1.1 and it works. But if I put config at root of test plan, then in will read new line only each thread iteration. Can I expect such behaviour based on docs only w/out try-and-error? I cannot see how it flows from scoping+exec order+docs on csv config element. Am I missing something?
I would appreciate some ideas why such factual behaviour is convenient and why functionality was implemented this way.
P.S. how can I read one line cvs to vars at start of test and then stop running that config to save CPU time? In 2.x version there was VariablesFromCSV config for that...
The Thread Group has an implicit Loop Controller inside it:
the next line from CSV will be read as soon as LoopIterationListener.iterationStart() event occurs, no matter of origin
It is safe to use CSV Data Set Config as it doesn't keep the whole file in the memory, it reads the next line only when the aforementioned iterationStart() event occurs. However it keeps an open file handle. If you do have really a lot of RAM and not enough file handles you can read the file into memory at the beginning of the test using i.e. setUp Thread Group and JSR223 Sampler with the following code
SampleResult.setIgnore()
new File('/path/to/csv/file').readLines().eachWithIndex { line, index ->
props.put('line_' + (index + 1), line)
}
once done you will be able to refer the first line using __P() function as ${__P(line_1,)}, second line as ${__P(line_2,)}, etc.

JMeter - Use a test fragment from another .jmx

in my project I need to have a jmx (let's call it main.jmx) script that will have a bunch of TestFragments (of which each of them will be a UserJourney composed by multiple requests and "flows") and I want to have other jmx files that might point to some of the test fragments of the main.jmx to use only some of them. I know that there is the IncluderController but if I am not wrong, it does not allow me to execute parts from other script but the script as a whole.
The idea is to have a single jmx (main.jmx) that would "store" all the UserJourneys and have other multiple jmxs that would be able to call some UJs from the main script.
Is there a way to have something that allow me to do the job without needing to create a jmx for each UserJourney and set them in multiple IncluderControllers?
Thanks in advance.
You need to have a proper Single Test Plan in place.
(UserJourney.jmx)
Test Plan
-Thread Group
-Transaction Controller#1 (main)
-Data sampler (jdbc etc)
-Request Sampler / TestFragments
-Response Extraction(json extractor/regular exp extractor)
-Transaction Controller#2 (UserJourney)
-Request Sampler / UserJourney (takes response from main controller as request params)
-Listeners
Cheers!

Jmeter property get/put issue

I have the following flow,
Thread Group 1
-JSR223 Sampler - props.put("x",10);
Thread Group 2
Number of threads(users) = ${__P("x")}
I am setting a property value which is not defined in any property file as 10. I am trying to use that value in the next thread group. But instead of ten threads, I get only 1 thread to start.
Documentation says ${__P()} would give 1 if the property is undefined. How can I set the THread Group 2's thread count to x value?
You need to pass that value from command line, when you run the test appended by -Jx.
So when you run your test, Pass value of X from command line
-JPropertyName=ProperyValue
This will pick up value as 10.
Setting property should be
props.put("x","10");
i.e. it wants value in String format, and function should be put, not set.
Thread Groups are being initialised during JMeter startup so you won't be able to set the number of threads in the Thread Group this way. You have 2 options:
Set the property value in user.properties file (lives in the "bin" folder of your JMeter installation) like
x=10
Pass the property value -J or -D command-line arguments like
jmeter -Jx=10 -n -t ....
jmeter -Dx=10 -n -t ...
The default value returned by the __P() function will never be 1 due to a bug in JMeter (you can report it via JMeter Issue Tracker if you want), its default value will be an empty string. If you want the __P() function to return 1 as default value you should be using it like ${__P(x,1)}
See Apache JMeter Properties Customization Guide guide for more information on working with JMeter Properties, ways of setting and overriding them, etc.
Although you cannot change the number of threads on the fly, you can control how often the samplers are executed via Constant Throughput Timer. This way you can use __P() function to set the desired throughput rate (in requests per minute) and you can change the associated property value on the fly even outside of the JMeter script.

Beanshell script launched once (start and end of test plan) in JMeter

Good afternoon !
I will try to explain you clearly my problem.
The context
I have a JMeter TestPlan which send HTTP requests to a server. I have a Beanshell script to assert each different case of error returned.
302 response code -> OK
200 response code -> ?
In each error 200, I check the response data string to see if it is an error or a correct case. (User error like User don't have correct rights is OK, but Server is unavailable is ERROR and both have 200 as response code.)
Here is my test plan :
The goal
As I have several errors returned by only one assertion script, I am not able to differenciate each error, except by uncollaspe the assertion in a ViewResultTree. But I disable it when launching my test, and I will launch my TestPlan remotely.
I had the idea to manually count each error. All my samples goes in my Assertion script, and goes to the correct if block according to their content. I increment some variables (JMeter.properties in fact) in each block.
int test = Integer.parseInt(props.getProperty("302"));
test++;
props.setProperty("302", ""+test);
I want to display all those variables in a JFrame at the end of my testplan like this :
The problem
My problem is that I don't know how to launch a Beanshell script before and after the TestPlan.
I want a first script to be started before any sample is send, just to initialize all my properties variables to 0 (else, they keep the value of the last TestPlan).
And, I want a second one to display my Frame with all the variables after the test plan is finished. (Currently it is a JFrame but it will not stay like this.)
Tested solutions
1) For my first script, I set a Counter (JMeter > Config Element > Counter) in the beginning of my test plan to 0.
I use it to check if my test already started of not with an If Controller :
I have a Pre-Processor Beanshell with props.set("302","0"); where "302" is my property to count all 302 response code.
It correctly works but I want to know if there is a proper way to do this.
2) Then, for my second script, I tried to use ${JMeterThread.last_sample_ok} in an If Controller aswell but it doesn't work like I expected. If I put it after my sample, it start after all OK assertion, and if I put it at the end of the test plan, it is never called.
How can I run my beanshell script once, after all my threads are stopped (i.e. all sample finished) ?
Thank you in advance, I hope you understood everything !
JMeter SetUp thread group and TearDown thread group are meant for exactly this.
Add your beanshell component to the setUp thread group to do some setup activities before your actual test starts. Similarly the tearDown thread group runs after your test execution is complete.

Thrift API load test

I am new into Apache Jmeter. Basically I want to load test our couple of thrift APIs but have no clue where to start with. It is in java where api takes 2 parameter and then send java object as response.
Any pointer would be very helpful.
JMeter isn't especially for it but it's flexible enough to support your use case.
There is an extensibility mechanism which uses BeanShell. JMeter provides BeanShell Sampler which is capable of invoking Java code, including using external jars.
Simple usage:
Start with empty JMeter project
Create a Thread Group with all defaults (you can play with number of threads, ramp-up, etc)
Add a BeanShell Sampler with following code:
Thread.sleep(2000L);
Add View Results Tree listener
Save and run
You should see a green triangle (or triangles) basing on your number of threads and loops) with output like following:
Thread Name: Thread Group 1-1
Sample Start: 2013-11-02 14:48:11 GMT+03:00
Load time: 5030
Latency: 0
Size in bytes: 0
Headers size in bytes: 0
Body size in bytes: 0
Sample Count: 1
Error Count: 0
Response code: 200
Response message: OK
If you use any of techniques to analyze results, i.e.
JMeter embedded listeners like Aggregate Report, Summary Report, Graph Resuls, etc.
Storing results to CSV file and opening them with Excel or equivalent (see jmeter.properties file under /bin directory of your JMeter installation. Properties prefix is "jmeter.save.saveservice."
JMeter Ant Task (see Test.jmx and build.xml in /extras folder under your JMeter installation)
JMeter Results Analysis Plugin
You'll see your request(s) success rate, min/max/average times (something like 2 seconds I guess) and some more information (depending on your configuration).
Particular your use case assumes
IMPORTANT Placing thrift (or whatever) jars under lib/ext folder (or you won't be able to access your APIs
importing classes you need to test somewhere in BeanShell Sampler
import yourpackage.YourClass;
Invoking methods you want to test from BeanShell Sampler
(optional) do some assertions on responses. i.e.
if (yourresponse != yourexpectedresponse){
IsSuccess=false;
ResponseMessage= "Test Failed";
}
Hope this helps
You can use JSR223 Sampler + Groovy (add groovy-all.jar in jmeter/lib) and look at this client example, see NonblockingClient code for an example:
http://www.javacodegeeks.com/2012/03/apache-thrift-quickstart-tutorial.html
Make your groovy code call a least the following at end:
SampleResult.setSuccessful(true/false)
SampleResult.setResponseCode("code")
SampleResult.setResponseMessage("message")
See:
http://jmeter.apache.org/usermanual/component_reference.html#JSR223_Sampler
And of course, ensure you add the required dependencies in jmeter/lib.
I have writtena CustomThriftSampler for JMeter to load test HBase through thrift service. You can get the details about it at my blog - http://1-st.blogspot.in/2013/12/load-testing-thrift-services-custom.html . Couldn't create a generalized code. Anyway its simple and starightforward java code. Anyone could try it. If time permit I shall write a generalised code and commit to github!!

Resources