Skip to content

Commit

Permalink
Set socket timeout when checking test mongod.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajdavis committed Dec 3, 2016
1 parent 2c2e1a4 commit 34eea7f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,12 @@ def setup_sync_cx(self):
port = int(os.environ.get("DB_PORT", 27017))
connectTimeoutMS = 100
serverSelectionTimeoutMS = 100
socketTimeoutMS = 10000
try:
client = connected(pymongo.MongoClient(
host, port,
connectTimeoutMS=connectTimeoutMS,
socketTimeoutMS=socketTimeoutMS,
serverSelectionTimeoutMS=serverSelectionTimeoutMS,
ssl_ca_certs=CA_PEM,
ssl=True))
Expand All @@ -157,14 +159,19 @@ def setup_sync_cx(self):
client = connected(pymongo.MongoClient(
host, port,
connectTimeoutMS=connectTimeoutMS,
socketTimeoutMS=socketTimeoutMS,
serverSelectionTimeoutMS=serverSelectionTimeoutMS,
ssl_ca_certs=CA_PEM,
ssl_certfile=CLIENT_PEM))

self.mongod_started_with_ssl = True
self.mongod_validates_client_cert = True
except pymongo.errors.ServerSelectionTimeoutError:
client = connected(pymongo.MongoClient(host, port))
client = connected(pymongo.MongoClient(
host, port,
connectTimeoutMS=connectTimeoutMS,
socketTimeoutMS=socketTimeoutMS,
serverSelectionTimeoutMS=serverSelectionTimeoutMS))

response = client.admin.command('ismaster')
if 'setName' in response:
Expand Down

0 comments on commit 34eea7f

Please sign in to comment.