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

Remove user_classes_count from heartbeat payload #1825

Merged
merged 3 commits into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,9 +907,6 @@ def client_listener(self):
logger.info(
"Worker %s self-healed with heartbeat, setting state to %s." % (str(c.id), client_state)
)
user_classes_count = msg.data.get("user_classes_count")
if user_classes_count:
c.user_classes_count = user_classes_count
if self._users_dispatcher is not None:
self._users_dispatcher.add_worker(worker_node=c)
if not self._users_dispatcher.dispatch_in_progress and self.state == STATE_RUNNING:
Expand Down Expand Up @@ -1096,7 +1093,6 @@ def heartbeat(self):
{
"state": self.worker_state,
"current_cpu_usage": self.current_cpu_usage,
"user_classes_count": self.user_classes_count,
},
self.client_id,
)
Expand Down
28 changes: 28 additions & 0 deletions locust/test/test_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -2509,6 +2509,34 @@ def my_task(self):

worker.quit()

def test_worker_heartbeat_messages_sent_to_master(self):
"""
Validate content of the heartbeat payload sent to the master.
"""

class MyUser(User):
wait_time = constant(1)

@task
def my_task(self):
pass

with mock.patch("locust.rpc.rpc.Client", mocked_rpc()) as client:
environment = Environment()
worker = self.get_runner(environment=environment, user_classes=[MyUser])

t0 = time.perf_counter()
while len([m for m in client.outbox if m.type == "heartbeat"]) == 0:
self.assertLessEqual(time.perf_counter() - t0, 3)
sleep(0.1)

message = next((m for m in reversed(client.outbox) if m.type == "heartbeat"))
self.assertEqual(len(message.data), 2)
self.assertIn("state", message.data)
self.assertIn("current_cpu_usage", message.data)

worker.quit()

def test_change_user_count_during_spawning(self):
class MyUser(User):
wait_time = constant(1)
Expand Down