I am working on JMeter 3.3. I will have n users and the login should be done only once but the other pages are to be executed multiple times. I found the solution as using 2 different thread groups, but its not working as I have cookies from my login.
I saw a similar usecase in: Sharing cookie values between thread groups in JMeter but none of the solutions worked. How to make this happen?
Could SetUp Thread Group be an answer? (http://jmeter.apache.org/usermanual/component_reference.html#setUp_Thread_Group) - I mean the login (and extracting cookies to a variable) would be done in that setUp group, then your other tests in 'normal' Thread Groups - which would read that globally available variable with your cookie.
If you need to login user only one time per iteration,than use Once only controller.
To share cookies between thread groups you can use Inter-thread communication plugin
Normally if you want to perform login only once you can use If Controller with the condition of ${__groovy(vars.getIteration() == 1,)} where:
__groovy() - a JMeter Function allowing execution of arbitrary Groovy code
vars - is a shorthand to JMeterVariables class instance providing read/write access to JMeter Variables. vars.getIteration() method returns current Thread Group iteration so the sampler(s) you put under the If Controller will be executed only once for each virtual user.
I got the solution from https://stackoverflow.com/a/43379806/8305811 but by turning on the CookieManager.save.cookies to true and setting up the cookie manager in the test plan level.
Related
I have created one simple JMeter script in V5.3. There I am using HTTP cookie and cache manager in test plan level and I am selecting both clear cookie/cache on each iteration. Under that I have kept one thread group with a HTTP sampler inside it. In the thread group level I have selected "Same User On Each Iteration" and executed it for 1 thread and 3 loop counts.
Will it behave as the same user in all the 3 iterations or treat them as different users as we have already selected clear cookie and cache on each iteration from test plan level?
Why would you do mutually exclusive things?
If you want cookies and cache to remain between Thread Group iterations - tick Same user on each iteration box
And vice versa, if you want to clear cookies and cache - don't tick this box
Going forward:
If you tick Same User On Each Iteration box on Thread Group level and Clear cache each iteration box on HTTP Cache Manager level the HTTP Cache Manager will override the thread group settings
More information:
HTTP Cache Manager
HTTP Cookie Manager
Introducing JMeter 5.2!
I have a threadgroup with 100 thread (users), and loop count of 10.
I have a cookie manger with default setting.
The users are anonymous (not logged in), but I want to track the number of users hitting the site in application insights, as it will generate new .net session tokens.
When I run the test, i would expect cookies to be local to each threads loop iteration.
So I would expect cookies to be "cleared" on each thread 10 times, and so I would expect to generate 1,000 .net session cookies on my application.
however, I don't, I see 1.
In the cookie manager, there are two options:
Clear cookies each iteration
Use thread group configuration to control cookie clearing.
Both are unchecked.
But this makes no sense - I want the cookies to be cleared on each iteration for each user.
Should I check one or both of these? do I need to set anything on the thread group?
In the thread group, I have "user same user on each iteration" unchecked - each iteration should be considered a new user.
Also, does it mater where the cookie manger goes? I have always put it at the top, above the threadgroup, but perhaps it is supposed to go under the thread group?
Ideas?
100 * 10 gives 1000, not 10000
There are 2 ways on how you can clear the cookies each iteration:
Tick this box:
Or tick the other and untick Same user on each iteration on Thread Group level
I would go for the latter option as this allows controlling i.e. HTTP Cache Manager and HTTP Authorization Manager as well
HTTP Cookie Manager considers only Thread Group iteration as iteration, other loop sources like Loop Controller or While Controller are not taken into consideration
You might consider placing your HTTP Cookie Manager(s) in order to limit its(their) scope according to your test scenario
You can add to first request JSR223 PreProcessor with code that will clear cookies on each start of iteration
sampler.getCookieManager().clear()
I did some experimentation. I got the right results after doing this:
put the cookie manager under the threadgroup. Before I had it above.
set "Use thread group config to control cookie clearing" in cookie manger
In threadgroup, make sure "use same user on each iteration" was unchecked.
Now for each thread, and each iteration, i see new session cookies, and these are preserved just for that thread and iteration.
I am having issues with debugging multiple requests going through same piece of code, so there is a need of context information. And using this stackoverflow's answer
Django logging with user/ip
Logging each request with a unique request_id, able to see each request flow easily. But the issue is when there is group_send inside django rest framework views using async_to_sync.
Thread local storage won't work in this case due to the code running on a different thread, is there any possible way of propagating thread local storage onto the subthread?
Also I found in the docs about async_to_sync that "Threadlocals and contextvars values are preserved across the boundary in both directions.". Does this mean that the thread local variables are shared in some way?, If it's so, why isn't the logger not able to pick up this thread local variable?
Anyway to properly log django views, channels with all request information without having to give extra on every log message?
Thank you!
Link for that async_to_sync line: https://docs.djangoproject.com/en/3.0/topics/async/
I have a test where users will logs in and enter search keyword in search field and will get the results. Finally logs out.
Now I want to test concurrency using Jmeter. So this is what I came up with.
Test plan
Thread group
+ Login request
+ Synchronizing Controller
+ Search string
+ Synchronizing Controller
+ Logout
I have added 10 in number of threads. I have added 5 in Synchronizing Controller. So when I run the test I will get the concurrency of 5 users? Rest 5 users will be simultaneous users?
Also I have depended request when login page loads. So to achieve concurrency on login, I have added all the request in transaction controller and added Synchronizing Controller as child to transaction controller. Please let me know if I am doing it right.
Also please let me know if there is another way to achieve concurrency for specific action (ex: 5 users hitting login button at same time).
First off, you should try to distinguish between 'concurrent' and 'simultaneous'. They are normally very similar terms but in load testing they have different meanings. Simultaneous means two or more requests at the same time. Concurrent is two or more threads (scripts) running in parallel.
So, what you are talking about is trying to configure JMeter to simulate multiple simultaneous requests. But actually, there's a much, much better approach than this. Instead of focusing on trying to hit the same request at the same time, which is fiddly in JMeter, you should setup your test to be a realistic representation of the sort of load you want your application to support. If you do that well, using random wait times, throughput controllers and a realistic number of threads, then you will automatically be testing concurrency and at the same time running genuine, valid and useful performance tests too.
So, basically, drop the synchronising timer, use a constant throughput timer instead, configure wait times and then calculate the correct number of threads to generate the desired load.
The added bonus to this approach is you will be much less likely to raise false negatives. For example, if you hit your server with 5 simultaneous login requests then you might find that this call is single-threaded and the response times increase. But maybe this doesn't matter, maybe the chances of two login calls at the same time are so small that it is not worth spending time changing the code. This is a very, very important concept in load testing - perhaps the most important - you must have realistic objectives, without these you could be running tests, finding false bugs and generally wasting time forever.
I'm creating a web app for handling various surveys. An admin can create his own survey and ask users to fill it up. Users are defined by target groups assigned to the survey (so only user in survey's target group can fill the survey).
One of methods to define a target group is a "Token target group". An admin can decide to generate e.g. 25 tokens. After that, the survey can be accessed by anyone who uses a special link (containing the token of course).
So now to the main question:
Every token might have an e-mail address associated with itself. How can I safely send e-mails containing the access link for the survey? I might need to send a few thousand e-mails (max. 10 000 I believe). This is an extreme example and such huge mailings would be needed only occasionally.
But I also would like to be able to keep track of the e-mail message status (was it send or was there any error?). I would also like to make sure that the SMTP server doesn't block this mailing. It would also be nice if the application remained responsive :) (The task should run in background).
What is the best way to handle that problem?
As far as I'm concerned, the standard Django mailing feature won't be much help here. People report that setting up a connection and looping through messages calling send() on them takes forever. It wouldn't run "in background", so I believe that this could have negative impact on the application responsiveness, right?
I read about django-mailer, but as far as I understood the docs - it doesn't allow to keep track of the message status. Or does it?
What are my other options?
Not sure about the rest, but regardless for backgrounding the task (no matter how you eventually do it) you'll want to look for Celery
The key here is to reuse connection and to not open it again for each email. Here is a documentation on the subject.