From 437ecc57f958072878bba9972dccec3a84defd1a Mon Sep 17 00:00:00 2001 From: Ronnie Smith Date: Tue, 25 Aug 2020 13:56:02 -0700 Subject: [PATCH] bugfix: Use replica set config instead of rs0 --- lib/storage/metadata/mongoclient/LogConsumer.js | 5 +++-- .../storage/metadata/mongoclient/MongoClientInterface.js | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/storage/metadata/mongoclient/LogConsumer.js b/lib/storage/metadata/mongoclient/LogConsumer.js index 243216208..4a065beca 100644 --- a/lib/storage/metadata/mongoclient/LogConsumer.js +++ b/lib/storage/metadata/mongoclient/LogConsumer.js @@ -17,9 +17,10 @@ class LogConsumer { * @param {string} logger - logger */ constructor(mongoConfig, logger) { - const { authCredentials, replicaSetHosts, database } = mongoConfig; + const { authCredentials, replicaSetHosts, replicaSet, database } = mongoConfig; const cred = MongoUtils.credPrefix(authCredentials); this._mongoUrl = `mongodb://${cred}${replicaSetHosts}/`; + this._replicaSet = replicaSet; this._logger = logger; this._oplogNsRegExp = new RegExp(`^${database}\\.`); // oplog collection @@ -36,7 +37,7 @@ class LogConsumer { */ connectMongo(done) { MongoClient.connect(this._mongoUrl, { - replicaSet: 'rs0', + replicaSet: this._replicaSet, useNewUrlParser: true, }, (err, client) => { diff --git a/tests/unit/storage/metadata/mongoclient/MongoClientInterface.js b/tests/unit/storage/metadata/mongoclient/MongoClientInterface.js index 803e49666..3a8d4ebd9 100644 --- a/tests/unit/storage/metadata/mongoclient/MongoClientInterface.js +++ b/tests/unit/storage/metadata/mongoclient/MongoClientInterface.js @@ -14,7 +14,7 @@ const mongoserver = new MongoMemoryReplSet({ { port: 27018 }, ], replSet: { - name: 'rs0', + name: 'customSetName', count: 1, dbName, storageEngine: 'ephemeralForTest', @@ -471,7 +471,7 @@ describe('MongoClientInterface::getObjectMDStats', () => { const opts = { replicaSetHosts: 'localhost:27018', writeConcern: 'majority', - replicaSet: 'rs0', + replicaSet: 'customSetName', readPreference: 'primary', database: dbName, replicationGroupId: 'GR001',