summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2018-06-26 18:26:41 -0400
committerJonathan Abrahams <jonathan@mongodb.com>2018-07-02 11:47:09 -0400
commitac99fe1f00339897b162d41625982298ba4eb34c (patch)
treea99ddd44aebcf02a48e1f6a020c58b9ef840f64d
parentf0158ae28bc36522be55143866c51d0893c916de (diff)
downloadmongo-ac99fe1f00339897b162d41625982298ba4eb34c.tar.gz
SERVER-35588 powertest.py should call replSetReconfigure command only after successful replSetGetConfig
(cherry picked from commit 0fdc2e40994c930a97aa213fa990423616bc5268)
-rwxr-xr-xpytests/powertest.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/pytests/powertest.py b/pytests/powertest.py
index 3e8f11c03d8..f34c3b870ae 100755
--- a/pytests/powertest.py
+++ b/pytests/powertest.py
@@ -1502,7 +1502,20 @@ def mongo_reconfig_replication(mongo, host_port, repl_set):
if ret["ok"] != 1:
LOGGER.error("Failed replSetGetConfig: %s", ret)
return 1
+
+ rs_config = ret["config"]
+ # We only reconfig if there is a change to 'host'.
+ if rs_config["members"][0]["host"] != host_port:
+ # With force=True, version is ignored.
+ # rs_config["version"] = rs_config["version"] + 1
+ rs_config["members"][0]["host"] = host_port
+ ret = mongo.admin.command("replSetReconfig", rs_config, force=True)
+ if ret["ok"] != 1:
+ LOGGER.error("Failed replSetReconfig: %s", ret)
+ return 1
+ LOGGER.info("Replication reconfigured: %s", ret)
break
+
except pymongo.errors.AutoReconnect:
pass
except pymongo.errors.OperationFailure as err:
@@ -1510,19 +1523,7 @@ def mongo_reconfig_replication(mongo, host_port, repl_set):
if err.code != 94:
LOGGER.error("Replication failed to initialize: %s", ret)
return 1
- rs_config = ret["config"]
- # We only reconfig if there is a change to 'host'.
- if rs_config["members"][0]["host"] != host_port:
- # With force=True, version is ignored.
- # rs_config["version"] = rs_config["version"] + 1
- rs_config["members"][0]["host"] = host_port
- while True:
- try:
- ret = mongo.admin.command("replSetReconfig", rs_config, force=True)
- break
- except pymongo.errors.AutoReconnect:
- pass
- LOGGER.info("Replication reconfigured: %s", ret)
+
primary_available = mongod_wait_for_primary(mongo)
LOGGER.debug("isMaster: %s", mongo.admin.command("isMaster"))
LOGGER.debug("replSetGetStatus: %s", mongo.admin.command("replSetGetStatus"))