HTTP Request path needs to be parameterized with UUID and a random URL - performance

URL format is
www.something.com/something/api/{uuid}?code=gomundw0gjq2kbvc3g63whfr9usap5rurjaq5vui5vm6xbt9hhqa8hbcpto4yatwpn26v42t9
I need to make several calls to this GET Url and check performance of the feature.
uuid here is not just the UUID , but is specific to my application
UUID= accountid+identifierid+uuid, which will look like 1234+1234+123e4567e89b12d3a456426655440000
How should I arrange my Jmeter Test Plan.
My Plan would be:
write UUID generated to a file
Using any preprocessor call the file from file and write program to append to a different value in the csv which is account/identifierid.
Please help on this, can some one explain how I should logically arrange my test plan and code to get data to parameterize my path in HTTP Request sampler.
Thanks in Advance

You need to get accountid+identifierid information stored into CSV file. This is something you need to do on your own.
You can use CSV Data Set Config in order to get the information from that file while your test is running, example configuration would be:
UUID can be generated using __UUID() function
So your HTTP Request sampler configuration would be something like:

Related

How can i generate a coulmn value as a random value in a csv file while doing load test with Jmeter

I am using Jmeter for load testing. I am passing parameters of the body from a csv file for an api. But our application will not receive the duplicate value. So when i load test by multiple users, the request get failed.because i am passing same parameter value for all users.So i need to make some of the columns with an instant value(random). so that different users will get different values.
{
"clinic_name":"clicnic",
"first_name":"provider1",
"initial":"v",
"last_name":"doc",
"salutation":"salu",
"address_1":"testttadd1",
"address_2":"testtttadd2",
"city":"ckdy",
"state":"Arizona",
"zip":"12365",
"fax":"",
"email":[{"email_id":"dfdf#dzcz.in","type":"Work","note":null}],
"phone":[{"number":"1235974444","note":"","type":"Mobile","extension":""}]
}
here i have given the request body and i need different email for different users. How can i do this?Can anyone help me..Thanks in advance.
you can use __RandomString function for the value of email_id:
"${__RandomString(15, abcdefghijklmnopqrstuvwxyz)}#${__RandomString(10, abcdefghijklmnopqrstuvwxyz)}.in"
The easiest is using Faker library like:
Download Java Faker jar and drop it to JMeter Classpath
Restart JMeter to pick the .jar up
You can use the following __groovy() function directly in the HTTP Request sampler body:
${__groovy(new com.github.javafaker.Faker().internet().emailAddress())}
Alternatively you can put the above expression into your CSV file, however make sure to wrap the variable reference into __eval() function, for example if you had ${email} you will need to change it to ${__eval(${email})}

Jmeter can get parameters?

My question is - if I run a test via Jmeter, for example , if it's a site which enables you to book a flight, and you choose your source and destination when you record it.
Is it possible to pass different values to the destination field? I mean, maybe a txt file with some destinations and pass it to the Jmeter test and then, you will have some tests which each of them is running with a different destination?
If yes, how can I do it?
It's not necessary that it will be a txt file. Just a way to pass different values to one parameter.
Important: I'm using blazemeter plugin for chrome.
Thanks a lot,
appreciated.
You can use CSV Data Set Config. It is very easy to use for parameterizing variables in the test plan.
Check this article on blazemeter to understand the CSV Data Set Config quickly.
Depending on what you're trying to achieve you can go for:
HTML Link Parser. See Poll Example which shows how you can use it for selecting random values from inputs
You can extract all the possible values from the previous response using a Post-Processor, most probably CSS Selector Extractor and configure each thread to use its own (or random) value from the input
And last, but not the least, you can use an external data source like .txt or .csv file and utilize __StringFromFile() function or CSV Data Set Config so each thread (virtual user) would read the next value from file instead of using recorded hard-coded values.

JMeter - Get header value and write in a log file

I am doing API REST Performance testing. For each API call, I have to send a unique Transaction and request ID in headers.
I use ${__UUID()} in headers, and it's working fine.
To track the transaction id in server logs, I want to print that function( ${__UUID()}) generated value in a log file with API name. For that, I have tried many ways, but those are very complicated and messy. Without adding a preprocessor can we log the value of the transaction id value from the request header?
I would be grateful if you throw some light on this.
I didn't understand why you don't want top use a preprocessor. I think it would be the best solution to generate the uuid in a script and store value before each request execution:
import java.util.UUID;
String uuid = UUID.randomUUID().toString();
log.info("Next uuid "+uuid);
vars.put("uuid",uuid);
Use the ${uuid} in your request header.
If you want to have the generated GUID printed in jmeter.log file - just wrap it into __log() function like:
${__log(${__UUID()})}
This will both generate the GUID and print the corresponding line into jmeter.log file:
More information: Apache JMeter Functions - An Introduction

Automatically generate HTTP request URLs in JMeter

I have an API call URL similar to this:
http://domain.com/rest/getValues?apiKey=sdfsdf&customerId=2200&timestampBegin=2013-08-15%2018:00:00%20CEST&timestampEnd=2013-08-19%2018:00:00%20CEST
I would like to dynamically change the time stamps, as well as the customerId, picked from a given set of timestamps and customerIds. Is this possible to do in Jmeter (preferably through GUI)?
Assuming that you are have inputs coming from external CSV file, you can use CSV data set config as explained here.
Your test plan will look something like
Thread groups
CSV Data Set config (define the file path and the variable names. You will be able to read these variables in request.
HTTP Sampler
http://domain.com/rest/getValues?apiKey=sdfsdf&customerId=${custid}&timestampBegin=${begin}&timestampEnd=${end}

JMeter JDBC Sampler extract more than one column values

I have a sql like the following in JDBC Sampler of JMeter
select id,code from table where .....
how do I extract the value of the two columns.
Are you asking how to extract a value from the response?
If so, use the post-processor "regular expression extractor", attached to the JDBC request.
If you want to extract all data, you can use he post processor "Save Response to a file".
http://jmeter.apache.org/usermanual/component_reference.html#Save_Responses_to_a_file
What is good is that the output for each request is extracted to a separate file, very useful if you use the CSV data config with your request. You just specify the prefix for files.
The output will look like :
result_save_1.plain
result_save_11.plain
result_save_13.plain
result_save_15.plain
result_save_17.plain
ETC...
The Variable Name is very useful because it describe how you can reintegrate thoses files in JMeter using the variable name.
JMeter is a killer app!

Resources