Skip to content

Commit

Permalink
Merge pull request #1830 from locustio/allow-workers-to-bypass-versio…
Browse files Browse the repository at this point in the history
…n-check

Allow workers to bypass version check by sending -1 as version
  • Loading branch information
cyberw authored Jul 29, 2021
2 parents bc70a26 + 018b9a7 commit 54d2883
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ def client_listener(self):
if not msg.data:
logger.error(f"An old (pre 2.0) worker tried to connect ({client_id}). That's not going to work.")
continue
elif msg.data != __version__:
elif msg.data != __version__ and msg.data != -1:
logger.warning(
f"A worker ({client_id}) running a different version ({msg.data}) connected, master version is {__version__}"
)
Expand Down
13 changes: 13 additions & 0 deletions locust/test/test_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,19 @@ def test_worker_connect(self):
server.mocked_send(Message("quit", None, "zeh_fake_client3"))
self.assertEqual(3, len(master.clients))

def test_worker_connect_with_special_versions(self):
with mock.patch("locust.rpc.rpc.Server", mocked_rpc()) as server:
master = self.get_runner()
server.mocked_send(Message("client_ready", None, "1.x_style_client_should_not_be_allowed"))
self.assertEqual(1, len(self.mocked_log.error))
self.assertEqual(0, len(master.clients))
server.mocked_send(Message("client_ready", "abcd", "other_version_mismatch_should_just_give_a_warning"))
self.assertEqual(1, len(self.mocked_log.warning))
self.assertEqual(1, len(master.clients))
server.mocked_send(Message("client_ready", -1, "version_check_bypass_should_not_warn"))
self.assertEqual(1, len(self.mocked_log.warning))
self.assertEqual(2, len(master.clients))

def test_worker_stats_report_median(self):
with mock.patch("locust.rpc.rpc.Server", mocked_rpc()) as server:
master = self.get_runner()
Expand Down

0 comments on commit 54d2883

Please sign in to comment.