summaryrefslogtreecommitdiff
path: root/jstests/sharding/primary_config_server_blackholed_from_mongos.js
diff options
context:
space:
mode:
authorclang-format-7.0.1 <adam.martin@10gen.com>2019-07-26 18:20:35 -0400
committerADAM David Alan Martin <adam.martin@10gen.com>2019-07-27 11:02:23 -0400
commit134a4083953270e8a11430395357fb70a29047ad (patch)
treedd428e1230e31d92b20b393dfdc17ffe7fa79cb6 /jstests/sharding/primary_config_server_blackholed_from_mongos.js
parent1e46b5049003f427047e723ea5fab15b5a9253ca (diff)
downloadmongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/sharding/primary_config_server_blackholed_from_mongos.js')
-rw-r--r--jstests/sharding/primary_config_server_blackholed_from_mongos.js112
1 files changed, 56 insertions, 56 deletions
diff --git a/jstests/sharding/primary_config_server_blackholed_from_mongos.js b/jstests/sharding/primary_config_server_blackholed_from_mongos.js
index a7cc266c1a2..674dc1f9235 100644
--- a/jstests/sharding/primary_config_server_blackholed_from_mongos.js
+++ b/jstests/sharding/primary_config_server_blackholed_from_mongos.js
@@ -1,75 +1,75 @@
// Ensures that if the primary config server is blackholed from the point of view of mongos, CRUD
// and read-only config operations continue to work.
(function() {
- 'use strict';
+'use strict';
- var st = new ShardingTest({shards: 2, mongos: 1, useBridge: true});
+var st = new ShardingTest({shards: 2, mongos: 1, useBridge: true});
- var testDB = st.s.getDB('BlackHoleDB');
- var configDB = st.s.getDB('config');
+var testDB = st.s.getDB('BlackHoleDB');
+var configDB = st.s.getDB('config');
- assert.commandWorked(testDB.adminCommand({enableSharding: 'BlackHoleDB'}));
- assert.commandWorked(
- testDB.adminCommand({shardCollection: testDB.ShardedColl.getFullName(), key: {_id: 1}}));
+assert.commandWorked(testDB.adminCommand({enableSharding: 'BlackHoleDB'}));
+assert.commandWorked(
+ testDB.adminCommand({shardCollection: testDB.ShardedColl.getFullName(), key: {_id: 1}}));
- var bulk = testDB.ShardedColl.initializeUnorderedBulkOp();
- for (var i = 0; i < 1000; i++) {
- bulk.insert({_id: i});
- }
- assert.writeOK(bulk.execute());
+var bulk = testDB.ShardedColl.initializeUnorderedBulkOp();
+for (var i = 0; i < 1000; i++) {
+ bulk.insert({_id: i});
+}
+assert.writeOK(bulk.execute());
- const configPrimary = st.configRS.getPrimary();
- const admin = configPrimary.getDB("admin");
+const configPrimary = st.configRS.getPrimary();
+const admin = configPrimary.getDB("admin");
- // Set the priority and votes to 0 for secondary config servers so that in the case
- // of an election, they cannot step up. If a different node were to step up, the
- // config server would no longer be blackholed from mongos.
- let conf = admin.runCommand({replSetGetConfig: 1}).config;
- for (let i = 0; i < conf.members.length; i++) {
- if (conf.members[i].host !== configPrimary.host) {
- conf.members[i].votes = 0;
- conf.members[i].priority = 0;
- }
+// Set the priority and votes to 0 for secondary config servers so that in the case
+// of an election, they cannot step up. If a different node were to step up, the
+// config server would no longer be blackholed from mongos.
+let conf = admin.runCommand({replSetGetConfig: 1}).config;
+for (let i = 0; i < conf.members.length; i++) {
+ if (conf.members[i].host !== configPrimary.host) {
+ conf.members[i].votes = 0;
+ conf.members[i].priority = 0;
}
- conf.version++;
- const response = admin.runCommand({replSetReconfig: conf});
- assert.commandWorked(response);
+}
+conf.version++;
+const response = admin.runCommand({replSetReconfig: conf});
+assert.commandWorked(response);
- jsTest.log('Partitioning the config server primary from the mongos');
- configPrimary.discardMessagesFrom(st.s, 1.0);
- st.s.discardMessagesFrom(configPrimary, 1.0);
+jsTest.log('Partitioning the config server primary from the mongos');
+configPrimary.discardMessagesFrom(st.s, 1.0);
+st.s.discardMessagesFrom(configPrimary, 1.0);
- assert.commandWorked(testDB.adminCommand({flushRouterConfig: 1}));
+assert.commandWorked(testDB.adminCommand({flushRouterConfig: 1}));
- // This should fail, because the primary is not available
- jsTest.log('Doing write operation on a new database and collection');
- assert.writeError(st.s.getDB('NonExistentDB')
- .TestColl.insert({_id: 0, value: 'This value will never be inserted'},
- {maxTimeMS: 15000}));
+// This should fail, because the primary is not available
+jsTest.log('Doing write operation on a new database and collection');
+assert.writeError(
+ st.s.getDB('NonExistentDB')
+ .TestColl.insert({_id: 0, value: 'This value will never be inserted'}, {maxTimeMS: 15000}));
- jsTest.log('Doing CRUD operations on the sharded collection');
- assert.eq(1000, testDB.ShardedColl.find().itcount());
- assert.writeOK(testDB.ShardedColl.insert({_id: 1000}));
- assert.eq(1001, testDB.ShardedColl.find().count());
+jsTest.log('Doing CRUD operations on the sharded collection');
+assert.eq(1000, testDB.ShardedColl.find().itcount());
+assert.writeOK(testDB.ShardedColl.insert({_id: 1000}));
+assert.eq(1001, testDB.ShardedColl.find().count());
- jsTest.log('Doing read operations on a config server collection');
+jsTest.log('Doing read operations on a config server collection');
- // Should fail due to primary read preference
- assert.throws(function() {
- configDB.chunks.find().itcount();
- });
- assert.throws(function() {
- configDB.chunks.find().count();
- });
- assert.throws(function() {
- configDB.chunks.aggregate().itcount();
- });
+// Should fail due to primary read preference
+assert.throws(function() {
+ configDB.chunks.find().itcount();
+});
+assert.throws(function() {
+ configDB.chunks.find().count();
+});
+assert.throws(function() {
+ configDB.chunks.aggregate().itcount();
+});
- // With secondary read pref config server reads should work
- st.s.setReadPref('secondary');
- assert.lt(0, configDB.chunks.find().itcount());
- assert.lt(0, configDB.chunks.find().count());
- assert.lt(0, configDB.chunks.aggregate().itcount());
+// With secondary read pref config server reads should work
+st.s.setReadPref('secondary');
+assert.lt(0, configDB.chunks.find().itcount());
+assert.lt(0, configDB.chunks.find().count());
+assert.lt(0, configDB.chunks.aggregate().itcount());
- st.stop();
+st.stop();
}());