From ca46cb20bd991ddebcaec534973f6e7cff7f1782 Mon Sep 17 00:00:00 2001 From: Julius Park Date: Tue, 26 Oct 2021 17:49:22 -0700 Subject: [PATCH] PYTHON-2948 Add prose test for SRV polling with a custom service name (#764) --- test/test_srv_polling.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/test_srv_polling.py b/test/test_srv_polling.py index 030dcd27f..1e9927769 100644 --- a/test/test_srv_polling.py +++ b/test/test_srv_polling.py @@ -289,6 +289,24 @@ class TestSrvPolling(unittest.TestCase): new = set(client.topology_description.server_descriptions()) self.assertSetEqual(old, new) + def test_srv_service_name(self): + # Construct a valid final response callback distinct from base. + response = [ + ("localhost.test.build.10gen.cc.", 27019), + ("localhost.test.build.10gen.cc.", 27020) + ] + + def nodelist_callback(): + return response + + with SrvPollingKnobs( + ttl_time=WAIT_TIME, min_srv_rescan_interval=WAIT_TIME): + client = MongoClient( + "mongodb+srv://test22.test.build.10gen.cc/?srvServiceName" + "=customname") + with SrvPollingKnobs(nodelist_callback=nodelist_callback): + self.assert_nodelist_change(response, client) + if __name__ == '__main__': unittest.main()