-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run time relative to start when using LoadTestShape #1581
Run time relative to start when using LoadTestShape #1581
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1581 +/- ##
==========================================
+ Coverage 81.61% 81.72% +0.11%
==========================================
Files 28 28
Lines 2583 2594 +11
Branches 393 395 +2
==========================================
+ Hits 2108 2120 +12
+ Misses 379 377 -2
- Partials 96 97 +1
Continue to review full report at Codecov.
|
@@ -7,7 +7,8 @@ class LoadTestShape(object): | |||
during a load test. | |||
""" | |||
|
|||
start_time = time.monotonic() | |||
def __init__(self): | |||
self.start_time = time.monotonic() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is ever called? Because the class is never instantiated, it's just declared eg, so __init__
is never run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it instantiated here:
Line 93 in 08d5173
shape_class = shape_classes[0]() |
shape_class
variable name a bit of a misnomer...)
(but maybe that is a mistake)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, you are right. I wrote that, I should know!
@@ -193,10 +193,9 @@ def main(): | |||
environment = create_environment(user_classes, options, events=locust.events, shape_class=shape_class) | |||
|
|||
if shape_class and (options.num_users or options.spawn_rate or options.step_load): | |||
logger.error( | |||
"The specified locustfile contains a shape class but a conflicting argument was specified: users, spawn-rate or step-load" | |||
logger.warning( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like it 👍
locust/runners.py
Outdated
@@ -352,6 +352,7 @@ def start_shape(self): | |||
self.update_state(STATE_INIT) | |||
self.shape_greenlet = self.greenlet.spawn(self.shape_worker) | |||
self.shape_greenlet.link_exception(greenlet_exception_handler) | |||
self.environment.shape_class.start_time = monotonic() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you not just call self.environment.shape_class.reset_time()
here and that would be enough?
nice! |
Adresses #1557
The start time of a test with a shape should now be reset every time a new test is being run. Not from the time of locust init.