How to test with cookied user? - jmeter

I want to test the site with 2 types of users.
First time user
Returning user
I am not sure how to test the returning user. Should I use cookie manager for this and use HTTP request twice with the same request to make the user cookied user?

It is more related to CACHE than COOKIE to define your scenario.
First Users: Download All Resources and Save Them Locally.
Returning Users: Use the Downloaded Resources instead of downloading them from the server again.
Here, Resources are referred to static web elements like images, .js, .css files which won't change much.
To implement both users, use HTTP Cache Manager. Use the default settings. Mark iterations in Thread Group -> Loop Count more than 1. Here, in first iteration, you are simulating First User. Remaining iterations are treated as Returning Users as JMeter uses Cache.
Note: If you check the option Clear cache each iteration, you are simulating all iterations as First Comers/Users as they always request/download resources from the server.

Related

Browser Cache Private S3 Resources

Stack is:
Angular
Laravel
S3
nginx
I'm using S3 to store confidential resources of my users. Bucket access is set to private which means I can access files either by creating temporary (signed, dynamic) links or by using Storage::disk('s3')->get('path/to/resource') method and returning an actual file as a response.
I'm looking for a way to cache resources in user's browser. I have tried to set cache headers to resource response directly on AWS, but since I'm creating temporary urls, they are dynamic and cache is not working in that case.
Any suggestion is highly appreciated.
EDIT: One thing that makes the whole problem even more complex is that security of resources should be intact. It means that I need a way to cache resources, but in the same time I must prevent users from copy-pasting links and using them outside of the app (sharing with others via direct links).
Temporary links in terms of security are still not an ideal solution, since they can be shared (and accessed multiple times) within the period of time they are valid for (in my case it's 30 seconds).
Caching will work as-is (based on Cache-Control, et al.) as long as the URL stays the same. So, if your application uses the same signed URL for awhile, you'll be fine.
The problem comes when you want to update an expiration date or something. This of course has different querystring parameters, and is effectively a different URL. You need a different caching key, but the browser has no concept of this by default.
If it is acceptable for your security, you can create a Service Worker which uses just the base URL (without querystring) as the cache key. Then, future requests for the same object on the bucket will be able to used the cached response, regardless of other URL parameters.
I must prevent users from copy-pasting links and using them outside of the app (sharing with others via direct links).
This part of your requirement is impossible, and unrelated to caching. Once that URL is signed, it can be used by others.
You have just add one parameter in your code.
'ResponseCacheControl' => 'no-store'
Storage::disk('s3')->getAwsTemporaryUrl(Storage::disk('s3')->getDriver()->getAdapter(), trim($mNameS3), \Carbon\Carbon::now()->addMinutes(config('app.aws_bucket_temp_url_time')), ['ResponseCacheControl' => 'no-store']);

What should be the value of "parallel download" field in HTTP sampler of Jmeter

I hit a URL through my browser and and check the Network tab of the browser, it showed me like:
DOMContentLoad: 4 seconds (Just to load DOM)
Load: 7 seconds(DOM + scripts + assets)
When I hit the same through J-Meter, it gave me a response time of ~seconds.
So, through, J-meter it's taking very long time to respond. Then, I enabled "Parallel downloads" and added a value to number field under the advanced option of HttpSampler. The response time reduced.But, still I am not sure what should be the value of that number.
Can anyone please help me out here in understanding on what factor we decide the value of the number field.
Modern browsers use ~6 parallel threads for downloading embedded resources so you should put 6 there. Adjust the value up or down to mimic browser(s) you would like to simulate.
Also don't forget to add HTTP Cache Manager as read browsers download embedded resources only once, on subsequent requests the resources (images, scripts and styles) are being returned from the browser's cache so you need to mimic this behaviour as well.
And finally make sure you are excluding external domains (3rd party banners, counters, maps, whatever) to focus solely on your application calls.
See Web Testing with JMeter: How To Properly Handle Embedded Resources in HTML Responses for more details.

Run the recorded testplan in Jmeter and verify the the entry in the Database

Im using Jmeter and do performance testing for my web application. I record my actions in jmeter and play back the same. The testplan got run but when i verify the database manually, the new row is not created. The value got added in the existing line.Please help me out of this. I am struck in this step for 2 days
Verify if your requests includes hardcoded session's data. If your app manages sessions and you just "recorded" the actions, probably you are re-using the same session's data. Assuming there is a login page -> the requests after the login would use a session, usually returned for the login action.
As comments are not enough descriptive; posting a new answer. You can do this by using regular expression extractors, because -probably- the session info comes in the response (so extract it into a variable, by parsing the response with a regex extractor)
and then use the variable in further request/s.
This is a tricky way and need lot of work... even more if the session keep changing in subsequent responses (it usually change while moving worward through the page/app workflow), if that is the case you will need to extract the data after each request.
Please reffer to the jmeter manual for more info about regex extractors.

Data correlation and concurrent users with Jmeter

This is Naresh. Seems this blog is really helpful for the beginners and all.
I have chosen Jmeter for Perf. testing web-based application and it is build with the environment - Microsoft dot net(Asp.net 3.5 with C#). Would Jmeter helps me?
I have done some sample recordings, for e.g login and search.
Scenario1 - Login
Here I have recorded for login and then parameterized with CSV config file.
And executed later.
As I do not much hand on exp, do I need to add anything to the above config to run it perfectly. For e.g. adding HTTP cookie manager or ?????
How to run the concurrent users?
Scenario 2:
Here, I have logged in - login.aspx is recorded
given a search - search.aspx is recorded
results will be displayed right below the search in a tabular format - (same)search.aspx is recorded
I want to run this for 100 simultaneous search(s). I understood how to pass the CSV file.
I am sure there is some thing needed to be done for executing this scenario.
Do I have need to do Data correlation, if yes? how to do this?
Do I need to add HTTP cookie manager or HTTP cache manager......
Please help guys, would be grateful :)
Naresh
Yes you must add the HTTP Cookie manager and HTTP cache manager

Refreshing in RestSharp for Windows Phone

I implemented RestSharp succesfully in my WP7 application, but one issue remains:
When I load resources from the server (for example a GET request on http://localhost:8080/cars), the first time the collection of (in this case) cars is succesfully returned.
When I issue the same request for the second time, I always get the same result as the first time - even when the resources have changed in the meantime. When looking at my server, the second time there is no request issued at all.
I presume there's a caching mechanism implemented in RestSharp, but I see no way to invalidate the cache results.
Are there any ways to manually invalidate the RestSharp for Windows Phone cache results? (Or ways to force the library to get the results from the server)
You can control caching of resources by setting headers on the response your server sends back. If you do not want the resource to be cached then set the cache-control header to no-cache.
It is the server's job to specify how long a resource is good for, the client should do its best to respect that information.
If you really, really want to delete entries in the cache you need to go via the WinINet API
As a quick hack to avoid caching you can append a unique value to the end of the query string. The current DateTime (including seconds and milliseconds if necessary) or a GUID are suitable.
eg.
var uri = "http://example.com/myrequest?rand=" + DateTime.Now().ToString();

Resources