Benchmark Elasticsearch using Apache JMeter - csv

I am currently using the Apache JMeter tool for benchmarking Elasticsearch.
I am using Elasticsearch's BULK API for posting documents into my index and to measure the result.
Doing this manually with the HTTP Request and with the Body Data is working fine. However, I would like to that automatically. I saw that I can use the CSV Data Set Config Config Element where I can put the body data of the HTTP Request in a CSV file.
Basically, the BULK API requires to write the elements one below the other:
{"index":{"_id":"1"}}
{"name": "John Doe" }
{"index":{"_id":"2"}}
{"name": "Jane Doe" }
Finally, one request should have 1000 of index and name pairs. Above you see two. So the question is, how would you configure the CSV Data Set Config and the HTTP Request so that you have only one POST Request with 1000x index and name pairs?
Thanks.

Given your CSV payload looks like:
1, John Doe
2, Jane Doe
3, Someone Else
Configure your CSV Data Set config as follows:
And the relevant HTTP Request like:
On each iteration and/or thread next value will be read and variables in the request will be substituted with the values from CSV
Depending on what you're trying to achieve your CSV Data Set configuration might be different, see Using CSV DATA SET CONFIG guide

Related

For jmeter post request, how can I generate input json from csv file?

I am trying to make a post rest call to my service. My sample input json file is,
{
"$id": "1",
"description": "sfdasd"
}
I have one csv file which contain a bunch of id and description, So is there a option where I can convert csv file to json objects and pass them to post call?
Assuming your CSV file is called test.csv, located in JMeter's "bin" folder and looks like:
Add CSV Data Set Config to your Test Plan and configure it as follows:
You can inline the defined JMeter Variables directly into your request body like:
{
"$id": "${id}",
"description": "${description}"
}
So when you run the test the variables placeholders will automatically be substituted with the values from the CSV file in the HTTP Request sampler:
See Using CSV DATA SET CONFIG article for more information on JMeter tests parameterization using CSV files.
Json is just text. Send as is with the variable id taken from csv:
{ "${id}": "1", "description": "sfdasd" }
CSV data can be converted to JSON via a POJO using Jackson. If a POJO is not already defined or required, you can always use the Java Collection classes to store parsed data and later convert it to JSON. http://www.novixys.com/blog/convert-csv-json-java/ is a good reference on how to convert csv to java.
You can check the following links too.
1. directly convert CSV file to JSON file using the Jackson library
2. Converting an CSV file to a JSON object in Java

How to update json field in Firebase DB with JMeter HTTP Request

I'm working with JMeter to make some HTTP Requests to my Firebase Database. I am able to create json data with a regular request, as well as with a CSV file. I'm wondering if it's possible to update, or add to, a json object.
My json data looks something like what is below. Let's say I wanted to add a boolean node called "sold", to which I could make equal to true or false. Could I create it within that json object? If so, could I also make it so that only fields with a specific "name" get updated?
{
"Price": "5.00",
"name": "buyer#gmail.com",
"seller_name": "seller#gmail.com",
"time": 1496893589683,
}
Looking into Updating Data with PATCH chapter of Saving Data article you can update a single field using HTTP PATCH Method.
JMeter supports HTTP PATCH method since version 2.8 so you should be in a position to use it as well in your test.

JSON logfile into Solr via Apache nifi

I'm tring to read a json log file and insert into solr collection using apache nifi.logfile is in following format(one json object perline)
{"#timestamp": "2017-02-18T02:16:50.496+04:00","message": "hello"}
{"#timestamp": "2017-02-18T02:16:50.496+04:00","message": "hello"}
{ "#timestamp": "2017-02-18T02:16:50.496+04:00","message": "hello"}
I was able to load the file and split by lines using different processes. How can i proceed further ?
You can use the PutSolrContentStream processor to write content to Solr from Apache NiFi. If each flowfile contains a single JSON record (and you should ensure you are splitting the JSON correctly even if it covers multiple lines, so examine SplitJSON vs. SplitText), each will be written to Solr as a different document. You can also use MergeContent to write in batches and be more efficient.
Bryan Bende wrote a good article on the Apache site on how to use this processor.

How do I send file in a PUT resquest using Postman

I using postman to test my api, and I need to send a PUT request that has a json object and some files. Im sending raw data to test this but I cant seem to figure out how to add a file in there.
PUT request
raw data example:
{
"email": "someone#something.com",
"info": "new account",
"file1" : (some file should be here),
"file2": (some file should be here)
}
You are not supposed to send files AND data in a PUT request, either the body of the request IS a file content, either you use POST to have multiple files of a file with other data.
I honestly can't explain more as I am stucked with the same kind of problem :-)

How do i get JSON data from a couchDB database and parse it in Xcode?

For Example,
I have a document in my CouchDB database that holds two fields
"password" and "username".
This is the URL for my document:http://127.0.0.1:5984/_utils/document.html?sgram/fdcfc14940fbaa0d86674046ce005107
I want to retrieve the value of these fields from that specific document in CouchDB and parse it in Xcode.
I tried using http-get but it just returns the entire page source.
You want to make a request to this endpoint
http://127.0.0.1:5984/sgram/fdcfc14940fbaa0d86674046ce005107
For a json response from couchdb just don't include _utils/document.html in between. If you do it will give you back the futon html page.