This test sometimes fails with:
ERROR: No replica set members match selector "Primary()" (ServerSelectionTimeoutError) Traceback (most recent call last): File "/data/mci/26eeb19bb7775a2b0ffb6f3b40c17caf/src/test/__init__.py", line 355, in wrap return f(*args, **kwargs) File "/data/mci/26eeb19bb7775a2b0ffb6f3b40c17caf/src/test/__init__.py", line 355, in wrap return f(*args, **kwargs) File "/data/mci/26eeb19bb7775a2b0ffb6f3b40c17caf/src/test/test_ssl.py", line 352, in test_cert_ssl_validation_hostname_matching serverSelectionTimeoutMS=100)) File "/data/mci/26eeb19bb7775a2b0ffb6f3b40c17caf/src/test/utils.py", line 285, in connected client.admin.command('ismaster') # Force connection. File "/data/mci/26eeb19bb7775a2b0ffb6f3b40c17caf/src/pymongo/database.py", line 524, in command with client._socket_for_reads(read_preference) as (sock_info, slave_ok): File "/opt/python/2.6/lib/python2.6/contextlib.py", line 16, in __enter__ return self.gen.next() File "/data/mci/26eeb19bb7775a2b0ffb6f3b40c17caf/src/pymongo/mongo_client.py", line 905, in _socket_for_reads with self._get_socket(read_preference) as sock_info: File "/opt/python/2.6/lib/python2.6/contextlib.py", line 16, in __enter__ return self.gen.next() File "/data/mci/26eeb19bb7775a2b0ffb6f3b40c17caf/src/pymongo/mongo_client.py", line 869, in _get_socket server = self._get_topology().select_server(selector) File "/data/mci/26eeb19bb7775a2b0ffb6f3b40c17caf/src/pymongo/topology.py", line 222, in select_server address)) File "/data/mci/26eeb19bb7775a2b0ffb6f3b40c17caf/src/pymongo/topology.py", line 181, in select_servers selector, server_timeout, address) File "/data/mci/26eeb19bb7775a2b0ffb6f3b40c17caf/src/pymongo/topology.py", line 197, in _select_servers_loop self._error_message(selector)) ServerSelectionTimeoutError: No replica set members match selector "Primary()"
I think this might just be a race condition due to the short serverSelectionTimeoutMS. Increasing the timeout to 250ms might reduce the frequency.