I'm looking into Jmeter to load test a webapp.
What is done in the real app when a user clicks a button is :
1. an http request is sent to a server and the response contains a list of ids.
2. another request which is formulated by the list of ids is sent to server.
I'm interested in the overall performance of both steps.
for example:
send request to http://server.com/getsomething
I get a json looks like:
{"ids":[11,22,33,44,55,66]}
I take the ids and build another request like http://server.com/getSomethingElse?
ids=11,22,33,44,55,66
How can I simulate a test like this in jmeter?
You will have to do something of following sort.
Thread group
HTTP Sampler 1 (Send request to http://server.com/getsomething)
(one ore more) Regular Expression extractor post processor (Extract IDs).
HTTP Sampler 2 (2nd request http://server.com/getsomethingElse?IDs)
Tree view listener (To see whats going on)
You may find following beginners jmeter screen cast helpful.
http://my.kpoint.com/kapsule/gcc-e1bad3ad-61cf-4620-9733-e44a74af8a3e/t/jmeter-tutorial-regex-extractor-basics
Related
For mocking currently we are recording SOAP request and response on file system with specific folder structure such as
Request folder
test1_request.xml
test2_request.xml
test3_request.xml
Response folder
test1_response.xml
test2_response.xml
test2_response.xml
When we run our test suite first we scan through these directory and store file content in a hashmap e.g.
Map.put(request, response)
Once all file contents are stored in map we start executing our test cases. In this process we construct the soap Request and pass it to our controller which in turn call this map and find a corresponding response for the request.
Now problem is over a period of time we have accumulated thousands of test cases and req/res which is slowing down the overall test execution process. For your information we have integrated this into our build process so everytime build is triggered we execute all our unit tests.
Any design recommendation to improve it?
I was thinking index these req/res files using solr or lucene but not sure if they provide any map machenism where in I pass soap request and get the matching response.
In case an incoming request must be completly equal to the cached request you can create a hash for the cached request and name the response files accordingly.
In your controller you can then create a hash for the request and you will directly find the response just opening the correct file.
Alternativly you can create a csv/properties file with "request hash" to "response filename" and just load this file. Should be much faster then always loading all requests and responses. This is more or less a simple index, lucene/solr should be really too much for just this use-case.
i'm trying to implement a test plan using JMeter.
I want to do the following scenario:
in the same thread i have 2 HTTP Request
HTTP Request login
HTTP Request getStudentsName
the thing is HTTP Request getStudentsName can't be done unless i run the login first , so lets say i want to do the login for 1 user and then getStudentsName for 50 users.
if i put the login and getStudentsName in 2 different threads login give a success but the getStudentsName failed.
My question is can i implement this example in the same thread?or any other help?
Thanks.
To run login only once use Once Only Controller as its parent by right click, Insert Parent on the UI.
The Once Only Logic Controller tells JMeter to process the controller(s) inside it only once per Thread, and pass over any requests under it during further iterations through the test plan.
You can use in the same thread group, Config Elements like HTTP Authorization Manager or HTTP Header Manager depending on what exactly the login implies.
I have WCA 3.5.0 server and I need to get documents from the site, using web crawler.
The problem is in the fact that I have to send a POST request to the site to get some data (initialy my site consists only of a form with some fields and submit button to send the request to the server). So, my POST request body should be something like that:
{"DateFrom":"2000-01-01T00:00:00","DateTo":"2030-01-01T23:59:59","Bundles":[{"Name":"the test name that i passed","Type":-1}],"Company":[],"Transaction":[],"Text":""}
I was thinking about making a a prefetch plugin for a web crawler.
But from the documentation I've found it looks like it is hardly possible:
"The first element ([0]) in the argument array that is passed to your
plug-in is an object of type PrefetchPluginArg1, which is an interface
that extends the interface PrefetchPluginArg. This is the only
argument and the only argument type that is passed to the prefetch
plug-in."
PrefetchPluginArg1 class has only getHTTPHeader(), setHTTPHeader(), getURL(), setURL(), doFetch(), setFetch(),
where:
The getHTTPHeader method returns a String that contains the all of
the content of the HTTP request header that the crawler sends so that
the crawler can download the document.
The getURL method returns the URL (in String form) of a document that
the crawler downloads. You can use this URL to decide if the document
requires additional information in the request header, such as a
cookie.
And it looks like there is no way to change request body.
So, is it realy possible to control POST request body, but not only header, and if it is so, can you please, share some information about the ways of solving this task?
I am working on a Ticket Reservation application. I am required to build a web-service which takes in request for cancellation, checks with a downstream system (via SOAP), whether it can be cancelled, and returns the appropriate response to the calling system after updating my tables.
I have to build a bunch of similar web-services for cancellation, rescheduling, et for which I'm planning to use RESTful web-services
This I'm planning to achieve using the POST method of the REST API, using JAX-RS. I could see that all the web-services I'm going to build suit the POST verb, and the other HTTP methods (GET, POST and DELETE) doesn't seem like they need to be used here. In that case what is the actual use case of these HTTP methods in REST? Am I right in using only POST?
Your REST resource is the ticket. Use GETs to read the ticket, PUT to modify the ticket state, and DELETE to do a logical delete (cancellation).
For any other operation, use the wildcard operation POST.
Have a look at this blog post Brief Introduction to REST, where the author goes through the core REST principles.
For the purpose of a cancellation, I would actually use the DELETE method. In the case of a successful cancellation, return a 200 with either response body confirming success or a response body containing the details of the reservation. Or a 204 if you don't want to return a body.
If it can't be canceled, you have your choice from the 400 series of errors (e.g. 404 if there is no such reservation, 403 if the request is forbidden, etc.) or the 500 series if there is a bug or malfunction.
You will certainly use the other HTTP verbs for all the other reservation actions--making a reservation, changing it, etc.
Consider your Ticket Reservations as your application resources.
Clients to your application would:
submit GETrequest to retrieve a representation (XML, JSON or anything else) one or many ticket reservations (given the URL they use, eg: /tickets to retrieve all of them - or all they are allowed to see, /tickets/1to retrieve a representation of the Ticket Reservation whose id is 1, tickets/?start=0&size=10 for paginated content, etc.)
submit POST requests on /ticketsto create a new reservation (and the response would provide the client with a location giving the location of the created reservation)
submit a PUT request to /tickets/1 (with a representation of the new reservation in the request body) to update the reservation identified by 1
submit a DELETE request to /tickets/1 to delete the reservation identified by 1
The main idea behind the use of such verbs is that the URLs should identify resources (and not actions), and the HTTP verb would be the action.
If you use everything with POST, you'll be more or less doing SOAP.
This article will give you more information on hat I tried to hihlight above: http://martinfowler.com/articles/richardsonMaturityModel.html
There's quite a lot to say about designing RESTful applications. You really should read one or more of these books: "Restful Web Services" - http://amzn.com/0596529260, "RESTful Web APIs" - http://amzn.com/B00F5BS966, "REST in Practice: Hypermedia and Systems Architecture" - http://amzn.com/B0046RERXY or "RESTful Web Services Cookbook" - http://amzn.com/B0043D2ESQ.
Get a cup of coffee and enjoy some reading :-)
We are building small test simulators that need to respond to restful requests injected into a platform based on content we inject into the message:
Example: GET http://server/example-app/users
Content-Headers and/or query params = some value of pass with 200
Server respond with 200 and content
Example: GET http://server/example-app/users
Content-Headers and/or query params = some value of fail with 400
Server respond with 400 and error
I am looking to see if anyone knows of an open source tool that would be of usefulness to inspect / parse the http request and figure out response based on the look-up criteria. I'm sure I could write some parsers easily, but just interested if the community has used or knows of something that is available to do the parsing and response mappings.
It's possible that the OWASP Zed Attack Proxy covers your needs.
Fiddler is an excellent proxy to inspect code and perform filtering: http://fiddler2.com/