I am using JMeter to do performance test a web page.
I have a scenario for uploading a file and downloading a file. I need to load test uploading file and downloading file scenarios.
Can any one help me how to achieve these using JMeter.
Thanks,
Raj
There are actually no difficulties in recording upload/download traffic with any HTTP sniffing tool and then emulate recorded requests in using JMeter.
In the simplest case you will get something like the following:
Thread Group to setup number of test users and loops;
for upload: 1 HTTP POST request with Use multipart/form-data for POST = true - to sent file as part of request;
for download: 1 HTTP GET request for download + Save Responses to a file listener attached to it - to save requested file.
This will look like the following:
Thread Group
Number of Threads = X
Loop Count = Y
. . .
UPLOAD HTTP Request
Method = POST
Use multipart/form-data for POST = true
-- Send Files with Request -- section:
File Path = ${testFile}
Parameter Name = datafile
MIME Type = ...
. . .
DOWNLOAD HTTP Request
Method = GET
Save Responses to a file
Filename Prefix = downloadTest_
Variable Name = testFile
. . .
Here you can find sample script implemented for schema given above: file-upload-download.jmx.
The following posts may also appear useful:
Testing load document functionality with JMeter
Performance testing: Upload and Download Scenarios with Apache JMeter
How to Test Image Upload Functionality With JMeter
JMeter Testing Multiple Random File Uploads
Handling File Upload in JMeter
Related
I have two thread groups in my project, and on of them has two HTTP request samplers. It's set up like the following
Thread group
Timer: Random between 1 and 5 minutes: ${__Random(60000,300000)}
HTTP request: A basic GET web service call
HTTP request: A basic GET web service call
Here's the Thread group setup.
That's it. Here's an example of the web service call setup
And here's what the "Statistics" portion of the HTML report looks like. Note the -1, -2 after the HTTP Request names. I'm trying to figure out why that's happening.
My other thread group / samplers are not displaying that way, but they're set up the same way, as far as I can tell.
In your example, HTTP requests Get Locations-0, Get Locations-1 are sub requests of Get Locations which appeared since you have selected the check box - Follow Redirects.
In case, you don't want HTTP requests Get Locations-0, Get Locations-1 to appear in your HTML report:
In the listener page(where you have saved the result file; which is the source file of HTML report) -> click on configure button -> uncheck the Save Sub Result option
You can also refer :Configure result file to customize HTML report
Turns out that some of the calls were returning a 200, others a 301, that's where they got separated out, even though the 301's didn't register as errors in the report.
I am trying to upload a file using the PUT method, which is not including the file in the request. I have followed the other example POST methods, but considering PUT does not allow multipart to be checked, that might be the issue.
I am also using:
* httpClient4
* jmeter 3.3
screenshot : https://www.evernote.com/shard/s126/sh/b4ebf947-c7e4-4e0a-9ebf-8e42a5f5d082/6813671cb2ab7419
Request data:
PUT http://myurl----here/app_path/test__16525587b4361f339ca33a9cdf0e9201d90e76dc__1676871c-71b8-488a-9750-29554a4be722
PUT data:
[no cookies]
Request Headers:
Connection: close
Content-Type: application/octet-stream
Content-Length: 0
Host: int-cloudstore-perf.svc.netspot.com.au
User-Agent: Apache-HttpClient/4.5.3 (Java/9.0.1)
Your test does't seem to be sending anything as your Put data should not be blank.
I would recommend to remove data from the Parameter Name section of the "Files Upload" tab of the HTTP Request sampler as PUT method is different and it doesn't assume submitting an HTML form and most probably your request will start working as expected (at least it will send data to the server)
Just in case check out Testing REST API File Uploads in JMeter article
Now,I have a need that post a file stream,not a local file.the process is:
client(file) ---> my server ----> third party Cloud Storage,the transfer is file stream.
I have found this article:
Ruby: How to post a file via HTTP as multipart/form-data?
require 'rest_client'
RestClient.post('http://localhost:3000/foo',
:name_of_file_param => File.new('/path/to/file'))
you can see that the name_of_file_param is a local file,not stream.
so I want to know ,if this is file stream form the client ,what should I do
You should be able to use any IO object, including a stream, as the parameter:
RestClient.post('http://localhost:3000/foo', :name_of_file_param => my_stream)
I have an app that I am trying to load test with JMeter, and I am unable to extract a value from an URL, that is generated after HTTP POST.
The app flow (simplified) goes something like this, with corresponding URLs:
Login: http://host:port/login
Go to Dashboard (HTTP GET): http://host:port/dashboard
Click "Create Content" (HTTP GET): http://host:port/$string1/$string2=/create
Enter data, click "Submit" (HTTP POST) now URL is: http://host:port/$string1/$string2=/content/$string3
$string1, $string2 & $string3 are randomly generated; $string1 & $string2 are available in the body at the dashboard URL (which are easily extracted using regex); $string3 however is returned after content is created. I need $string3 at Step 4 above to view the newly created content, and proceed with next steps in my script.
I don't have access to the internals of the app or the server it is on.
Sanity check:
Is this a chicken-egg situation?
Or am I missing something in JMeter?
Any way around this problem?
I assume after you click "submit" it's a post request that will start the create content process, then get a redirect reply from the server. (you can verify if it's a redirect reply in tree view)
Uncheck the redirect option in Jmeter and add a regex extractor element to the same request.
Then extract the redirect URL with something like Object moved to <a href="/(.+?)">here and in the next HTTP request element you can use that extracted as variable to Path like ${string3}!
I have a file in the website and i m trying to send this file to windows application using the Response.BinaryWrite (getContent)( Where getContent is the byte array having the file which I need to send) vis HTTP post method only. Also I m adding a Header and Content-Type as application/octet-stream in the Response.
Now while reading the (httpWebResponse) response in the stream at client side(windows application) all the things (header + content-type + file + some extra bytes) are getting added. so when I try to read the file in stream it cannot be loaded since the content has chnged
Is there any way to separate the file from rest contents present in the response object..
How sahll I save this file in directory
Use System.Net.WebClient.DownloadData or DownloadFile method instead.
What language / version are you using?
If you are using a reasonably up-to-date version of C# you can use the WebClient class, and its DownloadFile method