Skip to content
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

Merged
merged 3 commits into from
Oct 1, 2020

Conversation

DennisKrone
Copy link
Collaborator

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.

@codecov
Copy link

codecov bot commented Sep 30, 2020

Codecov Report

Merging #1581 into master will increase coverage by 0.11%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
locust/main.py 20.17% <0.00%> (+0.08%) ⬆️
locust/env.py 96.72% <100.00%> (ø)
locust/runners.py 82.13% <100.00%> (+0.58%) ⬆️
locust/shape.py 90.00% <100.00%> (+1.11%) ⬆️
locust/clients.py 90.19% <0.00%> (-4.91%) ⬇️
locust/stats.py 89.87% <0.00%> (-0.21%) ⬇️
locust/event.py 87.80% <0.00%> (+0.30%) ⬆️
locust/user/task.py 95.18% <0.00%> (+0.53%) ⬆️
locust/user/sequential_taskset.py 86.20% <0.00%> (+1.02%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8ef212d...579075b. Read the comment docs.

@@ -7,7 +7,8 @@ class LoadTestShape(object):
during a load test.
"""

start_time = time.monotonic()
def __init__(self):
self.start_time = time.monotonic()
Copy link
Contributor

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.

Copy link
Collaborator

@cyberw cyberw Sep 30, 2020

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:

shape_class = shape_classes[0]()
(making the shape_class variable name a bit of a misnomer...)

(but maybe that is a mistake)

Copy link
Contributor

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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like it 👍

@@ -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()
Copy link
Contributor

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?

@cyberw cyberw merged commit 0cd9367 into locustio:master Oct 1, 2020
@cyberw
Copy link
Collaborator

cyberw commented Oct 1, 2020

nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants