From a89ec0486a41630cae7aae483e1db44cdef36089 Mon Sep 17 00:00:00 2001 From: Jason Little Date: Sun, 27 Nov 2022 07:01:25 -0600 Subject: [PATCH 01/22] Adjust tests with legacy settings for sending federation to use modern settings. --- tests/events/test_presence_router.py | 20 ++++++++++--- tests/federation/test_federation_catch_up.py | 30 +++++++++++++++---- tests/federation/test_federation_sender.py | 15 ++++++++-- tests/handlers/test_presence.py | 5 +++- tests/handlers/test_typing.py | 10 +++++-- tests/module_api/test_api.py | 5 +++- tests/replication/_base.py | 2 +- .../tcp/streams/test_federation.py | 6 ++-- tests/replication/test_federation_ack.py | 5 ++-- .../test_federation_sender_shard.py | 23 +++++++------- tests/utils.py | 3 +- 11 files changed, 89 insertions(+), 35 deletions(-) diff --git a/tests/events/test_presence_router.py b/tests/events/test_presence_router.py index 685a9a6d52e3..52e355e1296c 100644 --- a/tests/events/test_presence_router.py +++ b/tests/events/test_presence_router.py @@ -162,7 +162,10 @@ def prepare(self, reactor, clock, homeserver): }, } }, - "send_federation": True, + # Default test case disables federation sending. Setting + # 'federation_sender_instances' to None turns it back on for the main + # process + "federation_sender_instances": None, } ) def test_receiving_all_presence_legacy(self): @@ -180,7 +183,10 @@ def test_receiving_all_presence_legacy(self): }, }, ], - "send_federation": True, + # Default test case disables federation sending. Setting + # 'federation_sender_instances' to None turns it back on for the main + # process + "federation_sender_instances": None, } ) def test_receiving_all_presence(self): @@ -290,7 +296,10 @@ def receiving_all_presence_test_body(self): }, } }, - "send_federation": True, + # Default test case disables federation sending. Setting + # 'federation_sender_instances' to None turns it back on for the main + # process + "federation_sender_instances": None, } ) def test_send_local_online_presence_to_with_module_legacy(self): @@ -310,7 +319,10 @@ def test_send_local_online_presence_to_with_module_legacy(self): }, }, ], - "send_federation": True, + # Default test case disables federation sending. Setting + # 'federation_sender_instances' to None turns it back on for the main + # process + "federation_sender_instances": None, } ) def test_send_local_online_presence_to_with_module(self): diff --git a/tests/federation/test_federation_catch_up.py b/tests/federation/test_federation_catch_up.py index 2873b4d43012..047795744e2c 100644 --- a/tests/federation/test_federation_catch_up.py +++ b/tests/federation/test_federation_catch_up.py @@ -79,7 +79,10 @@ def get_destination_room(self, room: str, destination: str = "host2") -> dict: )[0] return {"event_id": event_id, "stream_ordering": stream_ordering} - @override_config({"send_federation": True}) + # Default test case disables federation sending. Setting + # 'federation_sender_instances' to None turns it back on for the main + # process + @override_config({"federation_sender_instances": None}) def test_catch_up_destination_rooms_tracking(self): """ Tests that we populate the `destination_rooms` table as needed. @@ -105,7 +108,10 @@ def test_catch_up_destination_rooms_tracking(self): self.assertEqual(row_2["event_id"], event_id_2) self.assertEqual(row_1["stream_ordering"], row_2["stream_ordering"] - 1) - @override_config({"send_federation": True}) + # Default test case disables federation sending. Setting + # 'federation_sender_instances' to None turns it back on for the main + # process + @override_config({"federation_sender_instances": None}) def test_catch_up_last_successful_stream_ordering_tracking(self): """ Tests that we populate the `destination_rooms` table as needed. @@ -163,7 +169,10 @@ def test_catch_up_last_successful_stream_ordering_tracking(self): "Send succeeded but not marked as last_successful_stream_ordering", ) - @override_config({"send_federation": True}) # critical to federate + # Default test case disables federation sending. Setting + # 'federation_sender_instances' to None turns it back on for the main + # process + @override_config({"federation_sender_instances": None}) # critical to federate def test_catch_up_from_blank_state(self): """ Runs an overall test of federation catch-up from scratch. @@ -260,7 +269,10 @@ async def fake_send( return per_dest_queue, results_list - @override_config({"send_federation": True}) + # Default test case disables federation sending. Setting + # 'federation_sender_instances' to None turns it back on for the main + # process + @override_config({"federation_sender_instances": None}) def test_catch_up_loop(self): """ Tests the behaviour of _catch_up_transmission_loop. @@ -325,7 +337,10 @@ def test_catch_up_loop(self): event_5.internal_metadata.stream_ordering, ) - @override_config({"send_federation": True}) + # Default test case disables federation sending. Setting + # 'federation_sender_instances' to None turns it back on for the main + # process + @override_config({"federation_sender_instances": None}) def test_catch_up_on_synapse_startup(self): """ Tests the behaviour of get_catch_up_outstanding_destinations and @@ -424,7 +439,10 @@ def wake_destination_track(destination): # - all destinations are woken exactly once; they appear once in woken. self.assertCountEqual(woken, server_names[:-1]) - @override_config({"send_federation": True}) + # Default test case disables federation sending. Setting + # 'federation_sender_instances' to None turns it back on for the main + # process + @override_config({"federation_sender_instances": None}) def test_not_latest_event(self): """Test that we send the latest event in the room even if its not ours.""" diff --git a/tests/federation/test_federation_sender.py b/tests/federation/test_federation_sender.py index f1e357764ff4..5b5e906bc3c7 100644 --- a/tests/federation/test_federation_sender.py +++ b/tests/federation/test_federation_sender.py @@ -40,7 +40,10 @@ def make_homeserver(self, reactor, clock): return hs - @override_config({"send_federation": True}) + # Default test case disables federation sending. Setting + # 'federation_sender_instances' to None turns it back on for the main + # process + @override_config({"federation_sender_instances": None}) def test_send_receipts(self): mock_send_transaction = ( self.hs.get_federation_transport_client().send_transaction @@ -83,7 +86,10 @@ def test_send_receipts(self): ], ) - @override_config({"send_federation": True}) + # Default test case disables federation sending. Setting + # 'federation_sender_instances' to None turns it back on for the main + # process + @override_config({"federation_sender_instances": None}) def test_send_receipts_with_backoff(self): """Send two receipts in quick succession; the second should be flushed, but only after 20ms""" @@ -184,7 +190,10 @@ def make_homeserver(self, reactor, clock): def default_config(self): c = super().default_config() - c["send_federation"] = True + # Default test case disables federation sending. Setting + # 'federation_sender_instances' to None turns it back on for the main + # process + c["federation_sender_instances"] = None return c def prepare(self, reactor, clock, hs): diff --git a/tests/handlers/test_presence.py b/tests/handlers/test_presence.py index c5981ff9657f..dd814bfb9622 100644 --- a/tests/handlers/test_presence.py +++ b/tests/handlers/test_presence.py @@ -992,7 +992,10 @@ def make_homeserver(self, reactor, clock): def default_config(self): config = super().default_config() - config["send_federation"] = True + # Default test case disables federation sending. Setting + # 'federation_sender_instances' to None turns it back on for the main + # process + config["federation_sender_instances"]: None return config def prepare(self, reactor, clock, hs): diff --git a/tests/handlers/test_typing.py b/tests/handlers/test_typing.py index 9c821b3042b8..63f16559111d 100644 --- a/tests/handlers/test_typing.py +++ b/tests/handlers/test_typing.py @@ -200,7 +200,10 @@ def test_started_typing_local(self) -> None: ], ) - @override_config({"send_federation": True}) + # Default test case disables federation sending. Setting + # 'federation_sender_instances' to None turns it back on for the main + # process + @override_config({"federation_sender_instances": None}) def test_started_typing_remote_send(self) -> None: self.room_members = [U_APPLE, U_ONION] @@ -305,7 +308,10 @@ def test_started_typing_remote_recv_not_in_room(self) -> None: self.assertEqual(events[0], []) self.assertEqual(events[1], 0) - @override_config({"send_federation": True}) + # Default test case disables federation sending. Setting + # 'federation_sender_instances' to None turns it back on for the main + # process + @override_config({"federation_sender_instances": None}) def test_stopped_typing(self) -> None: self.room_members = [U_APPLE, U_BANANA, U_ONION] diff --git a/tests/module_api/test_api.py b/tests/module_api/test_api.py index 058ca57e559d..e03dd63d06aa 100644 --- a/tests/module_api/test_api.py +++ b/tests/module_api/test_api.py @@ -336,7 +336,10 @@ def test_send_local_online_presence_to(self): # Test sending local online presence to users from the main process _test_sending_local_online_presence_to_local_user(self, test_with_workers=False) - @override_config({"send_federation": True}) + # Default test case disables federation sending. Setting + # 'federation_sender_instances' to None turns it back on for the main + # process + @override_config({"federation_sender_instances": None}) def test_send_local_online_presence_to_federation(self): """Tests that send_local_presence_to_users sends local online presence to remote users.""" # Create a user who will send presence updates diff --git a/tests/replication/_base.py b/tests/replication/_base.py index 3029a16ddad9..6a7174b333c9 100644 --- a/tests/replication/_base.py +++ b/tests/replication/_base.py @@ -307,7 +307,7 @@ def make_worker_hs( stream to the master HS. Args: - worker_app: Type of worker, e.g. `synapse.app.federation_sender`. + worker_app: Type of worker, e.g. `synapse.app.generic_worker`. extra_config: Any extra config to use for this instances. **kwargs: Options that get passed to `self.setup_test_homeserver`, useful to e.g. pass some mocks for things like `federation_http_client` diff --git a/tests/replication/tcp/streams/test_federation.py b/tests/replication/tcp/streams/test_federation.py index ffec06a0d653..08c6f80488e1 100644 --- a/tests/replication/tcp/streams/test_federation.py +++ b/tests/replication/tcp/streams/test_federation.py @@ -22,9 +22,9 @@ class FederationStreamTestCase(BaseStreamTestCase): def _get_worker_hs_config(self) -> dict: # enable federation sending on the worker config = super()._get_worker_hs_config() - # TODO: make it so we don't need both of these - config["send_federation"] = False - config["worker_app"] = "synapse.app.federation_sender" + # The 'worker_app' is declared to be 'synapse.app.generic_worker' in super() + # Workers with no name default to whatever is in the 'worker_app' + config["federation_sender_instances"] = ["synapse.app.generic_worker"] return config def test_catchup(self): diff --git a/tests/replication/test_federation_ack.py b/tests/replication/test_federation_ack.py index 26b8bd512a7f..741c35a67c9f 100644 --- a/tests/replication/test_federation_ack.py +++ b/tests/replication/test_federation_ack.py @@ -25,8 +25,9 @@ class FederationAckTestCase(HomeserverTestCase): def default_config(self) -> dict: config = super().default_config() - config["worker_app"] = "synapse.app.federation_sender" - config["send_federation"] = False + config["worker_app"] = "synapse.app.generic_worker" + # Workers with no name default to whatever is in 'worker_app' + config["federation_sender_instances"] = ["synapse.app.generic_worker"] return config def make_homeserver(self, reactor, clock): diff --git a/tests/replication/test_federation_sender_shard.py b/tests/replication/test_federation_sender_shard.py index 6104a55aa1a9..065f9020a1f5 100644 --- a/tests/replication/test_federation_sender_shard.py +++ b/tests/replication/test_federation_sender_shard.py @@ -35,7 +35,9 @@ class FederationSenderTestCase(BaseMultiWorkerStreamTestCase): def default_config(self): conf = super().default_config() - conf["send_federation"] = False + # Setting this to an empty list disables federation sending. This is actually + # declared in super(), so this entire override is probably redundant. + conf["federation_sender_instances"] = [] return conf def test_send_event_single_sender(self): @@ -46,8 +48,11 @@ def test_send_event_single_sender(self): mock_client.put_json.return_value = make_awaitable({}) self.make_worker_hs( - "synapse.app.federation_sender", - {"send_federation": False}, + "synapse.app.generic_worker", + { + "worker_name": "sender1", + "federation_sender_instances": ["sender1"], + }, federation_http_client=mock_client, ) @@ -73,9 +78,8 @@ def test_send_event_sharded(self): mock_client1 = Mock(spec=["put_json"]) mock_client1.put_json.return_value = make_awaitable({}) self.make_worker_hs( - "synapse.app.federation_sender", + "synapse.app.generic_worker", { - "send_federation": True, "worker_name": "sender1", "federation_sender_instances": ["sender1", "sender2"], }, @@ -85,9 +89,8 @@ def test_send_event_sharded(self): mock_client2 = Mock(spec=["put_json"]) mock_client2.put_json.return_value = make_awaitable({}) self.make_worker_hs( - "synapse.app.federation_sender", + "synapse.app.generic_worker", { - "send_federation": True, "worker_name": "sender2", "federation_sender_instances": ["sender1", "sender2"], }, @@ -136,9 +139,8 @@ def test_send_typing_sharded(self): mock_client1 = Mock(spec=["put_json"]) mock_client1.put_json.return_value = make_awaitable({}) self.make_worker_hs( - "synapse.app.federation_sender", + "synapse.app.generic_worker", { - "send_federation": True, "worker_name": "sender1", "federation_sender_instances": ["sender1", "sender2"], }, @@ -148,9 +150,8 @@ def test_send_typing_sharded(self): mock_client2 = Mock(spec=["put_json"]) mock_client2.put_json.return_value = make_awaitable({}) self.make_worker_hs( - "synapse.app.federation_sender", + "synapse.app.generic_worker", { - "send_federation": True, "worker_name": "sender2", "federation_sender_instances": ["sender1", "sender2"], }, diff --git a/tests/utils.py b/tests/utils.py index 045a8b5fa7d9..d3ee99bdfac9 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -125,7 +125,8 @@ def default_config( """ config_dict = { "server_name": name, - "send_federation": False, + # Setting this to an empty list turns off federation sending. + "federation_sender_instances": [], "media_store_path": "media", # the test signing key is just an arbitrary ed25519 key to keep the config # parser happy From 8e99103309b756f4c3ed9636366b7111f60a50df Mon Sep 17 00:00:00 2001 From: Jason Little Date: Sun, 27 Nov 2022 17:04:11 -0600 Subject: [PATCH 02/22] Adjust tests with legacy settings involving pushers to modern settings. --- tests/push/test_email.py | 1 - tests/push/test_http.py | 1 - tests/replication/test_pusher_shard.py | 11 ++++------- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/push/test_email.py b/tests/push/test_email.py index fd14568f55ce..57b2f0536e4a 100644 --- a/tests/push/test_email.py +++ b/tests/push/test_email.py @@ -66,7 +66,6 @@ def make_homeserver(self, reactor, clock): "riot_base_url": None, } config["public_baseurl"] = "http://aaa" - config["start_pushers"] = True hs = self.setup_test_homeserver(config=config) diff --git a/tests/push/test_http.py b/tests/push/test_http.py index b383b8401f62..d8098a969543 100644 --- a/tests/push/test_http.py +++ b/tests/push/test_http.py @@ -43,7 +43,6 @@ class HTTPPusherTests(HomeserverTestCase): def default_config(self) -> Dict[str, Any]: config = super().default_config() - config["start_pushers"] = True return config def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer: diff --git a/tests/replication/test_pusher_shard.py b/tests/replication/test_pusher_shard.py index 59fea93e490e..a268adab0403 100644 --- a/tests/replication/test_pusher_shard.py +++ b/tests/replication/test_pusher_shard.py @@ -40,7 +40,6 @@ def prepare(self, reactor, clock, hs): def default_config(self): conf = super().default_config() - conf["start_pushers"] = False return conf def _create_pusher_and_send_msg(self, localpart): @@ -92,8 +91,8 @@ def test_send_push_single_worker(self): ) self.make_worker_hs( - "synapse.app.pusher", - {"start_pushers": False}, + "synapse.app.generic_worker", + {"pusher_instances": ["synapse.app.generic_worker"]}, proxied_blacklisted_http_client=http_client_mock, ) @@ -122,9 +121,8 @@ def test_send_push_multiple_workers(self): ) self.make_worker_hs( - "synapse.app.pusher", + "synapse.app.generic_worker", { - "start_pushers": True, "worker_name": "pusher1", "pusher_instances": ["pusher1", "pusher2"], }, @@ -137,9 +135,8 @@ def test_send_push_multiple_workers(self): ) self.make_worker_hs( - "synapse.app.pusher", + "synapse.app.generic_worker", { - "start_pushers": True, "worker_name": "pusher2", "pusher_instances": ["pusher1", "pusher2"], }, From 2b972a57e10042022e571687196b839053e68488 Mon Sep 17 00:00:00 2001 From: Jason Little Date: Sun, 27 Nov 2022 17:14:58 -0600 Subject: [PATCH 03/22] Linting found a whoops. --- tests/handlers/test_presence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/handlers/test_presence.py b/tests/handlers/test_presence.py index dd814bfb9622..ffe02d4f3f13 100644 --- a/tests/handlers/test_presence.py +++ b/tests/handlers/test_presence.py @@ -995,7 +995,7 @@ def default_config(self): # Default test case disables federation sending. Setting # 'federation_sender_instances' to None turns it back on for the main # process - config["federation_sender_instances"]: None + config["federation_sender_instances"] = None return config def prepare(self, reactor, clock, hs): From 0dafd0f4bc6c7ecaf03b3027c202100d61bef1f7 Mon Sep 17 00:00:00 2001 From: Jason Little Date: Sun, 27 Nov 2022 17:25:28 -0600 Subject: [PATCH 04/22] Add explicit override. ...to disable the potential for pushing to be active on the fake main process. Is this accurate or unnecessary? --- tests/replication/test_pusher_shard.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/replication/test_pusher_shard.py b/tests/replication/test_pusher_shard.py index a268adab0403..63cfe18fe577 100644 --- a/tests/replication/test_pusher_shard.py +++ b/tests/replication/test_pusher_shard.py @@ -20,6 +20,7 @@ from synapse.rest.client import login, room from tests.replication._base import BaseMultiWorkerStreamTestCase +from tests.unittest import override_config logger = logging.getLogger(__name__) @@ -83,6 +84,10 @@ def _create_pusher_and_send_msg(self, localpart): return event_id + # Pusher functionality is active on the main process by default. Disable that by + # explicitly overriding what 'pusher_instances' will be available so + # ShardedWorkerHandlingConfig will be filled out correctly. + @override_config({"pusher_instances": ["pusher1"]}) def test_send_push_single_worker(self): """Test that registration works when using a pusher worker.""" http_client_mock = Mock(spec_set=["post_json_get_json"]) @@ -113,6 +118,10 @@ def test_send_push_single_worker(self): ], ) + # Pusher functionality is active on the main process by default. Disable that by + # explicitly overriding what 'pusher_instances' will be available so + # ShardedWorkerHandlingConfig will be filled out correctly. + @override_config({"pusher_instances": ["pusher1", "pusher2"]}) def test_send_push_multiple_workers(self): """Test that registration works when using sharded pusher workers.""" http_client_mock1 = Mock(spec_set=["post_json_get_json"]) From eab6536ae29a9af75c0958827b3935b6269c50a0 Mon Sep 17 00:00:00 2001 From: Jason Little Date: Sun, 27 Nov 2022 23:39:57 -0600 Subject: [PATCH 05/22] Replace 'synapse.app.client_reader' with 'synapse.app.generic_worker' and fix comments. --- tests/replication/test_auth.py | 4 ++-- tests/replication/test_client_reader_shard.py | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/replication/test_auth.py b/tests/replication/test_auth.py index 43a16bb141db..5d7a89e0c702 100644 --- a/tests/replication/test_auth.py +++ b/tests/replication/test_auth.py @@ -38,7 +38,7 @@ def make_homeserver(self, reactor, clock): def _get_worker_hs_config(self) -> dict: config = self.default_config() - config["worker_app"] = "synapse.app.client_reader" + config["worker_app"] = "synapse.app.generic_worker" config["worker_replication_host"] = "testserv" config["worker_replication_http_port"] = "8765" @@ -53,7 +53,7 @@ def _test_register(self) -> FakeChannel: 4. Return the final request. """ - worker_hs = self.make_worker_hs("synapse.app.client_reader") + worker_hs = self.make_worker_hs("synapse.app.generic_worker") site = self._hs_to_site[worker_hs] channel_1 = make_request( diff --git a/tests/replication/test_client_reader_shard.py b/tests/replication/test_client_reader_shard.py index 995097d72ccc..eb5b376534b9 100644 --- a/tests/replication/test_client_reader_shard.py +++ b/tests/replication/test_client_reader_shard.py @@ -22,20 +22,20 @@ class ClientReaderTestCase(BaseMultiWorkerStreamTestCase): - """Test using one or more client readers for registration.""" + """Test using one or more generic workers for registration.""" servlets = [register.register_servlets] def _get_worker_hs_config(self) -> dict: config = self.default_config() - config["worker_app"] = "synapse.app.client_reader" + config["worker_app"] = "synapse.app.generic_worker" config["worker_replication_host"] = "testserv" config["worker_replication_http_port"] = "8765" return config def test_register_single_worker(self): - """Test that registration works when using a single client reader worker.""" - worker_hs = self.make_worker_hs("synapse.app.client_reader") + """Test that registration works when using a single generic worker.""" + worker_hs = self.make_worker_hs("synapse.app.generic_worker") site = self._hs_to_site[worker_hs] channel_1 = make_request( @@ -64,9 +64,9 @@ def test_register_single_worker(self): self.assertEqual(channel_2.json_body["user_id"], "@user:test") def test_register_multi_worker(self): - """Test that registration works when using multiple client reader workers.""" - worker_hs_1 = self.make_worker_hs("synapse.app.client_reader") - worker_hs_2 = self.make_worker_hs("synapse.app.client_reader") + """Test that registration works when using multiple generic workers.""" + worker_hs_1 = self.make_worker_hs("synapse.app.generic_worker") + worker_hs_2 = self.make_worker_hs("synapse.app.generic_worker") site_1 = self._hs_to_site[worker_hs_1] channel_1 = make_request( From b57aeb1a73480a4260792104064c14c6396540e2 Mon Sep 17 00:00:00 2001 From: Jason Little Date: Mon, 28 Nov 2022 01:55:11 -0600 Subject: [PATCH 06/22] Update tests using 'update_user_directory'. By setting 'update_user_directory_from_worker' to 'None', it disables the functionality(and I added that comment where the default config is written out). If you need to re-enable this functionality on master, either .pop() that value or alternatively set it to master which appears to work as well. --- tests/handlers/test_user_directory.py | 8 ++++++-- tests/utils.py | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/handlers/test_user_directory.py b/tests/handlers/test_user_directory.py index 9e39cd97e5bf..77545b2c5137 100644 --- a/tests/handlers/test_user_directory.py +++ b/tests/handlers/test_user_directory.py @@ -56,7 +56,9 @@ class UserDirectoryTestCase(unittest.HomeserverTestCase): def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer: config = self.default_config() - config["update_user_directory"] = True + # Remove the value that disables updating the user directory, as that function + # is needed below. + config.pop("update_user_directory_from_worker") self.appservice = ApplicationService( token="i_am_an_app_service", @@ -1045,7 +1047,9 @@ class TestUserDirSearchDisabled(unittest.HomeserverTestCase): def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer: config = self.default_config() - config["update_user_directory"] = True + # Remove the value that disables updating the user directory, as that function + # is needed below. It will be force disabled later + config.pop("update_user_directory_from_worker") hs = self.setup_test_homeserver(config=config) self.config = hs.config diff --git a/tests/utils.py b/tests/utils.py index d3ee99bdfac9..19aa17d69977 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -184,8 +184,9 @@ def default_config( # rooms will fail. "default_room_version": DEFAULT_ROOM_VERSION, # disable user directory updates, because they get done in the - # background, which upsets the test runner. - "update_user_directory": False, + # background, which upsets the test runner. Instead of an actual worker_name, + # setting this to 'None' disables updating the user directory as intended. + "update_user_directory_from_worker": None, "caches": {"global_factor": 1, "sync_response_cache_duration": 0}, "listeners": [{"port": 0, "type": "http"}], } From 44ec2eb1767db43df07f30a960e2dbf34723ee88 Mon Sep 17 00:00:00 2001 From: Jason Little Date: Mon, 28 Nov 2022 04:33:59 -0600 Subject: [PATCH 07/22] Changelog --- changelog.d/14568.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/14568.misc diff --git a/changelog.d/14568.misc b/changelog.d/14568.misc new file mode 100644 index 000000000000..13a8971dadbb --- /dev/null +++ b/changelog.d/14568.misc @@ -0,0 +1 @@ +Update some unit tests configuration that are related to workers. From b00d88f13dd46173afbcdbe1ca79533c2231afff Mon Sep 17 00:00:00 2001 From: Jason Little Date: Mon, 28 Nov 2022 18:49:08 -0600 Subject: [PATCH 08/22] Per review, update how 'update_user_directory_from_worker' is used to be more clear(and accurate). --- tests/handlers/test_user_directory.py | 11 +++++------ tests/utils.py | 5 +++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/handlers/test_user_directory.py b/tests/handlers/test_user_directory.py index 77545b2c5137..75fc5a17a47b 100644 --- a/tests/handlers/test_user_directory.py +++ b/tests/handlers/test_user_directory.py @@ -56,9 +56,8 @@ class UserDirectoryTestCase(unittest.HomeserverTestCase): def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer: config = self.default_config() - # Remove the value that disables updating the user directory, as that function - # is needed below. - config.pop("update_user_directory_from_worker") + # Re-enables updating the user directory, as that function is needed below. + config["update_user_directory_from_worker"] = None self.appservice = ApplicationService( token="i_am_an_app_service", @@ -1047,9 +1046,9 @@ class TestUserDirSearchDisabled(unittest.HomeserverTestCase): def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer: config = self.default_config() - # Remove the value that disables updating the user directory, as that function - # is needed below. It will be force disabled later - config.pop("update_user_directory_from_worker") + # Re-enables updating the user directory, as that function is needed below. It + # will be force disabled later + config["update_user_directory_from_worker"] = None hs = self.setup_test_homeserver(config=config) self.config = hs.config diff --git a/tests/utils.py b/tests/utils.py index 19aa17d69977..210bc451b0d9 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -185,8 +185,9 @@ def default_config( "default_room_version": DEFAULT_ROOM_VERSION, # disable user directory updates, because they get done in the # background, which upsets the test runner. Instead of an actual worker_name, - # setting this to 'None' disables updating the user directory as intended. - "update_user_directory_from_worker": None, + # setting this to an obviously 'Fake_worker_name' disables updating the user + # directory as intended. + "update_user_directory_from_worker": "Fake_worker_name", "caches": {"global_factor": 1, "sync_response_cache_duration": 0}, "listeners": [{"port": 0, "type": "http"}], } From 91195d3858d08ccd7b3019dc09b9a696e09480ef Mon Sep 17 00:00:00 2001 From: Jason Little Date: Mon, 28 Nov 2022 19:22:48 -0600 Subject: [PATCH 09/22] Per review, consolidate overridden settings into a 'default_config()' block. Add docstring to Test Class that explains it's turned on(check for accuracy generally). --- tests/events/test_presence_router.py | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/tests/events/test_presence_router.py b/tests/events/test_presence_router.py index 52e355e1296c..b703e4472e9e 100644 --- a/tests/events/test_presence_router.py +++ b/tests/events/test_presence_router.py @@ -126,6 +126,13 @@ def parse_config(config_dict: dict) -> PresenceRouterTestConfig: class PresenceRouterTestCase(FederatingHomeserverTestCase): + """ + Test cases using a custom PresenceRouter + + By default in test cases, federation sending is disabled. This class re-enables it + for the main process by setting `federation_sender_instances` to None. + """ + servlets = [ admin.register_servlets, login.register_servlets, @@ -150,6 +157,11 @@ def prepare(self, reactor, clock, homeserver): self.sync_handler = self.hs.get_sync_handler() self.module_api = homeserver.get_module_api() + def default_config(self) -> JsonDict: + config = super().default_config() + config["federation_sender_instances"] = None + return config + @override_config( { "presence": { @@ -162,10 +174,6 @@ def prepare(self, reactor, clock, homeserver): }, } }, - # Default test case disables federation sending. Setting - # 'federation_sender_instances' to None turns it back on for the main - # process - "federation_sender_instances": None, } ) def test_receiving_all_presence_legacy(self): @@ -183,10 +191,6 @@ def test_receiving_all_presence_legacy(self): }, }, ], - # Default test case disables federation sending. Setting - # 'federation_sender_instances' to None turns it back on for the main - # process - "federation_sender_instances": None, } ) def test_receiving_all_presence(self): @@ -296,10 +300,6 @@ def receiving_all_presence_test_body(self): }, } }, - # Default test case disables federation sending. Setting - # 'federation_sender_instances' to None turns it back on for the main - # process - "federation_sender_instances": None, } ) def test_send_local_online_presence_to_with_module_legacy(self): @@ -319,10 +319,6 @@ def test_send_local_online_presence_to_with_module_legacy(self): }, }, ], - # Default test case disables federation sending. Setting - # 'federation_sender_instances' to None turns it back on for the main - # process - "federation_sender_instances": None, } ) def test_send_local_online_presence_to_with_module(self): From 0abc6cc397f8dbabb9638255c482cb1de3ef12f7 Mon Sep 17 00:00:00 2001 From: Jason Little Date: Mon, 28 Nov 2022 19:49:56 -0600 Subject: [PATCH 10/22] Per review, consolidate override into a 'default_config()' and add docstring. --- tests/federation/test_federation_catch_up.py | 37 +++++++------------- 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/tests/federation/test_federation_catch_up.py b/tests/federation/test_federation_catch_up.py index 047795744e2c..3e21b3adecfa 100644 --- a/tests/federation/test_federation_catch_up.py +++ b/tests/federation/test_federation_catch_up.py @@ -7,6 +7,7 @@ from synapse.federation.units import Edu from synapse.rest import admin from synapse.rest.client import login, room +from synapse.types import JsonDict from synapse.util.retryutils import NotRetryingDestination from tests.test_utils import event_injection, make_awaitable @@ -14,6 +15,13 @@ class FederationCatchUpTestCases(FederatingHomeserverTestCase): + """ + Tests cases of catching up over federation. + + By default for test cases federation sending is disabled. This Test class has it + re-enabled for the main process. + """ + servlets = [ admin.register_servlets, room.register_servlets, @@ -42,6 +50,11 @@ def prepare(self, reactor, clock, hs): self.record_transaction ) + def default_config(self) -> JsonDict: + config = super().default_config() + config["federation_sender_instances"] = None + return config + async def record_transaction(self, txn, json_cb): if self.is_online: data = json_cb() @@ -79,10 +92,6 @@ def get_destination_room(self, room: str, destination: str = "host2") -> dict: )[0] return {"event_id": event_id, "stream_ordering": stream_ordering} - # Default test case disables federation sending. Setting - # 'federation_sender_instances' to None turns it back on for the main - # process - @override_config({"federation_sender_instances": None}) def test_catch_up_destination_rooms_tracking(self): """ Tests that we populate the `destination_rooms` table as needed. @@ -108,10 +117,6 @@ def test_catch_up_destination_rooms_tracking(self): self.assertEqual(row_2["event_id"], event_id_2) self.assertEqual(row_1["stream_ordering"], row_2["stream_ordering"] - 1) - # Default test case disables federation sending. Setting - # 'federation_sender_instances' to None turns it back on for the main - # process - @override_config({"federation_sender_instances": None}) def test_catch_up_last_successful_stream_ordering_tracking(self): """ Tests that we populate the `destination_rooms` table as needed. @@ -169,10 +174,6 @@ def test_catch_up_last_successful_stream_ordering_tracking(self): "Send succeeded but not marked as last_successful_stream_ordering", ) - # Default test case disables federation sending. Setting - # 'federation_sender_instances' to None turns it back on for the main - # process - @override_config({"federation_sender_instances": None}) # critical to federate def test_catch_up_from_blank_state(self): """ Runs an overall test of federation catch-up from scratch. @@ -269,10 +270,6 @@ async def fake_send( return per_dest_queue, results_list - # Default test case disables federation sending. Setting - # 'federation_sender_instances' to None turns it back on for the main - # process - @override_config({"federation_sender_instances": None}) def test_catch_up_loop(self): """ Tests the behaviour of _catch_up_transmission_loop. @@ -337,10 +334,6 @@ def test_catch_up_loop(self): event_5.internal_metadata.stream_ordering, ) - # Default test case disables federation sending. Setting - # 'federation_sender_instances' to None turns it back on for the main - # process - @override_config({"federation_sender_instances": None}) def test_catch_up_on_synapse_startup(self): """ Tests the behaviour of get_catch_up_outstanding_destinations and @@ -439,10 +432,6 @@ def wake_destination_track(destination): # - all destinations are woken exactly once; they appear once in woken. self.assertCountEqual(woken, server_names[:-1]) - # Default test case disables federation sending. Setting - # 'federation_sender_instances' to None turns it back on for the main - # process - @override_config({"federation_sender_instances": None}) def test_not_latest_event(self): """Test that we send the latest event in the room even if its not ours.""" From c37364dbd0e87f69d4790975b5de1ee02fdf5a03 Mon Sep 17 00:00:00 2001 From: Jason Little Date: Tue, 29 Nov 2022 03:12:27 -0600 Subject: [PATCH 11/22] Remove now unused import --- tests/federation/test_federation_catch_up.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/federation/test_federation_catch_up.py b/tests/federation/test_federation_catch_up.py index 3e21b3adecfa..b8fee7289838 100644 --- a/tests/federation/test_federation_catch_up.py +++ b/tests/federation/test_federation_catch_up.py @@ -11,7 +11,7 @@ from synapse.util.retryutils import NotRetryingDestination from tests.test_utils import event_injection, make_awaitable -from tests.unittest import FederatingHomeserverTestCase, override_config +from tests.unittest import FederatingHomeserverTestCase class FederationCatchUpTestCases(FederatingHomeserverTestCase): From b9f765d1cf6a72e575cac62c1ae491e03ec59de7 Mon Sep 17 00:00:00 2001 From: Jason Little Date: Tue, 29 Nov 2022 03:29:05 -0600 Subject: [PATCH 12/22] Shorten a bunch of wordy comments. --- tests/handlers/test_presence.py | 4 +--- tests/handlers/test_typing.py | 8 ++------ tests/module_api/test_api.py | 4 +--- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/tests/handlers/test_presence.py b/tests/handlers/test_presence.py index ffe02d4f3f13..584e7b89712c 100644 --- a/tests/handlers/test_presence.py +++ b/tests/handlers/test_presence.py @@ -992,9 +992,7 @@ def make_homeserver(self, reactor, clock): def default_config(self): config = super().default_config() - # Default test case disables federation sending. Setting - # 'federation_sender_instances' to None turns it back on for the main - # process + # Enable federation sending on the main process. config["federation_sender_instances"] = None return config diff --git a/tests/handlers/test_typing.py b/tests/handlers/test_typing.py index 63f16559111d..efbb5a8dbbaf 100644 --- a/tests/handlers/test_typing.py +++ b/tests/handlers/test_typing.py @@ -200,9 +200,7 @@ def test_started_typing_local(self) -> None: ], ) - # Default test case disables federation sending. Setting - # 'federation_sender_instances' to None turns it back on for the main - # process + # Enable federation sending on the main process. @override_config({"federation_sender_instances": None}) def test_started_typing_remote_send(self) -> None: self.room_members = [U_APPLE, U_ONION] @@ -308,9 +306,7 @@ def test_started_typing_remote_recv_not_in_room(self) -> None: self.assertEqual(events[0], []) self.assertEqual(events[1], 0) - # Default test case disables federation sending. Setting - # 'federation_sender_instances' to None turns it back on for the main - # process + # Enable federation sending on the main process. @override_config({"federation_sender_instances": None}) def test_stopped_typing(self) -> None: self.room_members = [U_APPLE, U_BANANA, U_ONION] diff --git a/tests/module_api/test_api.py b/tests/module_api/test_api.py index e03dd63d06aa..b0f3f4374da8 100644 --- a/tests/module_api/test_api.py +++ b/tests/module_api/test_api.py @@ -336,9 +336,7 @@ def test_send_local_online_presence_to(self): # Test sending local online presence to users from the main process _test_sending_local_online_presence_to_local_user(self, test_with_workers=False) - # Default test case disables federation sending. Setting - # 'federation_sender_instances' to None turns it back on for the main - # process + # Enable federation sending on the main process. @override_config({"federation_sender_instances": None}) def test_send_local_online_presence_to_federation(self): """Tests that send_local_presence_to_users sends local online presence to remote users.""" From 26c7bec0efa837e6026d2d7b5c31c83b89e1a018 Mon Sep 17 00:00:00 2001 From: Jason Little Date: Tue, 29 Nov 2022 03:33:43 -0600 Subject: [PATCH 13/22] Per review, consolidate override into a 'default_config()' and add docstring. --- tests/federation/test_federation_sender.py | 31 ++++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/tests/federation/test_federation_sender.py b/tests/federation/test_federation_sender.py index 5b5e906bc3c7..565a123e7f41 100644 --- a/tests/federation/test_federation_sender.py +++ b/tests/federation/test_federation_sender.py @@ -29,6 +29,13 @@ class FederationSenderReceiptsTestCases(HomeserverTestCase): + """ + Test federation sending to update receipts. + + By default for test cases federation sending is disabled. This Test class has it + re-enabled for the main process. + """ + def make_homeserver(self, reactor, clock): hs = self.setup_test_homeserver( federation_transport_client=Mock(spec=["send_transaction"]), @@ -40,10 +47,11 @@ def make_homeserver(self, reactor, clock): return hs - # Default test case disables federation sending. Setting - # 'federation_sender_instances' to None turns it back on for the main - # process - @override_config({"federation_sender_instances": None}) + def default_config(self) -> JsonDict: + config = super().default_config() + config["federation_sender_instances"] = None + return config + def test_send_receipts(self): mock_send_transaction = ( self.hs.get_federation_transport_client().send_transaction @@ -86,10 +94,6 @@ def test_send_receipts(self): ], ) - # Default test case disables federation sending. Setting - # 'federation_sender_instances' to None turns it back on for the main - # process - @override_config({"federation_sender_instances": None}) def test_send_receipts_with_backoff(self): """Send two receipts in quick succession; the second should be flushed, but only after 20ms""" @@ -176,6 +180,13 @@ def test_send_receipts_with_backoff(self): class FederationSenderDevicesTestCases(HomeserverTestCase): + """ + Test federation sending to update devices. + + By default for test cases federation sending is disabled. This Test class has it + re-enabled for the main process. + """ + servlets = [ admin.register_servlets, login.register_servlets, @@ -190,9 +201,7 @@ def make_homeserver(self, reactor, clock): def default_config(self): c = super().default_config() - # Default test case disables federation sending. Setting - # 'federation_sender_instances' to None turns it back on for the main - # process + # Enable federation sending on the main process. c["federation_sender_instances"] = None return c From e7138f2453848f5b8d57978f096a1bae18b5bbef Mon Sep 17 00:00:00 2001 From: Jason Little Date: Tue, 29 Nov 2022 03:49:46 -0600 Subject: [PATCH 14/22] Per review, remove redundant 'default_config()'s that served no purpose(see what I did there). --- tests/push/test_http.py | 4 ---- tests/replication/test_federation_sender_shard.py | 13 ++++++------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/tests/push/test_http.py b/tests/push/test_http.py index d8098a969543..ade63d640820 100644 --- a/tests/push/test_http.py +++ b/tests/push/test_http.py @@ -41,10 +41,6 @@ class HTTPPusherTests(HomeserverTestCase): user_id = True hijack_auth = False - def default_config(self) -> Dict[str, Any]: - config = super().default_config() - return config - def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer: self.push_attempts: List[Tuple[Deferred, str, dict]] = [] diff --git a/tests/replication/test_federation_sender_shard.py b/tests/replication/test_federation_sender_shard.py index 065f9020a1f5..4cadff140917 100644 --- a/tests/replication/test_federation_sender_shard.py +++ b/tests/replication/test_federation_sender_shard.py @@ -27,19 +27,18 @@ class FederationSenderTestCase(BaseMultiWorkerStreamTestCase): + """ + Various tests for federation sending on workers. + + Federation sending is disabled by default, it will be enabled in each test by + updating 'federation_sender_instances'. + """ servlets = [ login.register_servlets, register_servlets_for_client_rest_resource, room.register_servlets, ] - def default_config(self): - conf = super().default_config() - # Setting this to an empty list disables federation sending. This is actually - # declared in super(), so this entire override is probably redundant. - conf["federation_sender_instances"] = [] - return conf - def test_send_event_single_sender(self): """Test that using a single federation sender worker correctly sends a new event. From 71623f0c03538215004fd0e196c824c23d1196f0 Mon Sep 17 00:00:00 2001 From: Jason Little Date: Tue, 29 Nov 2022 03:59:50 -0600 Subject: [PATCH 15/22] Per review, change all 'sender's to 'federation_sender's. --- .../test_federation_sender_shard.py | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/tests/replication/test_federation_sender_shard.py b/tests/replication/test_federation_sender_shard.py index 4cadff140917..c28073b8f797 100644 --- a/tests/replication/test_federation_sender_shard.py +++ b/tests/replication/test_federation_sender_shard.py @@ -33,6 +33,7 @@ class FederationSenderTestCase(BaseMultiWorkerStreamTestCase): Federation sending is disabled by default, it will be enabled in each test by updating 'federation_sender_instances'. """ + servlets = [ login.register_servlets, register_servlets_for_client_rest_resource, @@ -49,8 +50,8 @@ def test_send_event_single_sender(self): self.make_worker_hs( "synapse.app.generic_worker", { - "worker_name": "sender1", - "federation_sender_instances": ["sender1"], + "worker_name": "federation_sender1", + "federation_sender_instances": ["federation_sender1"], }, federation_http_client=mock_client, ) @@ -79,8 +80,11 @@ def test_send_event_sharded(self): self.make_worker_hs( "synapse.app.generic_worker", { - "worker_name": "sender1", - "federation_sender_instances": ["sender1", "sender2"], + "worker_name": "federation_sender1", + "federation_sender_instances": [ + "federation_sender1", + "federation_sender2", + ], }, federation_http_client=mock_client1, ) @@ -90,8 +94,11 @@ def test_send_event_sharded(self): self.make_worker_hs( "synapse.app.generic_worker", { - "worker_name": "sender2", - "federation_sender_instances": ["sender1", "sender2"], + "worker_name": "federation_sender2", + "federation_sender_instances": [ + "federation_sender1", + "federation_sender2", + ], }, federation_http_client=mock_client2, ) @@ -140,8 +147,11 @@ def test_send_typing_sharded(self): self.make_worker_hs( "synapse.app.generic_worker", { - "worker_name": "sender1", - "federation_sender_instances": ["sender1", "sender2"], + "worker_name": "federation_sender1", + "federation_sender_instances": [ + "federation_sender1", + "federation_sender2", + ], }, federation_http_client=mock_client1, ) @@ -151,8 +161,11 @@ def test_send_typing_sharded(self): self.make_worker_hs( "synapse.app.generic_worker", { - "worker_name": "sender2", - "federation_sender_instances": ["sender1", "sender2"], + "worker_name": "federation_sender2", + "federation_sender_instances": [ + "federation_sender1", + "federation_sender2", + ], }, federation_http_client=mock_client2, ) From 8bde002da3e1924b64c6c64c118116f040ed4787 Mon Sep 17 00:00:00 2001 From: Jason Little Date: Tue, 29 Nov 2022 04:02:31 -0600 Subject: [PATCH 16/22] Remove more unused imports. --- tests/federation/test_federation_sender.py | 2 +- tests/push/test_http.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/federation/test_federation_sender.py b/tests/federation/test_federation_sender.py index 565a123e7f41..11734fccff9f 100644 --- a/tests/federation/test_federation_sender.py +++ b/tests/federation/test_federation_sender.py @@ -25,7 +25,7 @@ from synapse.types import JsonDict, ReadReceipt from tests.test_utils import make_awaitable -from tests.unittest import HomeserverTestCase, override_config +from tests.unittest import HomeserverTestCase class FederationSenderReceiptsTestCases(HomeserverTestCase): diff --git a/tests/push/test_http.py b/tests/push/test_http.py index ade63d640820..afaafe79aaf6 100644 --- a/tests/push/test_http.py +++ b/tests/push/test_http.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from typing import Any, Dict, List, Optional, Tuple +from typing import List, Optional, Tuple from unittest.mock import Mock from twisted.internet.defer import Deferred From 2c1a0a031061b638aa81de90a595f18c7a4beabb Mon Sep 17 00:00:00 2001 From: Jason Little Date: Tue, 29 Nov 2022 04:24:23 -0600 Subject: [PATCH 17/22] Per review, fix up a bunch of things I did weird/wrong. And remove the 'default_config' block too. --- tests/replication/test_pusher_shard.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/tests/replication/test_pusher_shard.py b/tests/replication/test_pusher_shard.py index 63cfe18fe577..ca18ad655394 100644 --- a/tests/replication/test_pusher_shard.py +++ b/tests/replication/test_pusher_shard.py @@ -20,7 +20,6 @@ from synapse.rest.client import login, room from tests.replication._base import BaseMultiWorkerStreamTestCase -from tests.unittest import override_config logger = logging.getLogger(__name__) @@ -39,10 +38,6 @@ def prepare(self, reactor, clock, hs): self.other_user_id = self.register_user("otheruser", "pass") self.other_access_token = self.login("otheruser", "pass") - def default_config(self): - conf = super().default_config() - return conf - def _create_pusher_and_send_msg(self, localpart): # Create a user that will get push notifications user_id = self.register_user(localpart, "pass") @@ -84,10 +79,6 @@ def _create_pusher_and_send_msg(self, localpart): return event_id - # Pusher functionality is active on the main process by default. Disable that by - # explicitly overriding what 'pusher_instances' will be available so - # ShardedWorkerHandlingConfig will be filled out correctly. - @override_config({"pusher_instances": ["pusher1"]}) def test_send_push_single_worker(self): """Test that registration works when using a pusher worker.""" http_client_mock = Mock(spec_set=["post_json_get_json"]) @@ -97,7 +88,7 @@ def test_send_push_single_worker(self): self.make_worker_hs( "synapse.app.generic_worker", - {"pusher_instances": ["synapse.app.generic_worker"]}, + {"worker_name": "pusher1", "pusher_instances": ["pusher1"]}, proxied_blacklisted_http_client=http_client_mock, ) @@ -118,10 +109,6 @@ def test_send_push_single_worker(self): ], ) - # Pusher functionality is active on the main process by default. Disable that by - # explicitly overriding what 'pusher_instances' will be available so - # ShardedWorkerHandlingConfig will be filled out correctly. - @override_config({"pusher_instances": ["pusher1", "pusher2"]}) def test_send_push_multiple_workers(self): """Test that registration works when using sharded pusher workers.""" http_client_mock1 = Mock(spec_set=["post_json_get_json"]) From 9cb0a6f5783581cb61d93e920dfe5135616db1d5 Mon Sep 17 00:00:00 2001 From: realtyem Date: Tue, 29 Nov 2022 04:32:03 -0600 Subject: [PATCH 18/22] Update tests/replication/test_federation_ack.py Co-authored-by: Patrick Cloke --- tests/replication/test_federation_ack.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/replication/test_federation_ack.py b/tests/replication/test_federation_ack.py index 741c35a67c9f..63b1dd40b5b9 100644 --- a/tests/replication/test_federation_ack.py +++ b/tests/replication/test_federation_ack.py @@ -26,8 +26,8 @@ class FederationAckTestCase(HomeserverTestCase): def default_config(self) -> dict: config = super().default_config() config["worker_app"] = "synapse.app.generic_worker" - # Workers with no name default to whatever is in 'worker_app' - config["federation_sender_instances"] = ["synapse.app.generic_worker"] + config["worker_name"] = "federation_sender1" + config["federation_sender_instances"] = ["federation_sender1"] return config def make_homeserver(self, reactor, clock): From b2e4590e4d4bcb876a1dd0694793b19aa0fc041d Mon Sep 17 00:00:00 2001 From: Jason Little Date: Tue, 29 Nov 2022 04:36:44 -0600 Subject: [PATCH 19/22] Give the last worker a name. --- tests/replication/tcp/streams/test_federation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/replication/tcp/streams/test_federation.py b/tests/replication/tcp/streams/test_federation.py index 08c6f80488e1..3ff60ac55456 100644 --- a/tests/replication/tcp/streams/test_federation.py +++ b/tests/replication/tcp/streams/test_federation.py @@ -23,8 +23,8 @@ def _get_worker_hs_config(self) -> dict: # enable federation sending on the worker config = super()._get_worker_hs_config() # The 'worker_app' is declared to be 'synapse.app.generic_worker' in super() - # Workers with no name default to whatever is in the 'worker_app' - config["federation_sender_instances"] = ["synapse.app.generic_worker"] + config["worker_name"] = "federation_sender1" + config["federation_sender_instances"] = ["federation_sender1"] return config def test_catchup(self): From 6de8d5a52dbb8151747ec2885f3588ee482fc804 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 30 Nov 2022 07:48:57 -0500 Subject: [PATCH 20/22] Remove outdated comment. --- tests/replication/tcp/streams/test_federation.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/replication/tcp/streams/test_federation.py b/tests/replication/tcp/streams/test_federation.py index 3ff60ac55456..bcb82c9c8051 100644 --- a/tests/replication/tcp/streams/test_federation.py +++ b/tests/replication/tcp/streams/test_federation.py @@ -22,7 +22,6 @@ class FederationStreamTestCase(BaseStreamTestCase): def _get_worker_hs_config(self) -> dict: # enable federation sending on the worker config = super()._get_worker_hs_config() - # The 'worker_app' is declared to be 'synapse.app.generic_worker' in super() config["worker_name"] = "federation_sender1" config["federation_sender_instances"] = ["federation_sender1"] return config From 9ab160ff7b957c98ca0423c3d0d48dd82186713b Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 30 Nov 2022 07:51:48 -0500 Subject: [PATCH 21/22] Tweak comment / name of user dir worker. --- tests/utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/utils.py b/tests/utils.py index 210bc451b0d9..d76bf9716ad2 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -184,10 +184,9 @@ def default_config( # rooms will fail. "default_room_version": DEFAULT_ROOM_VERSION, # disable user directory updates, because they get done in the - # background, which upsets the test runner. Instead of an actual worker_name, - # setting this to an obviously 'Fake_worker_name' disables updating the user - # directory as intended. - "update_user_directory_from_worker": "Fake_worker_name", + # background, which upsets the test runner. Setting this to an + # (obviously) fake worker name disables updating the user directory. + "update_user_directory_from_worker": "does_not_exist_worker_name", "caches": {"global_factor": 1, "sync_response_cache_duration": 0}, "listeners": [{"port": 0, "type": "http"}], } From 62ff49e04e50d62ba2717f60235845838544267d Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 30 Nov 2022 07:53:27 -0500 Subject: [PATCH 22/22] Clarify changelog. --- changelog.d/14568.misc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/14568.misc b/changelog.d/14568.misc index 13a8971dadbb..99973de1c1b8 100644 --- a/changelog.d/14568.misc +++ b/changelog.d/14568.misc @@ -1 +1 @@ -Update some unit tests configuration that are related to workers. +Modernize unit tests configuration related to workers.