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

Worker quitting then stopping via web UI bug fix #1324

Merged
merged 21 commits into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b80d945
Made it so stop only performs if state isn't already stopping/stopped…
Trouv Apr 13, 2020
6f4473d
Added second fix in web.py
Trouv Apr 13, 2020
a918d81
made it so test_stop event is fired when all workers quit
Trouv Apr 13, 2020
00b4da8
Added log message
Trouv Apr 13, 2020
1ca93b6
Fixed import merge conflict in web.py
Trouv Apr 14, 2020
358ffa5
Removed the alternative api message
Trouv Apr 14, 2020
26c0b01
Moved STATE_STOPPED check to the heartbeat method, as well as checkin…
Trouv Apr 14, 2020
9a414ba
Added info arg to stop() to log messages on stop only when it actuall…
Trouv Apr 14, 2020
72a7b87
Added heartbeat mocking for broken test case
Trouv Apr 14, 2020
6b2c81a
Alternative mock heatbeat solution, less things to pass around
Trouv Apr 14, 2020
2ab666f
Merge branch 'master' of github.com:Trouv/locust into worker-quit-ui-fix
Trouv Apr 15, 2020
1021d8e
Made it so UI updates to stopped form when workers quit
Trouv Apr 15, 2020
12f32e7
Added .stopping wherever .stopped is in css
Trouv Apr 15, 2020
4b575b9
Undid some no-longer-necessary changes
Trouv Apr 15, 2020
6b511f4
Removed newline in locust.js
Trouv Apr 15, 2020
82e8b66
Added check_stopped function and made new stops specific to reason. R…
Trouv Apr 15, 2020
71f98b2
Merge branch 'master' of github.com:Trouv/locust into worker-quit-ui-fix
Trouv Apr 16, 2020
7b40b18
Moved stop check to inside if, moved jquery stop set to inside button…
Trouv Apr 16, 2020
fc2fbd4
Added tests
Trouv Apr 16, 2020
a80d02b
Merge branch 'master' of github.com:Trouv/locust into worker-quit-ui-fix
Trouv Apr 16, 2020
59f117f
made new tests faster
Trouv Apr 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,11 @@ def start(self, locust_count, hatch_rate):
self.state = STATE_HATCHING

def stop(self):
self.state = STATE_STOPPING
for client in self.clients.all:
self.server.send_to_client(Message("stop", None, client.id))
self.environment.events.test_stop.fire(environment=self.environment)
if self.state not in [STATE_INIT, STATE_STOPPED, STATE_STOPPING]:
self.state = STATE_STOPPING
for client in self.clients.all:
self.server.send_to_client(Message("stop", None, client.id))
self.environment.events.test_stop.fire(environment=self.environment)

def quit(self):
if self.state not in [STATE_INIT, STATE_STOPPED, STATE_STOPPING]:
Expand Down Expand Up @@ -490,6 +491,8 @@ def client_listener(self):
if msg.node_id in self.clients:
del self.clients[msg.node_id]
logger.info("Client %r quit. Currently %i clients connected." % (msg.node_id, len(self.clients.ready)))
if self.worker_count == 0:
self.stop()
Trouv marked this conversation as resolved.
Show resolved Hide resolved
elif msg.type == "exception":
self.log_exception(msg.node_id, msg.data["msg"], msg.data["traceback"])

Expand Down
9 changes: 6 additions & 3 deletions locust/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from io import StringIO

from . import runners
from .runners import MasterLocustRunner
from .runners import MasterLocustRunner, STATE_STOPPING, STATE_STOPPED
from .stats import failures_csv, median_from_dict, requests_csv, sort_stats
from .util.cache import memoize
from .util.rounding import proper_round
Expand Down Expand Up @@ -125,8 +125,11 @@ def swarm():
@app.route('/stop')
@self.auth_required_if_enabled
def stop():
environment.runner.stop()
return jsonify({'success':True, 'message': 'Test stopped'})
if environment.runner.state in [STATE_STOPPING, STATE_STOPPED]:
return jsonify({'success':True, 'message': f"Test already {environment.runner.state}"})
else:
environment.runner.stop()
return jsonify({'success':True, 'message': 'Test stopped'})

@app.route("/stats/reset")
@self.auth_required_if_enabled
Expand Down