Conversation
Codecov Report
@@ Coverage Diff @@
## master #1118 +/- ##
==========================================
+ Coverage 75.46% 75.85% +0.39%
==========================================
Files 18 20 +2
Lines 1818 1864 +46
Branches 276 286 +10
==========================================
+ Hits 1372 1414 +42
- Misses 382 384 +2
- Partials 64 66 +2
Continue to review full report at Codecov.
|
|
Nice! Personally I favor pacing the total throughput for all running locusts, instead of individually (like I do in the TaskSetRPS class at https://github.com/SvenskaSpel/locust-plugins/blob/master/locust_plugins/tasksets.py), but maybe we could support both? While we are on the subject: I think we should change the default wait times to zero. A lot of new users get confused and immediately ask "Why is my test so slow, is Locust broken?". This would be a change impacting some old tests, but hopefully not many people will be relying on the default wait times... |
|
Tbh, I think we should only have one mechanism for setting wait times. I'm +1 for at least deprecating (log a warning) if someone is using min_wait / max_wait. |
I can see that there might be use-cases for it, but I don't think it fits very well with the idea of defining User behaviour and then simulating those users (if the wait time of a user is dependent on the number of - and actions of - other users). This PR shouldn't break
In this PR I've changed so that a
Yep, that's the goal. But I do think that we should aim for backwards compatibility with deprecation warnings (for awhile) if possible. |
|
I've now also fixed backwards compatibility for I've also updated all the tests and added som new tests for the old API. This PR should actually be mergeable pretty soon. |
Add deprecation warnings for usage of min_wait, max_wait, or wait_function. Updated tests to use new wait API. Added tests that tests the old wait API.
… warnings.simplefilter(“always”) from tests (should hopefully fix the failing Python 3.7 tests on Travic CI)
|
Sorry if this is coming too late, but an alternative api could be to try using python primitives instead, that way you could skip importing any extra functions: # Instead of constant(1) interpret any numeric type as constant
wait_time = 1
# Instead of between(1, 10) interpret tuples as between
wait_time = (1, 10)
# Instead of constant_pacing(5) interpret a function taking first positional arg as time spent on last request
wait_time = lambda t: 5 - tEdit: |
I think the proposed API is more clear, and less "magical", and it also allow users to define their own wait_time functions (that have access to the Locust instance). The third of your examples feels very unintuitive to me. |
|
We could possibly change so that just specifying a number as |
|
Shouldnt the wait functions be in their own package? Maybe, also maybe "between" as a distribution description is a little vague? It could be "uniform" instead... |
|
I still think we could use zero as the default time (it is the default in every other load testing tool I've used :) The main reason I think this is important is to lower the threshold for people just getting started with locust. |
I agree that
This PR currently raises as |
Do you mean a totally separate python package? I think it make sense to include them (at least They are located in a separate module ( |
Yea, I meant separate module/namespace, not package, sorry. Sure, another import is not so nice, but finding the available wait_time functions would be easier if they were in a separate namespace. the main locust namespace is kind of polluted as is. |
"between" is fine in isolation, but looks weird next to "constant" and "constant_pacing". I guess it is a matter of taste. In my experience having zero wait times is not rare or strange. |
It's still possible to import the wait_time functions from
I don't feel strongly about making Does anyone else want to chime in? |
|
Regarding the That being said, I guess defaulting to zero seems a tad more natural. As for the importing from what namespace, I'd say leave it as is now, for convenience :) |
|
Does this remove the need for #1005 ? |
Yes, it does. |
This is a proposal for changing the API for how the
LocustandTaskSetwait time is specified.Here's an example of the current API:
This would be the equivalent example with the proposed API:
I've also created two other wait_time functions besides
between:constant- Always wait the specified (constant) timeconstant_pacing- Try to sleep the amount of time required to make the time between task executions constant (so if a task takes 2 seconds to execute, the wait time will be 2 seconds lower). This is a requested feature in Allow a fixed RPS rate #646.Some things to note
min_waitandmax_waitstill works in this PR (though currently notwait_functionbut that could be fixed), so we could add deprecation warnings and keep that functionality for another version or two.time.sleepexpects, and I think it's more common that the wait time is multiple seconds rather than fractions of a second, so I think that change makes sense to do if we're changing the API.min_waitandmax_wait.The reason I started working on this, was because I was working on fixing the bug in #891 and realised that the fix would result in a somewhat messy solution (master...fix-891) that would involve taking a bound method on the Locust instance, and re-binding it on the TaskSet instance. So besides giving us a (IMO) nicer API, it would also help avoid that messy solution :).
What do you think? Is there something I haven't thought of that would break by this?