Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
remote_server: Queue deferred work after commit.
Tim Abbottb9af6c7962ed
diff --git a/zerver/lib/remote_server.py b/zerver/lib/remote_server.pyindex 200b48b1ac5..ed1524c3c8d 100644--- a/zerver/lib/remote_server.py+++ b/zerver/lib/remote_server.py@@ -21,7 +21,7 @@ from zerver.lib.exceptions import (RemoteRealmServerMismatchError,)from zerver.lib.outgoing_http import OutgoingSession-from zerver.lib.queue import queue_json_publish+from zerver.lib.queue import queue_event_on_commitfrom zerver.models import OrgTypeEnum, Realm, RealmAuditLog@@ -411,4 +411,4 @@ def enqueue_register_realm_with_push_bouncer_if_needed(realm: Realm) -> None:# We do this in a queue worker to avoid messing with the realm# creation process due to network issues or latency.event = {"type": "register_realm_with_push_bouncer", "realm_id": realm.id}- queue_json_publish("deferred_work", event)+ queue_event_on_commit("deferred_work", event)diff --git a/zerver/tests/test_import_export.py b/zerver/tests/test_import_export.pyindex 11c4ef0650b..5594e7063ad 100644--- a/zerver/tests/test_import_export.py+++ b/zerver/tests/test_import_export.py@@ -1413,7 +1413,8 @@ class RealmImportExportTest(ExportFile):m.side_effect = mock_send_to_push_bouncer_response- new_realm = do_import_realm(get_output_dir(), "test-zulip")+ with self.captureOnCommitCallbacks(execute=True):+ new_realm = do_import_realm(get_output_dir(), "test-zulip")self.assertTrue(Realm.objects.filter(string_id="test-zulip").exists())calls_args_for_assert = m.call_args_list[1][0]diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.pyindex b9308586dfa..e4f3aa77bdf 100644--- a/zerver/tests/test_realm.py+++ b/zerver/tests/test_realm.py@@ -1103,7 +1103,8 @@ class RealmTest(ZulipTestCase):m.side_effect = mock_send_to_push_bouncer_response- realm = do_create_realm("realm_string_id", "realm name")+ with self.captureOnCommitCallbacks(execute=True):+ realm = do_create_realm("realm_string_id", "realm name")self.assertEqual(realm.string_id, "realm_string_id")self.assertEqual(m.call_count, 2)