diff options
author | Jonathan Abrahams <jonathan@mongodb.com> | 2017-12-01 09:19:59 -0500 |
---|---|---|
committer | Jonathan Abrahams <jonathan@mongodb.com> | 2018-02-02 10:20:55 -0500 |
commit | d8cc94168fbf759f053937d1b545afa82ce4d4d7 (patch) | |
tree | ff30bc7066f27e377b228ead146e577d2e3898ec /pytests | |
parent | dbe6a700ab81ca464328c354f715b6d787879334 (diff) | |
download | mongo-d8cc94168fbf759f053937d1b545afa82ce4d4d7.tar.gz |
SERVER-32090 Powercycle - pymongo client args are overwritten
(cherry picked from commit f4b94fd2166358c779c27f0fb26677f4eedac41e)
Diffstat (limited to 'pytests')
-rwxr-xr-x | pytests/powertest.py | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/pytests/powertest.py b/pytests/powertest.py index cc929c62c32..d5d939aa494 100755 --- a/pytests/powertest.py +++ b/pytests/powertest.py @@ -1056,7 +1056,7 @@ def remote_handler(options, operations): port=options.port, options=options.mongod_options) - mongo_client_opts = get_mongo_client_args(options, host="localhost", port=options.port) + mongo_client_opts = get_mongo_client_args(host="localhost", port=options.port, options=options) # Perform the sequence of operations specified. If any operation fails # then return immediately. @@ -1297,21 +1297,23 @@ def wait_for_mongod_shutdown(data_dir, timeout=120): return 0 -def get_mongo_client_args(options, host=None, port=None): +def get_mongo_client_args(host=None, port=None, options=None): """ Returns keyword arg dict used in PyMongo client. """ - # Set the serverSelectionTimeoutMS to 600 seconds - mongo_args = {"serverSelectionTimeoutMS": 600000} - # Set the serverSelectionTimeoutMS to 120 seconds - mongo_args["socketTimeoutMS"] = 120000 - # Set the writeConcern - mongo_args = yaml.safe_load(options.write_concern) - # Set the readConcernLevel - if options.read_concern_level: - mongo_args["readConcernLevel"] = options.read_concern_level + # Set the serverSelectionTimeoutMS & socketTimeoutMS to 10 minutes + mongo_args = { + "serverSelectionTimeoutMS": 600000, + "socketTimeoutMS": 600000 + } if host: mongo_args["host"] = host if port: mongo_args["port"] = port + # Set the writeConcern + if hasattr(options, "write_concern"): + mongo_args.update(yaml.safe_load(options.write_concern)) + # Set the readConcernLevel + if hasattr(options, "read_concern_level") and options.read_concern_level: + mongo_args["readConcernLevel"] = options.read_concern_level return mongo_args @@ -2265,7 +2267,7 @@ Examples: # Optionally validate canary document locally. if validate_canary_local: mongo = pymongo.MongoClient( - **get_mongo_client_args(options, host=mongod_host, port=secret_port)) + **get_mongo_client_args(host=mongod_host, port=secret_port)) ret = mongo_validate_canary( mongo, options.db_name, options.collection_name, canary_doc) LOGGER.info("Local canary validation: %d", ret) @@ -2379,7 +2381,7 @@ Examples: canary_doc = {"x": time.time()} orig_canary_doc = copy.deepcopy(canary_doc) mongo = pymongo.MongoClient( - **get_mongo_client_args(options, host=mongod_host, port=standard_port)) + **get_mongo_client_args(host=mongod_host, port=standard_port)) crash_canary["function"] = mongo_insert_canary crash_canary["args"] = [ mongo, |