From 142fb0a7d40f17d834e1e4d13963839195c1040b Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 9 Jan 2018 12:03:12 +0000 Subject: [PATCH 1/3] Disable user_directory updates for UTs Fix flakiness in the UTs caused by the user_directory being updated in the background --- tests/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/utils.py b/tests/utils.py index ed8a7360f..44e5f7509 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -58,6 +58,10 @@ def setup_test_homeserver(name="test", datastore=None, config=None, **kargs): config.email_enable_notifs = False config.block_non_admin_invites = False + # disable user directory updates, because they get done in the + # background, which upsets the test runner. + config.update_user_directory = False + config.use_frozen_dicts = True config.database_config = {"name": "sqlite3"} config.ldap_enabled = False From 374c4d4cedf2366f145934d750fd309209b0de62 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 9 Jan 2018 12:04:52 +0000 Subject: [PATCH 2/3] Remove dead code pointless function is pointless --- tests/rest/client/v1/test_rooms.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/rest/client/v1/test_rooms.py b/tests/rest/client/v1/test_rooms.py index de376fb51..9f3725538 100644 --- a/tests/rest/client/v1/test_rooms.py +++ b/tests/rest/client/v1/test_rooms.py @@ -515,9 +515,6 @@ class RoomsCreateTestCase(RestTestCase): synapse.rest.client.v1.room.register_servlets(hs, self.mock_resource) - def tearDown(self): - pass - @defer.inlineCallbacks def test_post_room_no_keys(self): # POST with no config keys, expect new room id From f8fa5ae4af770cdf69e2d335f3aff0b823b34009 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 9 Jan 2018 12:05:25 +0000 Subject: [PATCH 3/3] enable twisted delayedcall debugging in UTs --- tests/unittest.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/unittest.py b/tests/unittest.py index 38715972d..7b478c429 100644 --- a/tests/unittest.py +++ b/tests/unittest.py @@ -12,7 +12,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. - +import twisted from twisted.trial import unittest import logging @@ -65,6 +65,10 @@ class TestCase(unittest.TestCase): @around(self) def setUp(orig): + # enable debugging of delayed calls - this means that we get a + # traceback when a unit test exits leaving things on the reactor. + twisted.internet.base.DelayedCall.debug = True + old_level = logging.getLogger().level if old_level != level: