How to correlate drop down list - jmeter

I have a response like below-
"distributionChannelList":[
{
"id":1,
"description":"Agency1"
},
{
"id":5,
"description":"Agency2"
},
{
"id":4,
"description":"Agency3"
},
{
"id":3,
"description":"Agency4"
}
],
"marketingTypeList":[
{
"id":1,
"description":"Type1".......
There are so many 'id' and 'description' values in my response. Agency1, Agency2.. are drop downs in my application.
So I want Jmeter to pick a different agency every time and pass in subsequent requests.
How to achieve this?

Use json extractor or reg Ex to fetch all the description with Match No. as 0 for random. Pass the Json created variable to the next request like ${varDescription}. On every run, random value will be fetched and provided to the next request.
Below snapshot is an example for regex but prefer json in your case. For fetching with json use $..description as json path expression. Repeat the same for others if required.
Hope this helps.
Update:-
Please check the below config. It will extractor 2 values in sync. But, ${cnt} should be same value. I have used counter just for demo. You can use random function to generate value between 1 to 4 and pass that variable ${rnd};${rnd}.

Related

Search for array value inside JSON column

When there is a single value, whereJsonContains does the job. But in this case, I have an array which is as a result of saving to JSON column being converted into string. Here is the example:
[
{
"key":"cUyV6kW3noxxW85G",
"value":"value-1",
},
{
"key":"R8dHf4vWBS8M4W5G",
"value":"value-2",
"multidimensional_array":{
"table":[
{
"attributes":{
"array":"[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\"]"
}
}
],
}
},
{
"key":"cUyV6kW3noxxW85G",
"value":"value-3",
},
]
I want to get those elements which contain specific value inside array. Here is my try, but it's not working, no results are being returned:
ExampleTable::whereJsonContains('example_column', ['multidimensional_array' => ['table' => ['attributes' => ['array' => $specific_value]]]])->get();
Is it even possible to do it this way, or do I need to get every single result which has multidimensional_array and json_decode() array so I can iterate over it to look for what I need?
take a look at the documentation: https://laravel.com/docs/master/queries#json-where-clauses
You should use the whereJsonContains a bit different;
ExampleTable::whereJsonContains('multidimensional_array->table->attributes->array', $specific_value)->get();

Jmeter extracting response multiple id from array

I am traying the extract the term-id- id value -200000000326 from the below response. controlled-term can have multiple term-id, I have tried with Json extractor $..controlled-term.[[term-id]].[id] and [Thursday 12:22 PM] G, Shwetha C
$..term-id[id]
but this is returning null. can you please help
enter code here:
{
"controlled-terms": {
"controlled-term": [
{
"term-id": {
"id": "200000000326"
},
"term-names": {
"term-name": [
{
"lang": "en",
"name": "All"
}
]
}
}
]
}}
For particular that JSON you provided the relevant JSONPath query would be something like:
$.controlled-term.*.term-id.id
If you need to extract particular ID which is related to some other attribute value - you will have to provide the full JSON response and specify the data relationships.
I would also recommend considering switching to JSON JMESPath Extractor mainly because it has official specification (JSONPath implementations are lacking it so query which works for one implementation may fail for another). Moreover JMESPath language is more powerful and provides a lot of functions and operators which can make your life easier. More information: The JMeter JSON JMESPath Extractor and Assertion: A Guide

Use result from jdbc request for the next request

I am using JDBC to query on azure sql in JMeter. I was able to successfully get the response. see below
otp
100940
In the Result variable name the value is OTP
My next step in Http request POST method, see below
{
"id": ${requestId},
"otp": "${OTP}",
"requestId": "123456"
}
as you can see otp is parameterized.
But in actual request see below;
POST data:
{
"id": 506,
"otp": "[{otp=100940}]",
"requestId": "123456"
}
how can I concatenate so that I only get the actual otp value without the [{otp=}]
You can add Regular Expression Extractor to extract number from OTP variable
Choose Apply To: JMeter Variable and write OTP and use regular expression as:
otp=(\d+)
And use Template $1$ and Match No. 1
JMeter Variable Name to use - extraction is to be applied to the contents of the named variable
If your response is this otp 100940, use below Regular Expression to extract it:
Now, you can use anywhere OTP value using ${OTP} variable
{
"id": ${requestId},
"otp": "${OTP}",
"requestId": "123456"
}

update a get request to elastic search in nifi

I'm trying to hit a get request on my elastic search index using JSONelastisearchprocessor in NIFI.
Now, for each flow file i have some incoming attributes, based on that i need to generate different get request and store the response somewhere.
The list of processors i'm using is as below:
Getfile (to read JSON file)
Evaluate JSON path (To extract the attributes which i want to use with every get request, PROC_INST_ID_ in this case )
JSON queryelastic search (to hit the request with the below )
PUTfile to store the response
Request body
{
"query": {
"nested": {
"path": "los",
"query": {
"bool": {
"must": [
{ "match": { "los.${proc_ins_id}":"784525" }},
{ "match": { "los._source.cibilPermission.VALUE_":"1" }}
]
}
}
}
}
}
I can't see the request being genrated and not getting any response instead i'm only getting the value of proc_ins_id as reponse in putfile. Can someone suggest some appropriate way to do this?
Attaching relevant screenshots as well for reference.
I'm assuming you are providing the request body in the Query property of JsonQueryElasticSearch. In that case, you should set the Destination property to flowfile-attribute in EvaluateJsonPath because if it is set to flowfile-content and the Query property is configured with an actual query, JsonQueryElasticSearch won't even read the content of the flowfile.
And also connect hits and original to two different processors because if you connect them to the same processor you would get the original flowfile which was updated at EvaluateJsonPath at the directory configured in PutFile. In general, people would auto-terminate the original relationships unless there is a need to have it. You may also need to have the aggregations relationship configured as well because the aggregation results are sent to that relationship.

How to get Number of rows in Jmeter using Json Path Extractor

My Response is:
{
rows{
["2","xxx","yyyy"],
["3","xxx","yyyy"],
["4","xxx","yyyy"],
}
}
I am using $.rows to get all the rows. as well I am giving $.rows[0].[1] to get the value from 1st row and 1st value..
I am trying to get the total number of rows using $.rows.size() or length. It is not following exception. How to get the number of rows?
Exception: Options AS_PATH_LIST and ALWAYS_RETURN_LIST are not allowed
when using path functions!
Given the following JSON:
{
"name":"John",
"age":30,
"cars": [
{ "name":"Ford", "models":[ "Fiesta", "Focus", "Mustang" ] },
{ "name":"BMW", "models":[ "320", "X3", "X5" ] },
{ "name":"Fiat", "models":[ "500", "Panda" ] }
]
}
If I add JSON Path Extractor as a child of the sample which returns the above JSON and configure it like:
Reference Name: arraySize
JSONPath Expression: $..cars.length()
I am able to see the following variables in the View Results Tree listener:
arraySize=[3]
arraySize_1=3
arraySize_matchNr=1
Which seems to be something you're looking for.
You can install JSON Path Extractor along with JSON Path Assertion using JMeter Plugins Manager

Resources