Thrift API load test - jmeter

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!!

Related

Strange labels with suffix -0, -1 in jmeter results

We recently updated apache jmeter from v4.0 to the latest v5.4.3.
The tests are running fine, but we have strange results.
The requests appear with 3 different labels (without suffix or -0 / -1 appended).
timeStamp, label, responseCode, threadName
1643834640785, API call, 200, Load Group 1 1-1
1643834640785, API call-0, 302, Load Group 1 1-1
1643834641189, API call-1, 200, Load Group 1 1-1
1643834640785, API call, 200, Load Group 1 1-2
....
It seems to me this happens, when the same thread calls the API multiple times.
I am not a jmeter and I am not sure why this happens and how to fix it. Also I don't know what information is needed to analyze the problem correctly.
Thanks in advance!
I'm seeing HTTP Status 302 which means redirection (for example from HTTP to HTTPS or from global website to country-specific website), in that case JMeter generates additional Sub-Result.
The "strange" labels is how JMeter calculates throughput for embedded resources and the cumulative execution time of the parent sampler in case of redirects as well.
The question is what do you want to do with this.
The options are in:
Take it for granted given the above explanation
If you want the "strange" labels to be resolved into real URLs - tick "Functional Testing" box in the Test Plan
or add the next line to user.properties file:
subresults.disable_renaming=true
If you want to get rid of these subresults completely - add the next line to user.properties file:
jmeter.save.saveservice.subresults=false
More information:
Configuring JMeter
JMeter Properties Reference

How to log "server exec time" = (latency - connect time)

How can I log (by using sample_variables=...,...) jdbc/server exec time which we define as (latency - connect time)?
We would like to use the metric for a custom graph in the Jmeter Reporting module.
Add the next line to user.properties file:
sample_variables=execTime
See Sample Variables user manual entry for more information
Add JSR223 PostProcessor as a child of the request which "exec time" you want to measure or put it at the same level as other JDBC Request samplers (see JMeter Scoping Rules - The Ultimate Guide article for details)
Put the following code into "Script" area:
vars.putObject('execTime', prev.getLatency() - prev.getConnectTime())
it will subtract connect time from latency and store the value into execTime JMeter Variable
Now you should be able to follow instructions from Generating customs graphs over time JMeter user manual chapter

Regarding WebDriver Sampler and Config/Listener Folder Path

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.

How to stop execution of a user in Jmeter after certain data is downloaded

I am testing the performance of a Internet speed test application being build by our company.
The scenario is each user will be downloading 6 files in parallel(six different http requests). So I am using blazemeter parallel controller to replicate this.
Each Jmeter thread will hit these 6 requests in parallel and will move to next iteration.
Now we have to stop or kill the user after it has downloaded x MB of data.
Means any thread which has downloaded X Mb data in all the iterations will stop further iterations.
You could add JSR223 PostProcessor which will be retrieving the response size and check whether it exceeds defined threshold. If it is - you can call setStopThread() function
Example code:
if (prev.getBytesAsLong() > 1000) {
log.info("Sampler downloaded " + prev.getBytesAsLong() + " bytes, stopping")
prev.setStopThread(true)
}
In the above snippet prev stands for the parent HTTPSampleResult, check out Top 8 JMeter Java Classes You Should Be Using with Groovy article to learn more about JMeter API shorthands available for JSR223 Test Elements.

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!

Resources