diff options
author | Vesselina Ratcheva <vesselina.ratcheva@10gen.com> | 2018-02-14 17:19:14 -0500 |
---|---|---|
committer | Vesselina Ratcheva <vesselina.ratcheva@10gen.com> | 2018-02-21 10:38:49 -0500 |
commit | fdfce7f6c24a676bd9e3eef36d273c98a9bb59ab (patch) | |
tree | 2d1d2301b4b228f579cadd413f2517f060690196 | |
parent | 6df7ca5841e2ffa40354975323e410796d952382 (diff) | |
download | mongo-fdfce7f6c24a676bd9e3eef36d273c98a9bb59ab.tar.gz |
SERVER-32143 Remove test coverage for master-slave
43 files changed, 13 insertions, 2318 deletions
diff --git a/buildscripts/resmokeconfig/suites/master_slave.yml b/buildscripts/resmokeconfig/suites/master_slave.yml deleted file mode 100644 index eb3dfbc4ef3..00000000000 --- a/buildscripts/resmokeconfig/suites/master_slave.yml +++ /dev/null @@ -1,14 +0,0 @@ -test_kind: js_test - -selector: - roots: - - jstests/master_slave/*.js - exclude_files: - # Skip until SERVER-25618 is resolved. - - jstests/master_slave/block1.js - -executor: - config: - shell_options: - nodb: '' - readMode: commands diff --git a/buildscripts/resmokeconfig/suites/master_slave_auth.yml b/buildscripts/resmokeconfig/suites/master_slave_auth.yml deleted file mode 100644 index 4ba765fc9f0..00000000000 --- a/buildscripts/resmokeconfig/suites/master_slave_auth.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Section that is ignored by resmoke.py. -config_variables: -- &keyFile jstests/libs/authTestsKey -- &keyFileData Thiskeyisonlyforrunningthesuitewithauthenticationdontuseitinanytestsdirectly - -test_kind: js_test - -selector: - roots: - - jstests/master_slave/*.js - exclude_files: - # Skip any tests that run with auth explicitly. - - jstests/master_slave/*[aA]uth*.js - # Skip until SERVER-25618 is resolved. - - jstests/master_slave/block1.js - -executor: - config: - shell_options: - global_vars: - TestData: - auth: true - authMechanism: SCRAM-SHA-1 - keyFile: *keyFile - keyFileData: *keyFileData - nodb: '' - readMode: commands diff --git a/buildscripts/resmokeconfig/suites/master_slave_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/master_slave_jscore_passthrough.yml deleted file mode 100644 index a13a1bcfc19..00000000000 --- a/buildscripts/resmokeconfig/suites/master_slave_jscore_passthrough.yml +++ /dev/null @@ -1,34 +0,0 @@ -test_kind: js_test - -selector: - roots: - - jstests/core/**/*.js - exclude_files: - # These tests are not expected to pass with master-slave: - - jstests/core/dbadmin.js - - jstests/core/opcounters_write_cmd.js - - jstests/core/capped_update.js - - jstests/core/apply_ops1.js # Nested applyOps work differently in master/slave. - -executor: - archive: - hooks: - - CheckReplDBHash - - ValidateCollections - config: - shell_options: - eval: "testingReplication = true;" - readMode: commands - hooks: - # The CheckReplDBHash hook waits until all operations have replicated to and have been applied - # on the secondaries, so we run the ValidateCollections hook after it to ensure we're - # validating the entire contents of the collection. - - class: CheckReplDBHash - - class: ValidateCollections - - class: CleanEveryN - n: 20 - fixture: - class: MasterSlaveFixture - mongod_options: - set_parameters: - enableTestCommands: 1 diff --git a/buildscripts/resmokelib/testing/fixtures/masterslave.py b/buildscripts/resmokelib/testing/fixtures/masterslave.py deleted file mode 100644 index d63205363ef..00000000000 --- a/buildscripts/resmokelib/testing/fixtures/masterslave.py +++ /dev/null @@ -1,162 +0,0 @@ -""" -Master/slave fixture for executing JSTests against. -""" - -from __future__ import absolute_import - -import os.path - -import pymongo -import pymongo.errors - -from . import interface -from . import standalone -from ... import config -from ... import utils - - -class MasterSlaveFixture(interface.ReplFixture): - """ - Fixture which provides JSTests with a master/slave deployment to - run against. - """ - - def __init__(self, - logger, - job_num, - mongod_executable=None, - mongod_options=None, - master_options=None, - slave_options=None, - dbpath_prefix=None, - preserve_dbpath=False): - - interface.ReplFixture.__init__(self, logger, job_num, dbpath_prefix=dbpath_prefix) - - if "dbpath" in mongod_options: - raise ValueError("Cannot specify mongod_options.dbpath") - - self.mongod_executable = mongod_executable - self.mongod_options = utils.default_if_none(mongod_options, {}) - self.master_options = utils.default_if_none(master_options, {}) - self.slave_options = utils.default_if_none(slave_options, {}) - self.preserve_dbpath = preserve_dbpath - - self._dbpath_prefix = os.path.join(self._dbpath_prefix, config.FIXTURE_SUBDIR) - - self.master = None - self.slave = None - - def setup(self): - if self.master is None: - self.master = self._new_mongod_master() - self.master.setup() - - if self.slave is None: - self.slave = self._new_mongod_slave() - self.slave.setup() - - def await_ready(self): - self.master.await_ready() - self.slave.await_ready() - - # Do a replicated write to ensure that the slave has finished with its initial sync before - # starting to run any tests. - client = self.master.mongo_client() - - # Keep retrying this until it times out waiting for replication. - def insert_fn(remaining_secs): - remaining_millis = int(round(remaining_secs * 1000)) - write_concern = pymongo.WriteConcern(w=2, wtimeout=remaining_millis) - coll = client.resmoke.get_collection("await_ready", write_concern=write_concern) - coll.insert_one({"awaiting": "ready"}) - - try: - self.retry_until_wtimeout(insert_fn) - except pymongo.errors.WTimeoutError: - self.logger.info("Replication of write operation timed out.") - raise - - def _do_teardown(self): - running_at_start = self.is_running() - success = True # Still a success if nothing is running. - - if not running_at_start: - self.logger.info( - "Master-slave deployment was expected to be running in _do_teardown(), but wasn't.") - - if self.slave is not None: - if running_at_start: - self.logger.info("Stopping slave...") - - success = self.slave.teardown() - - if running_at_start: - self.logger.info("Successfully stopped slave.") - - if self.master is not None: - if running_at_start: - self.logger.info("Stopping master...") - - success = self.master.teardown() and success - - if running_at_start: - self.logger.info("Successfully stopped master.") - - return success - - def is_running(self): - return (self.master is not None and self.master.is_running() and - self.slave is not None and self.slave.is_running()) - - def get_primary(self): - return self.master - - def get_secondaries(self): - return [self.slave] - - def _new_mongod(self, mongod_logger, mongod_options): - """ - Returns a standalone.MongoDFixture with the specified logger and - options. - """ - return standalone.MongoDFixture(mongod_logger, - self.job_num, - mongod_executable=self.mongod_executable, - mongod_options=mongod_options, - preserve_dbpath=self.preserve_dbpath) - - def _new_mongod_master(self): - """ - Returns a standalone.MongoDFixture configured to be used as the - master of a master-slave deployment. - """ - - mongod_logger = self.logger.new_fixture_node_logger("master") - - mongod_options = self.mongod_options.copy() - mongod_options.update(self.master_options) - mongod_options["master"] = "" - mongod_options["dbpath"] = os.path.join(self._dbpath_prefix, "master") - return self._new_mongod(mongod_logger, mongod_options) - - def _new_mongod_slave(self): - """ - Returns a standalone.MongoDFixture configured to be used as the - slave of a master-slave deployment. - """ - - mongod_logger = self.logger.new_fixture_node_logger("slave") - - mongod_options = self.mongod_options.copy() - mongod_options.update(self.slave_options) - mongod_options["slave"] = "" - mongod_options["source"] = self.master.get_internal_connection_string() - mongod_options["dbpath"] = os.path.join(self._dbpath_prefix, "slave") - return self._new_mongod(mongod_logger, mongod_options) - - def get_internal_connection_string(self): - return self.master.get_internal_connection_string() - - def get_driver_connection_url(self): - return self.master.get_driver_connection_url() diff --git a/etc/evergreen.yml b/etc/evergreen.yml index 4cb74ca7b99..e6cb10f65ab 100644 --- a/etc/evergreen.yml +++ b/etc/evergreen.yml @@ -3376,17 +3376,6 @@ tasks: run_multiple_jobs: true - <<: *task_template - name: master_slave_jscore_passthrough - depends_on: - - name: jsCore - commands: - - func: "do setup" - - func: "run tests" - vars: - resmoke_args: --suites=master_slave_jscore_passthrough --storageEngine=wiredTiger - run_multiple_jobs: true - -- <<: *task_template name: replica_sets_jscore_passthrough depends_on: - name: jsCore @@ -3753,26 +3742,6 @@ tasks: run_multiple_jobs: true - <<: *task_template - name: master_slave - commands: - - func: "do setup" - - func: "run tests" - vars: - resmoke_args: --suites=master_slave --storageEngine=wiredTiger - run_multiple_jobs: true - -- <<: *task_template - name: master_slave_auth - depends_on: - - name: master_slave - commands: - - func: "do setup" - - func: "run tests" - vars: - resmoke_args: --suites=master_slave_auth --storageEngine=wiredTiger - run_multiple_jobs: true - -- <<: *task_template name: sasl commands: - func: "do setup" @@ -4769,9 +4738,6 @@ buildvariants: - name: replica_sets_auth - name: replica_sets_pv0 - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sharding - name: sharding_auth - name: slow1 @@ -4885,9 +4851,6 @@ buildvariants: - name: replica_sets_pv0 - name: retryable_writes_jscore_passthrough - name: retryable_writes_jscore_stepdown_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: serial_run - name: session_jscore_passthrough - name: sharded_causally_consistent_jscore_passthrough @@ -4953,8 +4916,6 @@ buildvariants: - name: jstestfuzz_concurrent_sharded - name: jstestfuzz_sharded - name: mongosTest - - name: master_slave - - name: master_slave_auth - name: linux-64-lsm stepback: false @@ -5004,8 +4965,6 @@ buildvariants: - name: concurrency_simultaneous - name: replica_sets - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_jscore_passthrough - name: sharding - name: slow1 - name: serial_run @@ -5082,9 +5041,6 @@ buildvariants: - name: replica_sets - name: replica_sets_auth - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sharding - name: sharding_auth - name: sharding_last_stable_mongos_and_mixed_shards @@ -5187,9 +5143,6 @@ buildvariants: - name: replica_sets - name: replica_sets_auth - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: powercycle - name: powercycle_fcv3.4 - name: powercycle_replication @@ -5281,9 +5234,6 @@ buildvariants: - name: replica_sets - name: replica_sets_auth - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sharding - name: sharding_auth - name: sharding_last_stable_mongos_and_mixed_shards @@ -5376,9 +5326,6 @@ buildvariants: - name: replica_sets - name: replica_sets_auth - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sharding - name: sharding_auth - name: slow1 @@ -5493,9 +5440,6 @@ buildvariants: - name: replica_sets - name: replica_sets_auth - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sharding - name: sharding_auth - name: slow1 @@ -5588,9 +5532,6 @@ buildvariants: - name: replica_sets_auth - name: replica_sets_pv0 - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sasl - name: sharded_collections_jscore_passthrough - name: sharding @@ -5668,8 +5609,6 @@ buildvariants: - name: bulk_gle_passthrough - name: replica_sets_auth - name: replica_sets_ese - - name: master_slave_auth - - name: master_slave - name: powercycle - name: sasl - name: sharding_auth @@ -5756,9 +5695,6 @@ buildvariants: - name: replica_sets - name: replica_sets_auth - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sharding - name: sharding_auth - name: sharding_last_stable_mongos_and_mixed_shards @@ -5830,8 +5766,6 @@ buildvariants: - name: jsCore_compatibility - name: jsCore_decimal - name: jsonSchema - - name: master_slave - - name: master_slave_jscore_passthrough - name: mongosTest - name: noPassthrough - name: noPassthroughWithMongod @@ -6092,7 +6026,6 @@ buildvariants: - name: read_concern_linearizable_passthrough - name: replica_sets_auth - name: replica_sets_jscore_passthrough - - name: master_slave_jscore_passthrough - name: sasl - name: sharding_auth distros: @@ -6173,8 +6106,6 @@ buildvariants: - name: jstestfuzz_sharded_causal_consistency - name: jstestfuzz_sharded_continuous_stepdown - name: jstestfuzz_sharded_session - - name: master_slave - - name: master_slave_jscore_passthrough - name: mongosTest - name: multiversion - name: multiversion_auth @@ -6314,8 +6245,6 @@ buildvariants: - name: jstestfuzz_sharded - name: jstestfuzz_sharded_causal_consistency - name: jstestfuzz_sharded_session - - name: master_slave - - name: master_slave_jscore_passthrough - name: mongosTest - name: noPassthroughWithMongod - name: noPassthrough @@ -6373,7 +6302,6 @@ buildvariants: - name: jsCore_decimal - name: mongosTest - name: replica_sets - - name: master_slave - name: tool - name: enterprise-osx-1010 @@ -6593,9 +6521,6 @@ buildvariants: - name: jstestfuzz_sharded_causal_consistency - name: jstestfuzz_sharded_continuous_stepdown - name: jstestfuzz_sharded_session - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: mongosTest - name: multiversion_auth - name: multiversion @@ -6761,9 +6686,6 @@ buildvariants: - name: jsCore_decimal - name: jsCore_minimum_batch_size - name: jsCore_op_query - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: mongosTest - name: multiversion_auth - name: multiversion @@ -6955,9 +6877,6 @@ buildvariants: - name: replica_sets - name: replica_sets_auth - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sharding - name: sharding_auth - name: slow1 @@ -7048,9 +6967,6 @@ buildvariants: - name: replica_sets - name: replica_sets_auth - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sharding - name: sharding_auth - name: slow1 @@ -7146,9 +7062,6 @@ buildvariants: - name: replica_sets_auth - name: replica_sets_pv0 - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sasl - name: sharded_collections_jscore_passthrough - name: sharding @@ -7253,9 +7166,6 @@ buildvariants: - name: replica_sets_auth - name: replica_sets_pv0 - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sasl - name: sharded_collections_jscore_passthrough - name: sharding @@ -7354,9 +7264,6 @@ buildvariants: - name: replica_sets_auth - name: replica_sets_pv0 - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sasl - name: sharded_collections_jscore_passthrough - name: sharding @@ -7732,9 +7639,6 @@ buildvariants: - name: replica_sets_auth - name: replica_sets_pv0 - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sasl - name: sharded_collections_jscore_passthrough - name: sharding @@ -7826,9 +7730,6 @@ buildvariants: - name: replica_sets - name: replica_sets_auth - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sharding - name: sharding_auth - name: sharding_last_stable_mongos_and_mixed_shards @@ -8022,9 +7923,6 @@ buildvariants: - name: replica_sets - name: replica_sets_auth - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sharding - name: sharding_auth - name: sharding_last_stable_mongos_and_mixed_shards @@ -8110,9 +8008,6 @@ buildvariants: - name: replica_sets - name: replica_sets_auth - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sharding - name: sharding_auth - name: sharding_last_stable_mongos_and_mixed_shards @@ -8250,9 +8145,6 @@ buildvariants: - name: replica_sets - name: replica_sets_auth - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sharding - name: sharding_auth - name: sharding_last_stable_mongos_and_mixed_shards @@ -8354,9 +8246,6 @@ buildvariants: - name: jstestfuzz_sharded - name: jstestfuzz_sharded_session - name: jstestfuzz_sharded_causal_consistency - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: mongosTest - name: noPassthrough - name: noPassthroughWithMongod @@ -8567,9 +8456,6 @@ buildvariants: - name: replica_sets_pv0 - name: replica_sets_jscore_passthrough - name: rollback_fuzzer - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sharding - name: sharding_auth - name: sharding_op_query @@ -8644,9 +8530,6 @@ buildvariants: - name: replica_sets_auth - name: replica_sets_pv0 - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sasl - name: sharded_collections_jscore_passthrough - name: sharding @@ -8734,9 +8617,6 @@ buildvariants: - name: replica_sets_auth - name: replica_sets_pv0 - name: replica_sets_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sasl - name: sharded_collections_jscore_passthrough - name: sharding @@ -8855,9 +8735,6 @@ buildvariants: - name: jsCore_minimum_batch_size - name: jsCore_op_query - name: jsonSchema - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: mongosTest - name: multiversion_auth - name: multiversion @@ -9014,9 +8891,6 @@ buildvariants: - name: jsCore_minimum_batch_size - name: jsCore_op_query - name: jsonSchema - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: mongosTest - name: multiversion_auth - name: multiversion @@ -9167,9 +9041,6 @@ buildvariants: - name: replica_sets_initsync_static_jscore_passthrough - name: replica_sets_resync_static_jscore_passthrough - name: replica_sets_kill_secondaries_jscore_passthrough - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: sasl - name: sharded_collections_jscore_passthrough - name: sharding @@ -9293,8 +9164,6 @@ buildvariants: - name: jstestfuzz_sharded_causal_consistency - name: jstestfuzz_sharded_continuous_stepdown - name: jstestfuzz_sharded_session - - name: master_slave - - name: master_slave_jscore_passthrough - name: mmap - name: multiversion - name: multiversion_auth @@ -9421,8 +9290,6 @@ buildvariants: - name: jstestfuzz_sharded_causal_consistency - name: jstestfuzz_sharded_continuous_stepdown - name: jstestfuzz_sharded_session - - name: master_slave - - name: master_slave_jscore_passthrough - name: mmap - name: noPassthrough - name: noPassthroughWithMongod @@ -9526,8 +9393,6 @@ buildvariants: - name: jstestfuzz_sharded_causal_consistency - name: jstestfuzz_sharded_continuous_stepdown - name: jstestfuzz_sharded_session - - name: master_slave - - name: master_slave_jscore_passthrough - name: mmap - name: noPassthrough - name: noPassthroughWithMongod @@ -9598,9 +9463,6 @@ buildvariants: - name: jstestfuzz_concurrent_sharded - name: jstestfuzz_replication - name: jstestfuzz_sharded - - name: master_slave - - name: master_slave_auth - - name: master_slave_jscore_passthrough - name: mmap - name: noPassthrough - name: noPassthroughWithMongod diff --git a/jstests/auth/repl.js b/jstests/auth/repl.js index d6a1a9ce6ec..06aa38a38a7 100644 --- a/jstests/auth/repl.js +++ b/jstests/auth/repl.js @@ -209,30 +209,3 @@ secondary = rs.getSecondary(); authReplTest.setSecondary(secondary); authReplTest.testAll(); rs.stopSet(); - -jsTest.log("3 test master/slave"); -var rt = new ReplTest(rtName); - -// start and stop without auth in order to ensure -// existence of the correct dbpath -var master = rt.start(true, {}, false, true); -rt.stop(true); -var slave = rt.start(false, {}, false, true); -rt.stop(false); - -// start master/slave with auth -master = rt.start(true, mongoOptions, true); -slave = rt.start(false, mongoOptions, true); -var masterDB = master.getDB("admin"); - -masterDB.createUser({user: "root", pwd: "pass", roles: ["root"]}); -masterDB.auth("root", "pass"); - -// ensure that master/slave replication is up and running -masterDB.foo.save({}, {writeConcern: {w: 2, wtimeout: 15000}}); -masterDB.foo.drop(); - -authReplTest = AuthReplTest({primaryConn: master, secondaryConn: slave}); -authReplTest.createUserAndRoles(2); -authReplTest.testAll(); -rt.stop(); diff --git a/jstests/concurrency/fsm_libs/cluster.js b/jstests/concurrency/fsm_libs/cluster.js index 287ea8b428e..025f862a34d 100644 --- a/jstests/concurrency/fsm_libs/cluster.js +++ b/jstests/concurrency/fsm_libs/cluster.js @@ -33,7 +33,6 @@ var Cluster = function(options) { function validateClusterOptions(options) { var allowedKeys = [ - 'masterSlave', 'replication.enabled', 'replication.numNodes', 'sameCollection', @@ -57,9 +56,6 @@ var Cluster = function(options) { tojson(allowedKeys)); }); - options.masterSlave = options.masterSlave || false; - assert.eq('boolean', typeof options.masterSlave); - options.replication = options.replication || {}; assert.eq('object', typeof options.replication); @@ -169,11 +165,6 @@ var Cluster = function(options) { 'Expected teardownFunctions.config to be an array'); assert(options.teardownFunctions.config.every(f => (typeof f === 'function')), 'Expected teardownFunctions.config to be an array of functions'); - - assert(!options.masterSlave || !options.replication.enabled, - "Both 'masterSlave' and " + "'replication.enabled' cannot be true"); - assert(!options.masterSlave || !options.sharded.enabled, - "Both 'masterSlave' and 'sharded.enabled' cannot" + "be true"); } function makeReplSetTestConfig(numReplSetNodes) { @@ -318,24 +309,6 @@ var Cluster = function(options) { this._addReplicaSetConns(rst); - } else if (options.masterSlave) { - var rt = new ReplTest('replTest'); - - var master = rt.start(true); - var slave = rt.start(false); - conn = master; - - master.adminCommand({setParameter: 1, logLevel: verbosityLevel}); - slave.adminCommand({setParameter: 1, logLevel: verbosityLevel}); - - this.teardown = function teardown() { - options.teardownFunctions.mongod.forEach(this.executeOnMongodNodes); - - rt.stop(); - }; - - _conns.mongod = [master, slave]; - } else { // standalone server conn = db.getMongo(); db.adminCommand({setParameter: 1, logLevel: verbosityLevel}); @@ -716,8 +689,7 @@ var Cluster = function(options) { * and false otherwise. */ Cluster.isStandalone = function isStandalone(clusterOptions) { - return !clusterOptions.sharded.enabled && !clusterOptions.replication.enabled && - !clusterOptions.masterSlave; + return !clusterOptions.sharded.enabled && !clusterOptions.replication.enabled; }; /** diff --git a/jstests/core/compact_keeps_indexes.js b/jstests/core/compact_keeps_indexes.js index f2da7597cdf..897cfcd87de 100644 --- a/jstests/core/compact_keeps_indexes.js +++ b/jstests/core/compact_keeps_indexes.js @@ -25,26 +25,17 @@ assert.eq(coll.find({_id: 1}).itcount(), 1); assert.eq(coll.find({x: 1}).itcount(), 1); - // Run compact repeatedly while simultaneously creating and dropping a collection in a - // different database. - // Skip this test case in master/slave mode because of database cloning behavior in slaves. - // The test uses a single collection in the database test_compact_keeps_indexes_drop - // which triggers a series of slow resync operations in the slave as the collection is - // repeatedly created and dropped. - var isMasterSlave = - testingReplication && !assert.commandWorked(db.isMaster()).hasOwnProperty('setName'); - if (!isMasterSlave) { - var dropCollectionShell = startParallelShell(function() { - var t = db.getSiblingDB('test_compact_keeps_indexes_drop').testcoll; + var dropCollectionShell = startParallelShell(function() { + var t = db.getSiblingDB('test_compact_keeps_indexes_drop').testcoll; + t.drop(); + for (var i = 0; i < 100; i++) { + t.save({a: 1}); t.drop(); - for (var i = 0; i < 100; i++) { - t.save({a: 1}); - t.drop(); - } - }); - for (var i = 0; i < 10; i++) { - coll.runCommand('compact'); } - dropCollectionShell(); + }); + for (var i = 0; i < 10; i++) { + coll.runCommand('compact'); } + dropCollectionShell(); + }()); diff --git a/jstests/gle/block2.js b/jstests/gle/block2.js deleted file mode 100644 index ee2ad06c5e5..00000000000 --- a/jstests/gle/block2.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Basic gle testing for master/slave environment. Write command version also - * available at jstests/repl. - */ - -var rt = new ReplTest("block1"); - -var m = rt.start(true); -var s = rt.start(false); - -if (m.writeMode() == 'commands') { - jsTest.log('Skipping test since commands mode is already tested in repl/'); -} else { - function setup() { - dbm = m.getDB("foo"); - dbs = s.getDB("foo"); - - tm = dbm.bar; - ts = dbs.bar; - } - setup(); - - function check(msg) { - assert.eq(tm.count(), ts.count(), "check: " + msg); - } - - function worked(w, wtimeout) { - var gle = dbm.getLastError(w, wtimeout); - if (gle != null) { - printjson(gle); - } - return gle == null; - } - - check("A"); - - tm.save({x: 1}); - assert(worked(2), "B"); - - tm.save({x: 2}); - assert(worked(2, 3000), "C"); - - rt.stop(false); - tm.save({x: 3}); - assert.eq(3, tm.count(), "D1"); - assert(!worked(2, 3000), "D2"); - - s = rt.start(false); - setup(); - assert(worked(2, 5 * 60 * 1000), "E"); -} - -rt.stop(); diff --git a/jstests/hooks/run_check_repl_dbhash.js b/jstests/hooks/run_check_repl_dbhash.js index 06e626ba5cd..7e09c7ca6c8 100644 --- a/jstests/hooks/run_check_repl_dbhash.js +++ b/jstests/hooks/run_check_repl_dbhash.js @@ -6,100 +6,6 @@ load('jstests/libs/discover_topology.js'); // For Topology and DiscoverTopology. load('jstests/libs/parallelTester.js'); // For ScopedThread. - // A thin wrapper around master/slave nodes that provides methods necessary for checking data - // consistency between the master and slave nodes. - // - // DEPRECATED: This wrapper is only intended to be used for the master-slave deployment started - // by resmoke.py as part of the master_slave_jscore_passthrough.yml test suite and it shouldn't - // be used for any other master/slave tests. - // - // TODO SERVER-32143: Remove this wrapper. - function MasterSlaveDBHashTest(primaryHost) { - const master = new Mongo(primaryHost); - const masterPort = master.host.split(':')[1]; - const slave = new Mongo('localhost:' + String(parseInt(masterPort) + 1)); - - this.nodeList = function nodeList() { - return [master.host, slave.host]; - }; - - this.getHashes = function getHashes(db) { - const combinedRes = {}; - let res = master.getDB(db).runCommand('dbhash'); - assert.commandWorked(res); - combinedRes.master = res; - - res = slave.getDB(db).runCommand('dbhash'); - assert.commandWorked(res); - combinedRes.slaves = [res]; - - return combinedRes; - }; - - this.getPrimary = function getPrimary() { - slave.setSlaveOk(); - this.liveNodes = {master: master, slaves: [slave]}; - return master; - }; - - this.getSecondaries = function getSecondaries() { - return [slave]; - }; - - this.awaitReplication = function awaitReplication() { - assert.commandWorked(master.adminCommand({fsyncUnlock: 1}), - 'failed to unlock the primary'); - - print('Starting fsync on master to flush all pending writes'); - assert.commandWorked(master.adminCommand({fsync: 1})); - print('fsync on master completed'); - - const kTimeout = 5 * 60 * 1000; // 5 minute timeout - const dbNames = master.getDBNames(); - - for (let dbName of dbNames) { - if (dbName === 'local') { - continue; - } - - print('Awaiting replication of inserts into ' + dbName); - assert.writeOK(master.getDB(dbName).await_repl.insert( - {awaiting: 'repl'}, {writeConcern: {w: 2, wtimeout: kTimeout}}), - 'Awaiting replication failed'); - } - print('Finished awaiting replication'); - assert.commandWorked(master.adminCommand({fsync: 1, lock: 1}), - 'failed to re-lock the primary'); - }; - - this.checkReplicatedDataHashes = function checkReplicatedDataHashes() { - const msgPrefix = 'checkReplicatedDataHashes for master-slave deployment'; - const excludedDBs = jsTest.options().excludedDBsFromDBHash || []; - - // Since UUIDs aren't explicitly replicated in master-slave deployments, we ignore the - // UUID in the output of the 'listCollections' command to avoid reporting a known data - // inconsistency issue from checkReplicatedDataHashes(). - const ignoreUUIDs = true; - - new ReplSetTest({ - nodes: 0 - }).checkReplicatedDataHashes.call(this, msgPrefix, excludedDBs, ignoreUUIDs); - }; - - this.checkReplicaSet = function checkReplicaSet() { - new ReplSetTest({nodes: 0}).checkReplicaSet.apply(this, arguments); - }; - - this.dumpOplog = function dumpOplog() { - print('Not dumping oplog for master-slave deployment'); - }; - } - - function isMasterSlaveDeployment(conn) { - const cmdLineOpts = assert.commandWorked(conn.adminCommand({getCmdLineOpts: 1})); - return cmdLineOpts.parsed.master === true; - } - function checkReplicatedDataHashesThread(hosts, testData) { try { TestData = testData; @@ -116,12 +22,6 @@ let skipped = false; try { const conn = db.getMongo(); - - if (isMasterSlaveDeployment(conn)) { - new MasterSlaveDBHashTest(conn.host).checkReplicatedDataHashes(); - return; - } - const topology = DiscoverTopology.findConnectedNodes(conn); if (topology.type === Topology.kStandalone) { diff --git a/jstests/hooks/run_check_repl_oplogs.js b/jstests/hooks/run_check_repl_oplogs.js index a2875d61150..0e0ebadc897 100644 --- a/jstests/hooks/run_check_repl_oplogs.js +++ b/jstests/hooks/run_check_repl_oplogs.js @@ -3,11 +3,6 @@ 'use strict'; (function() { - // Master/Slave does not support oplog test, since the oplog.$main is empty on the Slave. - var MasterSlaveOplogTest = function() { - throw new Error('checkOplogs not supported for Master/Slave'); - }; - var startTime = Date.now(); assert.neq(typeof db, 'undefined', 'No `db` object, is the shell connected to a mongod?'); @@ -18,9 +13,7 @@ var cmdLineOpts = db.adminCommand('getCmdLineOpts'); assert.commandWorked(cmdLineOpts); - var isMasterSlave = cmdLineOpts.parsed.master === true; - var testFixture = - isMasterSlave ? new MasterSlaveOplogTest() : new ReplSetTest(db.getMongo().host); + var testFixture = new ReplSetTest(db.getMongo().host); testFixture.checkOplogs(); var totalTime = Date.now() - startTime; diff --git a/jstests/hooks/run_initial_sync_node_validation.js b/jstests/hooks/run_initial_sync_node_validation.js index 769409c534d..3ae954fe057 100644 --- a/jstests/hooks/run_initial_sync_node_validation.js +++ b/jstests/hooks/run_initial_sync_node_validation.js @@ -11,8 +11,6 @@ var cmdLineOpts = db.adminCommand('getCmdLineOpts'); assert.commandWorked(cmdLineOpts); - var isMasterSlave = cmdLineOpts.parsed.master === true; - assert(!isMasterSlave, 'Master/Slave is not supported with initial sync hooks'); // The initial sync hooks only work for replica sets. var rst = new ReplSetTest(db.getMongo().host); diff --git a/jstests/master_slave/basic1.js b/jstests/master_slave/basic1.js deleted file mode 100644 index ff286b23721..00000000000 --- a/jstests/master_slave/basic1.js +++ /dev/null @@ -1,173 +0,0 @@ - -// test repl basics -// data on master/slave is the same - -var rt = new ReplTest("basic1"); - -m = rt.start(true); -s = rt.start(false); - -function block() { - am.runCommand({getlasterror: 1, w: 2, wtimeout: 3000}); -} - -am = m.getDB("foo"); -as = s.getDB("foo"); - -function check(note) { - var start = new Date(); - var x, y; - while ((new Date()).getTime() - start.getTime() < 30000) { - x = am.runCommand("dbhash"); - y = as.runCommand("dbhash"); - if (x.md5 == y.md5) - return; - sleep(200); - } - lastOpLogEntry = - m.getDB("local").oplog.$main.find({op: {$ne: "n"}}).sort({$natural: -1}).limit(-1).next(); - note = note + tojson(am.a.find().toArray()) + " != " + tojson(as.a.find().toArray()) + - "last oplog:" + tojson(lastOpLogEntry); - assert.eq(x.md5, y.md5, note); -} - -am.a.save({x: 1}); -check("A"); - -am.a.save({x: 5}); - -am.a.update({}, {$inc: {x: 1}}); -check("B"); - -am.a.update({}, {$inc: {x: 1}}, false, true); -check("C"); - -// ----- check features ------- - -// map/reduce -assert.writeOK(am.mr.insert({tags: ["a"]})); -assert.writeOK(am.mr.insert({tags: ["a", "b"]})); -check("mr setup"); - -m = function() { - for (var i = 0; i < this.tags.length; i++) { - print("\t " + i); - emit(this.tags[i], 1); - } -}; - -r = function(key, v) { - return Array.sum(v); -}; - -correct = { - a: 2, - b: 1 -}; - -function checkMR(t) { - var res = t.mapReduce(m, r, {out: {inline: 1}}); - assert.eq(correct, res.convertToSingleObject(), "checkMR: " + tojson(t)); -} - -function checkNumCollections(msg, diff) { - if (!diff) - diff = 0; - var m = am.getCollectionNames(); - var s = as.getCollectionNames(); - assert.eq(m.length + diff, s.length, msg + " lengths bad \n" + tojson(m) + "\n" + tojson(s)); -} - -checkNumCollections("MR1"); -checkMR(am.mr); -checkMR(as.mr); -checkNumCollections("MR2"); - -block(); -checkNumCollections("MR3"); - -var res = am.mr.mapReduce(m, r, {out: "xyz"}); -block(); - -checkNumCollections("MR4"); - -var t = am.rpos; -var writeOption = {writeConcern: {w: 2, wtimeout: 3000}}; -t.insert({_id: 1, a: [{n: "a", c: 1}, {n: "b", c: 1}, {n: "c", c: 1}], b: [1, 2, 3]}, writeOption); -check("after pos 1 "); - -t.update({"a.n": "b"}, {$inc: {"a.$.c": 1}}, writeOption); -check("after pos 2 "); - -t.update({b: 2}, {$inc: {"b.$": 1}}, writeOption); -check("after pos 3 "); - -t.update({b: 3}, {$set: {"b.$": 17}}, writeOption); -check("after pos 4 "); - -printjson(am.rpos.findOne()); -printjson(as.rpos.findOne()); - -// am.getSisterDB( "local" ).getCollection( "oplog.$main" ).find().limit(10).sort( { $natural : -1 } -// ).forEach( printjson ) - -t = am.b; -var updateOption = {upsert: true, multi: false, writeConcern: {w: 2, wtimeout: 3000}}; -t.update({_id: "fun"}, {$inc: {"a.b.c.x": 6743}}, updateOption); -check("b 1"); - -t.update({_id: "fun"}, {$inc: {"a.b.c.x": 5}}, updateOption); -check("b 2"); - -t.update({_id: "fun"}, {$inc: {"a.b.c.x": 100, "a.b.c.y": 911}}, updateOption); -assert.eq({_id: "fun", a: {b: {c: {x: 6848, y: 911}}}}, as.b.findOne(), "b 3"); -check("b 4"); - -// lots of indexes - -am.lotOfIndexes.insert({x: 1}); -for (i = 0; i < 200; i++) { - var idx = {}; - idx["x" + i] = 1; - am.lotOfIndexes.ensureIndex(idx); -} - -assert.soon(function() { - return am.lotOfIndexes.getIndexes().length == as.lotOfIndexes.getIndexes().length; -}, "lots of indexes a"); - -assert.eq( - am.lotOfIndexes.getIndexes().length, as.lotOfIndexes.getIndexes().length, "lots of indexes b"); - -// multi-update with $inc - -am.mu1.update({_id: 1, $atomic: 1}, {$inc: {x: 1}}, true, true); -x = { - _id: 1, - x: 1 -}; -assert.eq(x, am.mu1.findOne(), "mu1"); -assert.soon(function() { - z = as.mu1.findOne(); - printjson(z); - return friendlyEqual(x, z); -}, "mu2"); - -// profiling - this should be last - -am.setProfilingLevel(2); -am.foo.insert({x: 1}, writeOption); -am.foo.findOne(); -assert.eq(2, am.system.profile.count(), "P1"); -assert.eq(0, as.system.profile.count(), "P2"); - -assert.eq(1, as.foo.findOne().x, "P3"); -assert.eq(0, as.system.profile.count(), "P4"); - -assert(as.getCollectionNames().indexOf("system.profile") < 0, "P4.5"); - -as.setProfilingLevel(2); -as.foo.findOne(); -assert.eq(1, as.system.profile.count(), "P5"); - -rt.stop(); diff --git a/jstests/master_slave/batch_write_command_wc_repl.js b/jstests/master_slave/batch_write_command_wc_repl.js deleted file mode 100644 index 167182ed6ae..00000000000 --- a/jstests/master_slave/batch_write_command_wc_repl.js +++ /dev/null @@ -1,71 +0,0 @@ -// -// Tests write-concern-related batch write protocol functionality for master/slave replication -// More general write concern tests in replsets/batch_write_command_wc.js -// - -var request; -var result; - -// NOTE: ALL TESTS BELOW SHOULD BE SELF-CONTAINED, FOR EASIER DEBUGGING - -jsTest.log("Starting legacy repl tests..."); - -// Start a master node -// Allows testing legacy repl failures -var mongod = MongoRunner.runMongod({master: "", oplogSize: 40, smallfiles: ""}); -var coll = mongod.getCollection("test.batch_write_command_wc_repl"); - -// -// Basic insert, default WC -coll.remove({}); -printjson(request = { - insert: coll.getName(), - documents: [{a: 1}] -}); -printjson(result = coll.runCommand(request)); -assert(result.ok); -assert.eq(1, result.n); -assert.eq(1, coll.count()); - -// -// Basic insert, majority WC -coll.remove({}); -printjson(request = { - insert: coll.getName(), - documents: [{a: 1}], - writeConcern: {w: 'majority'} -}); -printjson(result = coll.runCommand(request)); -assert(result.ok); -assert.eq(1, result.n); -assert.eq(1, coll.count()); - -// -// Basic insert, immediate bad wMode error -coll.remove({}); -printjson(request = { - insert: coll.getName(), - documents: [{a: 1}], - writeConcern: {w: 'invalid'} -}); -printjson(result = coll.runCommand(request)); -assert(!result.ok); -assert.eq(0, coll.count()); - -// -// Basic insert, error on WC with wtimeout -coll.remove({}); -printjson(request = { - insert: coll.getName(), - documents: [{a: 1}], - writeConcern: {w: 2, wtimeout: 1} -}); -printjson(result = coll.runCommand(request)); -assert(result.ok); -assert.eq(1, result.n); -assert(result.writeConcernError); -assert(result.writeConcernError.errInfo.wtimeout); -assert.eq(1, coll.count()); - -jsTest.log("DONE legacy repl tests"); -MongoRunner.stopMongod(mongod); diff --git a/jstests/master_slave/block1.js b/jstests/master_slave/block1.js deleted file mode 100644 index ab427270340..00000000000 --- a/jstests/master_slave/block1.js +++ /dev/null @@ -1,19 +0,0 @@ - -var rt = new ReplTest("block1"); - -m = rt.start(true); -s = rt.start(false); - -dbm = m.getDB("foo"); -dbs = s.getDB("foo"); - -tm = dbm.bar; -ts = dbs.bar; - -for (var i = 0; i < 1000; i++) { - tm.insert({_id: i}, {writeConcern: {w: 2}}); - assert.eq(i + 1, ts.count(), "A" + i); - assert.eq(i + 1, tm.count(), "B" + i); -} - -rt.stop(); diff --git a/jstests/master_slave/block2.js b/jstests/master_slave/block2.js deleted file mode 100644 index 6b6e1357aec..00000000000 --- a/jstests/master_slave/block2.js +++ /dev/null @@ -1,29 +0,0 @@ - -var rt = new ReplTest("block1"); - -m = rt.start(true); -s = rt.start(false); - -function setup() { - dbm = m.getDB("foo"); - dbs = s.getDB("foo"); - - tm = dbm.bar; - ts = dbs.bar; -} -setup(); - -function check(msg) { - assert.eq(tm.count(), ts.count(), "check: " + msg); -} - -check("A"); - -assert.writeOK(tm.insert({x: 1}, {writeConcern: {w: 2, wtimeout: ReplTest.kDefaultTimeoutMS}})); -assert.writeOK(tm.insert({x: 2}, {writeConcern: {w: 2, wtimeout: ReplTest.kDefaultTimeoutMS}})); - -rt.stop(false); -assert.writeError(tm.insert({x: 3}, {writeConcern: {w: 2, wtimeout: 3000}})); -assert.eq(3, tm.count(), "D1"); - -rt.stop(); diff --git a/jstests/master_slave/initial_sync_id_index.js b/jstests/master_slave/initial_sync_id_index.js deleted file mode 100644 index 0b15a04be71..00000000000 --- a/jstests/master_slave/initial_sync_id_index.js +++ /dev/null @@ -1,48 +0,0 @@ -// Tests that the _id index spec is copied exactly during initial sync. -(function() { - "use strict"; - - load("jstests/libs/get_index_helpers.js"); - - const rt = new ReplTest(); - const master = rt.start(true); - const masterDB = master.getDB("test"); - - // Create a collection with a v=2 _id index. - assert.commandWorked( - masterDB.createCollection("collV2", {idIndex: {key: {_id: 1}, name: "_id_", v: 2}})); - let spec = GetIndexHelpers.findByName(masterDB.collV2.getIndexes(), "_id_"); - assert.neq(spec, null); - assert.eq(spec.v, 2); - - // Create a collection with a v=1 _id index. - assert.commandWorked( - masterDB.createCollection("collV1", {idIndex: {key: {_id: 1}, name: "_id_", v: 1}})); - spec = GetIndexHelpers.findByName(masterDB.collV1.getIndexes(), "_id_"); - assert.neq(spec, null); - assert.eq(spec.v, 1); - - // Initial sync a slave. - const slave = rt.start(false); - const slaveDB = slave.getDB("test"); - - // Wait for the slave to sync the collections. - assert.soon(function() { - var res = slaveDB.runCommand({listCollections: 1, filter: {name: "collV2"}}); - return res.cursor.firstBatch.length === 1; - }, "Collection with v:2 _id index failed to sync on slave"); - assert.soon(function() { - var res = slaveDB.runCommand({listCollections: 1, filter: {name: "collV1"}}); - return res.cursor.firstBatch.length === 1; - }, "Collection with v:1 _id index failed to sync on slave"); - - // Check _id index versions on slave. - spec = GetIndexHelpers.findByName(slaveDB.collV2.getIndexes(), "_id_"); - assert.neq(spec, null); - assert.eq(spec.v, 2); - spec = GetIndexHelpers.findByName(slaveDB.collV1.getIndexes(), "_id_"); - assert.neq(spec, null); - assert.eq(spec.v, 1); - - rt.stop(); -})();
\ No newline at end of file diff --git a/jstests/master_slave/initial_sync_wc2.js b/jstests/master_slave/initial_sync_wc2.js deleted file mode 100644 index abcc490f781..00000000000 --- a/jstests/master_slave/initial_sync_wc2.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This test ensures that the w:2 write correctly waits until initial sync is done. - * Before SERVER-25618 the w:2 write could return during initial sync since the slave reported - * progress during initial sync. - */ -var rt = new ReplTest("initial_sync_wc2"); - -// The database name needs to be at the top of the list or at least before the "test" db. -var dbToCloneName = "a_toclone"; - -// Start the master and insert some data to ensure that the slave has to clone a database. -var master = rt.start(true); -assert.writeOK(master.getDB(dbToCloneName).mycoll.insert({a: 1})); -assert.eq(1, master.getDB(dbToCloneName).mycoll.find({}).itcount()); - -// Start the slave. -var slave = rt.start(false); - -// Perform a w=2 write to ensure that slave can be read from, and initial sync is complete. -assert.writeOK(master.getDB("test").mycoll.insert({}, {writeConcern: {w: 2}})); -assert.eq(1, slave.getDB("test").mycoll.find({}).itcount()); -rt.stop();
\ No newline at end of file diff --git a/jstests/master_slave/master1.js b/jstests/master_slave/master1.js deleted file mode 100644 index 2292a061939..00000000000 --- a/jstests/master_slave/master1.js +++ /dev/null @@ -1,55 +0,0 @@ -// Test handling of clock skew and optimes across mongod instances -// -// There is no automatic fail-over in a master/slave deployment, so if the master goes down, no new -// master will be elected. Therefore if the master is using an ephemeral storage engine, it cannot -// be restarted without losing all data. This test expects that restarting the master will maintain -// the node's data, so cannot be run with ephemeral storage engines. -// @tags: [requires_persistence] - -var baseName = "jstests_repl_master1test"; - -oplog = function() { - return m.getDB("local").oplog.$main; -}; - -lastop = function() { - return oplog().find().sort({$natural: -1}).next(); -}; - -am = function() { - return m.getDB(baseName).a; -}; - -rt = new ReplTest(baseName); - -m = rt.start(true); - -am().save({}); -assert.eq("i", lastop().op); - -op = lastop(); -printjson(op); -op.ts.t = op.ts.t + 600000; // 10 minutes -assert.commandWorked(m.getDB("local").runCommand({godinsert: "oplog.$main", obj: op})); - -rt.stop(true); -m = rt.start(true, null, true); - -assert.eq(op.ts.t, lastop().ts.t, tojson({lastop: lastop()})); -am().save({}); -assert.eq(op.ts.t, lastop().ts.t); -assert.eq(op.ts.i + 1, lastop().ts.i); - -op = lastop(); -printjson(op); -op.ts.i = Math.pow(2, 31) - 1; -printjson(op); -assert.commandWorked(m.getDB("local").runCommand({godinsert: "oplog.$main", obj: op})); - -rt.stop(true); -m = rt.start(true, null, true); -assert.eq(op.ts.i, lastop().ts.i); - -am().save({}); - -assert.eq(0, rt.stop(true)); diff --git a/jstests/master_slave/mod_move.js b/jstests/master_slave/mod_move.js deleted file mode 100644 index 2ec8996dce3..00000000000 --- a/jstests/master_slave/mod_move.js +++ /dev/null @@ -1,58 +0,0 @@ - -// test repl basics -// data on master/slave is the same - -var rt = new ReplTest("mod_move"); - -m = rt.start(true, {oplogSize: 50}); - -am = m.getDB("foo"); - -function check(note) { - var start = new Date(); - var x, y; - while ((new Date()).getTime() - start.getTime() < 5 * 60 * 1000) { - x = am.runCommand("dbhash"); - y = as.runCommand("dbhash"); - if (x.md5 == y.md5) - return; - sleep(200); - } - assert.eq(x.md5, y.md5, note); -} - -// insert a lot of 'big' docs -// so when we delete them the small docs move here - -BIG = 100000; -N = BIG * 2; - -var bulk = am.a.initializeUnorderedBulkOp(); -for (var i = 0; i < BIG; i++) { - bulk.insert({_id: i, s: 1, x: 1}); -} -for (; i < N; i++) { - bulk.insert({_id: i, s: 1}); -} -for (i = 0; i < BIG; i++) { - bulk.find({_id: i}).remove(); -} -assert.writeOK(bulk.execute()); -assert.eq(BIG, am.a.count()); - -if (am.serverStatus().storageEngine.name == "mmapv1") { - assert.eq(1, am.a.stats().paddingFactor, "A2"); -} - -// start slave -s = rt.start(false); -as = s.getDB("foo"); -bulk = am.a.initializeUnorderedBulkOp(); -for (i = N - 1; i >= BIG; i--) { - bulk.find({_id: i}).update({$set: {x: 1}}); -} -assert.writeOK(bulk.execute()); - -check("B"); - -rt.stop(); diff --git a/jstests/master_slave/repair.js b/jstests/master_slave/repair.js deleted file mode 100644 index bb5185d326a..00000000000 --- a/jstests/master_slave/repair.js +++ /dev/null @@ -1,15 +0,0 @@ -// Test repair on master - -var baseName = "jstests_repl_repair"; - -rt = new ReplTest(baseName); - -m = rt.start(true); - -m.getDB(baseName)[baseName].save({}); -var c = m.getDB('local').oplog.$main.count(); -assert.automsg("c > 0"); - -assert.commandWorked(m.getDB("local").repairDatabase()); -assert.automsg("c <= m.getDB( 'local' ).oplog.$main.count()"); -rt.stop();
\ No newline at end of file diff --git a/jstests/master_slave/repl1.js b/jstests/master_slave/repl1.js deleted file mode 100644 index ea8f85a6260..00000000000 --- a/jstests/master_slave/repl1.js +++ /dev/null @@ -1,64 +0,0 @@ -// Test basic replication functionality -// -// There is no automatic fail-over in a master/slave deployment, so if the master goes down, no new -// master will be elected. Therefore if the master is using an ephemeral storage engine, it cannot -// be restarted without losing all data. This test expects that restarting the master will maintain -// the node's data, so cannot be run with ephemeral storage engines. -// @tags: [requires_persistence] - -var baseName = "jstests_repl1test"; - -soonCount = function(count) { - assert.soon(function() { - // print( "check count" ); - // print( "count: " + s.getDB( baseName ).z.find().count() ); - return s.getDB(baseName).a.find().count() == count; - }); -}; - -doTest = function(signal) { - - rt = new ReplTest("repl1tests"); - - m = rt.start(true); - s = rt.start(false); - - am = m.getDB(baseName).a; - - for (i = 0; i < 1000; ++i) - am.save({_id: new ObjectId(), i: i}); - - soonCount(1000); - as = s.getDB(baseName).a; - assert.eq(1, as.find({i: 0}).count()); - assert.eq(1, as.find({i: 999}).count()); - - rt.stop(false, signal); - - for (i = 1000; i < 1010; ++i) - am.save({_id: new ObjectId(), i: i}); - - s = rt.start(false, null, true); - soonCount(1010); - as = s.getDB(baseName).a; - assert.eq(1, as.find({i: 1009}).count()); - - rt.stop(true, signal); - - m = rt.start(true, null, true); - am = m.getDB(baseName).a; - - for (i = 1010; i < 1020; ++i) - am.save({_id: new ObjectId(), i: i}); - - assert.soon(function() { - return as.find().count() == 1020; - }); - assert.eq(1, as.find({i: 1019}).count()); - - assert.automsg("m.getDB( 'local' ).getCollection( 'oplog.$main' ).stats().size > 0"); - - rt.stop(); -}; - -doTest(15); // SIGTERM diff --git a/jstests/master_slave/repl10.js b/jstests/master_slave/repl10.js deleted file mode 100644 index 10a05d3131a..00000000000 --- a/jstests/master_slave/repl10.js +++ /dev/null @@ -1,41 +0,0 @@ -// Test slave delay -(function() { - "use strict"; - - var baseName = "jstests_repl10test"; - - var soonCount = function(s, count) { - assert.soon(function() { - // print( "check count" ); - // print( "count: " + s.getDB( baseName ).z.find().count() ); - return s.getDB(baseName).a.find().count() == count; - }); - }; - - var doTest = function(signal) { - - var rt = new ReplTest("repl10tests"); - - var m = rt.start(true); - var s = rt.start(false, {"slavedelay": "30"}); - - var am = m.getDB(baseName).a; - - am.save({i: 1}); - - soonCount(s, 1); - - am.save({i: 2}); - assert.eq(2, am.count()); - sleep(2000); - assert.eq(1, s.getDB(baseName).a.count()); - - soonCount(s, 2); - - rt.stop(); - }; - - print("repl10.js dotest(15)"); - doTest(15); // SIGTERM - print("repl10.js SUCCESS"); -}()); diff --git a/jstests/master_slave/repl12.js b/jstests/master_slave/repl12.js deleted file mode 100644 index c3adac0ddbe..00000000000 --- a/jstests/master_slave/repl12.js +++ /dev/null @@ -1,51 +0,0 @@ -// SERVER-1626 -// check for initial sync of multiple db's - -function debug(x) { - print("DEBUG:" + tojson(x)); -} - -rt = new ReplTest("repl12tests"); - -m = rt.start(true); - -usedDBs = []; - -a = "a"; -for (i = 0; i < 3; ++i) { - usedDBs.push(a); - m.getDB(a).c.save({}); - a += "a"; -} - -// print("\n\n\n DB NAMES MASTER:"); -// printjson(m.getDBNames()); - -var z = 10500; -print("sleeping " + z + "ms"); -sleep(z); - -s = rt.start(false); - -function countHave() { - var have = 0; - for (var i = 0; i < usedDBs.length; i++) { - if (s.getDB(usedDBs[i]).c.findOne()) - have++; - } - return have; -} - -assert.soon(function() { - try { - var c = countHave(); - debug("count: " + c); - return c == 3; - } catch (e) { - printjson(e); - return false; - } -}); - -// printjson(s.getDBNames()); -rt.stop();
\ No newline at end of file diff --git a/jstests/master_slave/repl13.js b/jstests/master_slave/repl13.js deleted file mode 100644 index b892de8a3d4..00000000000 --- a/jstests/master_slave/repl13.js +++ /dev/null @@ -1,66 +0,0 @@ -// Test update modifier uassert during initial sync. SERVER-4781 -var debuggingEnabled = false; - -function debug(x) { - if (debuggingEnabled) { - printjson(x); - } -} - -rt = new ReplTest("repl13tests"); - -m = rt.start(true); -mc = m.getDB('d')['c']; - -// Insert some documents with a:{} fields. -var bulk = mc.initializeUnorderedBulkOp(); -for (var i = 0; i < 100000; ++i) { - bulk.insert({_id: i, a: {}}); -} -assert.writeOK(bulk.execute()); - -s = rt.start(false); -sc = s.getDB('d')['c']; - -// Wait for the initial clone to begin. -assert.soon(function() { - debug(sc.count()); - return sc.count() > 0; -}); - -// Update documents that will be cloned last with the intent that an updated version will be cloned. -// This may cause an assertion when an update that was successfully applied to the original version -// of a document is replayed against an updated version of the same document. -bulk = mc.initializeUnorderedBulkOp(); -for (i = 99999; i >= 90000; --i) { - // If the document is cloned as {a:1}, the {$set:{'a.b':1}} modifier will uassert. - bulk.find({_id: i}).update({$set: {'a.b': 1}}); - bulk.find({_id: i}).update({$set: {a: 1}}); -} -assert.writeOK(bulk.execute()); - -// The initial sync completes and subsequent writes succeed, in spite of any assertions that occur -// when the update operations above are replicated. -mc.save({}); -assert.eq(100001, mc.count()); -assert.soon(function() { - return sc.count() == 100001; -}); -mc.save({}); -assert.eq(100002, mc.count()); -assert.soon(function() { - return sc.count() == 100002; -}); - -debug(sc.findOne({_id: 99999})); -debug(sc.findOne({_id: 90000})); - -assert.eq(1, sc.findOne({_id: 99999}).a); -assert.eq(1, sc.findOne({_id: 90000}).a); - -m_hash = m.getDB("d").runCommand("dbhash"); -s_hash = s.getDB("d").runCommand("dbhash"); - -assert.eq( - m_hash.collections.c, s_hash.collections.c, "sad " + tojson(m_hash) + " " + tojson(s_hash)); -rt.stop();
\ No newline at end of file diff --git a/jstests/master_slave/repl14.js b/jstests/master_slave/repl14.js deleted file mode 100644 index e897d9376f1..00000000000 --- a/jstests/master_slave/repl14.js +++ /dev/null @@ -1,68 +0,0 @@ -// Test replication of an array by $push-ing to a missing field in the presence of a sparse index on -// the field. SERVER-4907 - -function testWithCollectionIndexIds(capped, sparse, useIds) { - printjson({capped: capped, sparse: sparse, useIds: useIds}); - - rt = new ReplTest("repl14tests"); - - m = rt.start(true); // master - if (capped) { - m.getDB('d').createCollection('c', {capped: true, size: 5 * 1024}); - } - mc = m.getDB('d')['c']; // master collection - - mc.ensureIndex({a: 1}, {sparse: sparse}); - toInsert = {}; - if (capped) { - // Add a singleton array as padding, so the push later on will not change document size. - toInsert = {p: [1]}; - } - if (useIds) { // Insert wiith an auto generated _id. - mc.insert(toInsert); - } else { // Otherwise avoid the auto generated _id. - mc._mongo.insert(mc._fullName, toInsert, 0); - } - assert.eq(mc.count(), 1); - - s = rt.start(false); // slave - sc = s.getDB('d')['c']; // slave collection - - // Wait for the document to be cloned. - assert.soon(function() { - return sc.count() > 0; - }, "doc not replicated soon enough", 60 * 1000); - - modifiers = {$push: {a: 1}}; - if (capped) { - // Delete our singleton array to balance the new singleton array we're going to create. - modifiers['$unset'] = {p: 1}; - } - assert.writeOK(mc.update({}, modifiers)); - - // Wait for the update to be replicated. - assert.soon(function() { - return sc.count({a: 1}) > 0; - }); - - rt.stop(); -} - -function testWithCollectionIndex(capped, sparse) { - testWithCollectionIndexIds(capped, sparse, true); - if (capped) { - testWithCollectionIndexIds(capped, sparse, false); - } -} - -function testWithCollection(capped) { - testWithCollectionIndex(capped, true); - testWithCollectionIndex(capped, false); -} - -function test() { - testWithCollection(true); - testWithCollection(false); -} - -test(); diff --git a/jstests/master_slave/repl16.js b/jstests/master_slave/repl16.js deleted file mode 100644 index 84d0073eff8..00000000000 --- a/jstests/master_slave/repl16.js +++ /dev/null @@ -1,40 +0,0 @@ -// Test deduping of new documents without an _id index -// SERVER-14132 - -if (0) { - function doTest(insert) { - rt = new ReplTest("repl16tests"); - master = rt.start(true); - master.getDB('d').createCollection('c', {capped: true, size: 5 * 1024, autoIndexId: false}); - mc = master.getDB('d')['c']; - - insert({_id: 1}); - insert({_id: 2}); - - slave = rt.start(false); - sc = slave.getDB('d')['c']; - - // Wait for the slave to copy the documents. - assert.soon(function() { - return sc.count() == 2; - }); - - insert({_id: 1}); - insert({_id: 2}); - insert({_id: 3}); - assert.eq(5, mc.count()); - - // Wait for the slave to apply the operations. - assert.soon(function() { - return sc.count() == 5; - }); - - rt.stop(); - } - - function insertWithIds(obj) { - mc.insert(obj); - } - - doTest(insertWithIds); -} diff --git a/jstests/master_slave/repl2.js b/jstests/master_slave/repl2.js deleted file mode 100644 index 4c0bc468e4d..00000000000 --- a/jstests/master_slave/repl2.js +++ /dev/null @@ -1,69 +0,0 @@ -// Test resync command: -// 1. Start master/slave deployment. -// 2. Insert a document to seed the oplog. -// 3. Assert that the resync command fails when the slave is caught up to the master. -// 4. Stop the slave. -// 5. Insert enough documents to rotate the oplog. -// 6. Restart the slave. -// 7. Assert the resync command now works on the slave. -// 8. Assert the slave eventually has the same data. -// 9. Assert the slave now rejects the resync command. -// -// This test cannot be run on ephemeral storage engines, because after restarting, at step 6, the -// slave will not have any data and will start an initial sync, rejecting the resync command. -// @tags: [requires_persistence] - -soonCount = function(count) { - assert.soon(function() { - // print( "check count" ); - // print( "count: " + s.getDB( baseName ).z.find().count() ); - return s.getDB("foo").a.find().count() == count; - }); -}; - -doTest = function(signal, extraOpts) { - print("signal: " + signal); - - var rt = new ReplTest("repl2tests"); - - // implicit small oplog makes slave get out of sync - m = rt.start(true, {oplogSize: "1"}); - s = rt.start(false, extraOpts); - - am = m.getDB("foo").a; - - am.save({_id: new ObjectId()}); - soonCount(1); - assert.eq(0, s.getDB("admin").runCommand({"resync": 1}).ok); - rt.stop(false, signal); - - big = new Array(2000).toString(); - for (i = 0; i < 1000; ++i) - am.save({_id: new ObjectId(), i: i, b: big}); - - s = rt.start(false, extraOpts, true); - - print("earliest op in master: " + - tojson(m.getDB("local").oplog.$main.find().sort({$natural: 1}).limit(1).next())); - print("latest op on slave: " + tojson(s.getDB("local").sources.findOne())); - - assert.soon(function() { - var result = s.getDB("admin").runCommand({"resync": 1}); - print("resync says: " + tojson(result)); - return result.ok == 1; - }); - - soonCount(1001); - assert.automsg("m.getDB( 'local' ).getCollection( 'oplog.$main' ).stats().size > 0"); - - as = s.getDB("foo").a; - assert.eq(1, as.find({i: 0}).count()); - assert.eq(1, as.find({i: 999}).count()); - - assert.eq(0, s.getDB("admin").runCommand({"resync": 1}).ok); - - rt.stop(); - -}; - -doTest(15, {"vv": null}); // SIGTERM diff --git a/jstests/master_slave/repl3.js b/jstests/master_slave/repl3.js deleted file mode 100644 index ce1c355342f..00000000000 --- a/jstests/master_slave/repl3.js +++ /dev/null @@ -1,51 +0,0 @@ -// Test autoresync - -var baseName = "jstests_repl3test"; - -soonCount = function(count) { - assert.soon(function() { - // print( "check count" ); - // print( "count: " + s.getDB( baseName ).z.find().count() + ", expected: " + - // count ); - return s.getDB(baseName).a.find().itcount() == count; - }); -}; - -doTest = function(signal) { - - print("repl3.js doTest(" + signal + ")"); - - rt = new ReplTest("repl3tests"); - - m = rt.start(true); - s = rt.start(false); - - am = m.getDB(baseName).a; - - am.save({_id: new ObjectId()}); - soonCount(1); - rt.stop(false, signal); - - big = new Array(2000).toString(); - for (i = 0; i < 1000; ++i) - am.save({_id: new ObjectId(), i: i, b: big}); - - s = rt.start(false, {autoresync: null}, true); - - // after SyncException, mongod waits 10 secs. - sleep(15000); - - // Need the 2 additional seconds timeout, since commands don't work on an 'allDead' node. - soonCount(1001); - as = s.getDB(baseName).a; - assert.eq(1, as.find({i: 0}).count()); - assert.eq(1, as.find({i: 999}).count()); - - assert.commandFailed(s.getDB("admin").runCommand({"resync": 1})); - - rt.stop(); -}; - -doTest(15); // SIGTERM - -print("repl3.js OK"); diff --git a/jstests/master_slave/repl4.js b/jstests/master_slave/repl4.js deleted file mode 100644 index e28986e1573..00000000000 --- a/jstests/master_slave/repl4.js +++ /dev/null @@ -1,41 +0,0 @@ -// Test replication 'only' mode - -soonCount = function(db, coll, count) { - assert.soon(function() { - return s.getDB(db)[coll].find().count() == count; - }); -}; - -doTest = function() { - - rt = new ReplTest("repl4tests"); - - m = rt.start(true); - s = rt.start(false, {only: "c"}); - - cm = m.getDB("c").c; - bm = m.getDB("b").b; - - cm.save({x: 1}); - bm.save({x: 2}); - - soonCount("c", "c", 1); - assert.eq(1, s.getDB("c").c.findOne().x); - sleep(10000); - printjson(s.getDBNames()); - assert.eq(-1, s.getDBNames().indexOf("b")); - assert.eq(0, s.getDB("b").b.find().count()); - - rt.stop(false); - - cm.save({x: 3}); - bm.save({x: 4}); - - s = rt.start(false, {only: "c"}, true); - soonCount("c", "c", 2); -}; - -// Disabled because of SERVER-10344 -if (false) { - doTest(); -} diff --git a/jstests/master_slave/repl5.js b/jstests/master_slave/repl5.js deleted file mode 100644 index 45d07b35da5..00000000000 --- a/jstests/master_slave/repl5.js +++ /dev/null @@ -1,38 +0,0 @@ -// Test auto reclone after failed initial clone - -soonCountAtLeast = function(db, coll, count) { - assert.soon(function() { - try { - // print( "count: " + s.getDB( db )[ coll ].find().count() ); - return s.getDB(db)[coll].find().itcount() >= count; - } catch (e) { - return false; - } - }); -}; - -doTest = function(signal, extraOpts) { - - rt = new ReplTest("repl5tests"); - - m = rt.start(true); - - // Use a database that lexicographically follows "admin" to avoid failing to clone admin, since - // as of SERVER-29452 mongod fails to start up without a featureCompatibilityVersion document. - ma = m.getDB("b").a; - var bulk = ma.initializeUnorderedBulkOp(); - for (i = 0; i < 100000; ++i) - bulk.insert({i: i}); - assert.writeOK(bulk.execute()); - - s = rt.start(false, extraOpts); - soonCountAtLeast("b", "a", 1); - rt.stop(false, signal); - - s = rt.start(false, extraOpts, true); - soonCountAtLeast("b", "a", 10000); - - rt.stop(); -}; - -doTest(15); // SIGTERM diff --git a/jstests/master_slave/repl6.js b/jstests/master_slave/repl6.js deleted file mode 100644 index c9ccdbdd559..00000000000 --- a/jstests/master_slave/repl6.js +++ /dev/null @@ -1,82 +0,0 @@ -// Test one master replicating to two slaves -// -// There is no automatic fail-over in a master/slave deployment, so if the master goes down, no new -// master will be elected. Therefore if the master is using an ephemeral storage engine, it cannot -// be restarted without losing all data. This test expects that restarting the master will maintain -// the node's data, so cannot be run with ephemeral storage engines. -// @tags: [requires_persistence] - -var baseName = "jstests_repl6test"; - -soonCount = function(m, count) { - assert.soon(function() { - return m.getDB(baseName).a.find().count() == count; - }, "expected count: " + count + " from : " + m); -}; - -doTest = function(signal) { - - ports = allocatePorts(3); - - ms1 = new ReplTest("repl6tests-1", [ports[0], ports[1]]); - ms2 = new ReplTest("repl6tests-2", [ports[0], ports[2]]); - - m = ms1.start(true); - s1 = ms1.start(false); - s2 = ms2.start(false); - - am = m.getDB(baseName).a; - - for (i = 0; i < 1000; ++i) - am.save({_id: new ObjectId(), i: i}); - - soonCount(s1, 1000); - soonCount(s2, 1000); - - check = function(as) { - assert.eq(1, as.find({i: 0}).count()); - assert.eq(1, as.find({i: 999}).count()); - }; - - as = s1.getDB(baseName).a; - check(as); - as = s2.getDB(baseName).a; - check(as); - - ms1.stop(false, signal); - ms2.stop(false, signal); - - for (i = 1000; i < 1010; ++i) - am.save({_id: new ObjectId(), i: i}); - - s1 = ms1.start(false, null, true); - soonCount(s1, 1010); - as = s1.getDB(baseName).a; - assert.eq(1, as.find({i: 1009}).count()); - - ms1.stop(true, signal); - - // Need to pause here on Windows, since killing processes does not synchronously close their - // open file handles. - sleep(5000); - - m = ms1.start(true, null, true); - am = m.getDB(baseName).a; - - for (i = 1010; i < 1020; ++i) - am.save({_id: new ObjectId(), i: i}); - - soonCount(s1, 1020); - assert.eq(1, as.find({i: 1019}).count()); - - s2 = ms2.start(false, null, true); - soonCount(s2, 1020); - as = s2.getDB(baseName).a; - assert.eq(1, as.find({i: 1009}).count()); - assert.eq(1, as.find({i: 1019}).count()); - - ms1.stop(); - ms2.stop(false); -}; - -doTest(15); // SIGTERM diff --git a/jstests/master_slave/repl7.js b/jstests/master_slave/repl7.js deleted file mode 100644 index 3ed91b6aed3..00000000000 --- a/jstests/master_slave/repl7.js +++ /dev/null @@ -1,56 +0,0 @@ -// Test persistence of list of dbs to add. - -var getDBNamesNoThrow = function(conn) { - try { - return conn.getDBNames(); - } catch (e) { - printjson(e); - return [""]; - } -}; - -doTest = function(signal, extraOpts) { - - rt = new ReplTest("repl7tests"); - - m = rt.start(true); - - // Use databases that lexicographically follow "admin" to avoid failing to clone admin, since - // as of SERVER-29452 mongod fails to start up without a featureCompatibilityVersion document. - for (n = "b"; n != "bbbbb"; n += "b") { - m.getDB(n).b.save({x: 1}); - } - - s = rt.start(false, extraOpts); - - assert.soon(function() { - return -1 != getDBNamesNoThrow(s).indexOf("bb"); - }, "bb timeout", 60000, 1000); - - rt.stop(false, signal); - - s = rt.start(false, extraOpts, signal); - - assert.soon(function() { - for (n = "b"; n != "bbbbb"; n += "b") { - if (-1 == getDBNamesNoThrow(s).indexOf(n)) - return false; - } - return true; - }, "b-bbbb timeout", 60000, 1000); - - assert.soon(function() { - for (n = "b"; n != "bbbbb"; n += "b") { - if (1 != m.getDB(n).b.find().count()) { - return false; - } - } - return true; - }, "b-bbbb count timeout"); - - sleep(300); - - rt.stop(); -}; - -doTest(15); // SIGTERM diff --git a/jstests/master_slave/repl8.js b/jstests/master_slave/repl8.js deleted file mode 100644 index ec0ea50317f..00000000000 --- a/jstests/master_slave/repl8.js +++ /dev/null @@ -1,44 +0,0 @@ -// Test cloning of capped collections - -baseName = "jstests_repl_repl8"; - -rt = new ReplTest("repl8tests"); - -m = rt.start(true); - -m.getDB(baseName).createCollection("first", {capped: true, size: 1000}); -assert(m.getDB(baseName).getCollection("first").isCapped()); - -s = rt.start(false); - -assert.soon(function() { - return s.getDB(baseName).getCollection("first").isCapped(); -}); - -m.getDB(baseName).createCollection("second", {capped: true, size: 1000}); -assert.soon(function() { - return s.getDB(baseName).getCollection("second").isCapped(); -}); - -m.getDB(baseName).getCollection("third").save({a: 1}); -assert.soon(function() { - return s.getDB(baseName).getCollection("third").exists(); -}); -assert.commandWorked(m.getDB("admin").runCommand( - {renameCollection: "jstests_repl_repl8.third", to: "jstests_repl_repl8.third_rename"})); -assert(m.getDB(baseName).getCollection("third_rename").exists()); -assert(!m.getDB(baseName).getCollection("third").exists()); -assert.soon(function() { - return s.getDB(baseName).getCollection("third_rename").exists(); -}); -assert.soon(function() { - return !s.getDB(baseName).getCollection("third").exists(); -}); - -m.getDB(baseName).getCollection("fourth").save({a: 1}); -assert.commandWorked(m.getDB(baseName).getCollection("fourth").convertToCapped(1000)); -assert(m.getDB(baseName).getCollection("fourth").isCapped()); -assert.soon(function() { - return s.getDB(baseName).getCollection("fourth").isCapped(); -}); -rt.stop();
\ No newline at end of file diff --git a/jstests/master_slave/repl9.js b/jstests/master_slave/repl9.js deleted file mode 100644 index 8bdabc93d0f..00000000000 --- a/jstests/master_slave/repl9.js +++ /dev/null @@ -1,61 +0,0 @@ -// Test replication of collection renaming - -baseName = "jstests_repl_repl9"; - -rt = new ReplTest("repl9tests"); - -m = rt.start(true); -s = rt.start(false); - -admin = m.getDB("admin"); - -debug = function(foo) {}; // print( foo ); } - -// rename within db - -m.getDB(baseName).one.save({a: 1}); -assert.soon(function() { - v = s.getDB(baseName).one.findOne(); - return v && 1 == v.a; -}); - -assert.commandWorked( - admin.runCommand({renameCollection: "jstests_repl_repl9.one", to: "jstests_repl_repl9.two"})); -assert.soon(function() { - if (-1 == s.getDB(baseName).getCollectionNames().indexOf("two")) { - debug("no two coll"); - debug(tojson(s.getDB(baseName).getCollectionNames())); - return false; - } - if (!s.getDB(baseName).two.findOne()) { - debug("no two object"); - return false; - } - return 1 == s.getDB(baseName).two.findOne().a; -}); -assert.eq(-1, s.getDB(baseName).getCollectionNames().indexOf("one")); - -// rename to new db - -first = baseName + "_first"; -second = baseName + "_second"; - -m.getDB(first).one.save({a: 1}); -assert.soon(function() { - return s.getDB(first).one.findOne() && 1 == s.getDB(first).one.findOne().a; -}); - -assert.commandWorked(admin.runCommand( - {renameCollection: "jstests_repl_repl9_first.one", to: "jstests_repl_repl9_second.two"})); -assert.soon(function() { - return -1 != s.getDBNames().indexOf(second) && - -1 != s.getDB(second).getCollectionNames().indexOf("two") && - s.getDB(second).two.findOne() && 1 == s.getDB(second).two.findOne().a; -}); - -// Renaming a collection across databases is replicated as multiple operations so we have to wait -// for source collection drop to be applied on the slave. -assert.soon(function() { - return -1 == s.getDB(first).getCollectionNames().indexOf("one"); -}); -rt.stop();
\ No newline at end of file diff --git a/jstests/master_slave/repl_sync_only_db_with_special_chars.js b/jstests/master_slave/repl_sync_only_db_with_special_chars.js deleted file mode 100644 index 1daaf1abe85..00000000000 --- a/jstests/master_slave/repl_sync_only_db_with_special_chars.js +++ /dev/null @@ -1,25 +0,0 @@ - -doTest = function() { - - var rt = new ReplTest("repl_sync_only_db_with_special_chars"); - var normalDB = "abc"; - var specialDB = "[a-z]+"; - var master = rt.start(true); - var slave = rt.start(false, {only: specialDB}); - - master.getDB(normalDB).data.save({a: 1}); - master.getDB(specialDB).data.save({z: 1}); - - assert.soon(function() { - var normalDocs = slave.getDB(normalDB).data.find().count(); - var specialDocs = slave.getDB(specialDB).data.find().count(); - - return normalDocs == 0 && specialDocs == 1; - }, "Failed to only sync to " + specialDB); - -}; - -// Disabled because of SERVER-10344 -if (false) { - doTest(); -} diff --git a/jstests/master_slave/snapshot1.js b/jstests/master_slave/snapshot1.js deleted file mode 100644 index 50e552f418c..00000000000 --- a/jstests/master_slave/snapshot1.js +++ /dev/null @@ -1,47 +0,0 @@ -// Test SERVER-623 - starting slave from a new snapshot -// -// This test requires persistence because it assumes copying the dbpath with copy the data between -// nodes. There should not be any data in the dbpath for ephemeral storage engines, so this will not -// work. It also requires the fsync command to enduce replication lag. -// @tags: [requires_persistence, requires_fsync] - -ports = allocatePorts(3); - -var baseName = "repl_snapshot1"; - -rt1 = new ReplTest("repl_snapshot1-1", [ports[0], ports[1]]); -rt2 = new ReplTest("repl_snapshot1-2", [ports[0], ports[2]]); -m = rt1.start(true); - -big = new Array(2000).toString(); -for (i = 0; i < 1000; ++i) - m.getDB(baseName)[baseName].save({_id: new ObjectId(), i: i, b: big}); - -m.getDB("admin").runCommand({fsync: 1, lock: 1}); -copyDbpath(rt1.getPath(true), rt1.getPath(false)); -m.getDB("admin").fsyncUnlock(); - -s1 = rt1.start(false, null, true); -assert.eq(1000, s1.getDB(baseName)[baseName].count()); -m.getDB(baseName)[baseName].save({i: 1000}); -assert.soon(function() { - return 1001 == s1.getDB(baseName)[baseName].count(); -}); - -s1.getDB("admin").runCommand({fsync: 1, lock: 1}); -copyDbpath(rt1.getPath(false), rt2.getPath(false)); -s1.getDB("admin").fsyncUnlock(); - -s2 = rt2.start(false, null, true); -assert.eq(1001, s2.getDB(baseName)[baseName].count()); -m.getDB(baseName)[baseName].save({i: 1001}); -assert.soon(function() { - return 1002 == s2.getDB(baseName)[baseName].count(); -}); -assert.soon(function() { - return 1002 == s1.getDB(baseName)[baseName].count(); -}); - -assert(!rawMongoProgramOutput().match(/resync/)); -rt1.stop(); -rt2.stop();
\ No newline at end of file diff --git a/jstests/noPassthrough/global_operation_latency_histogram.js b/jstests/noPassthrough/global_operation_latency_histogram.js index 31aaa532fa6..33cb7f0897e 100644 --- a/jstests/noPassthrough/global_operation_latency_histogram.js +++ b/jstests/noPassthrough/global_operation_latency_histogram.js @@ -5,7 +5,7 @@ "use strict"; var name = "operationalLatencyHistogramTest"; - var mongo = MongoRunner.runMongod({master: ""}); + var mongo = MongoRunner.runMongod(); var testDB = mongo.getDB("test"); var testColl = testDB[name + "coll"]; diff --git a/jstests/parallel/repl.js b/jstests/parallel/repl.js deleted file mode 100644 index b952f7c77a1..00000000000 --- a/jstests/parallel/repl.js +++ /dev/null @@ -1,63 +0,0 @@ -// test basic operations in parallel, with replication -// @tags: [requires_replication] -load('jstests/libs/parallelTester.js'); - -baseName = "parallel_repl"; - -rt = new ReplTest(baseName); - -m = rt.start(true); -s = rt.start(false); - -// tests need to run against master server -db = m.getDB("test"); -host = db.getMongo().host; - -Random.setRandomSeed(); - -t = new ParallelTester(); - -for (id = 0; id < 10; ++id) { - var g = new EventGenerator(id, baseName, Random.randInt(20), host); - for (var j = 0; j < 1000; ++j) { - var op = Random.randInt(3); - switch (op) { - case 0: // insert - g.addInsert({_id: Random.randInt(1000)}); - break; - case 1: // remove - g.addRemove({_id: Random.randInt(1000)}); - break; - case 2: // update - g.addUpdate({_id: {$lt: 1000}}, {$inc: {a: 5}}); - break; - default: - assert(false, "Invalid op code"); - } - } - t.add(EventGenerator.dispatch, g.getEvents()); -} - -var g = new EventGenerator(id, baseName, Random.randInt(5), host); -for (var j = 1000; j < 3000; ++j) { - g.addCheckCount(j - 1000, {_id: {$gte: 1000}}, j % 100 == 0, j % 500 == 0); - g.addInsert({_id: j}); -} -t.add(EventGenerator.dispatch, g.getEvents()); - -t.run("one or more tests failed"); - -masterValidation = m.getDB("test")[baseName].validate(); -assert(masterValidation.valid, tojson(masterValidation)); - -slaveValidation = s.getDB("test")[baseName].validate(); -assert(slaveValidation.valid, tojson(slaveValidation)); - -assert.soon(function() { - mh = m.getDB("test").runCommand("dbhash"); - // printjson( mh ); - sh = s.getDB("test").runCommand("dbhash"); - // printjson( sh ); - return mh.md5 == sh.md5; -}); -rt.stop();
\ No newline at end of file diff --git a/src/mongo/db/catalog/database_test.cpp b/src/mongo/db/catalog/database_test.cpp index d81392f1972..ec9c876f245 100644 --- a/src/mongo/db/catalog/database_test.cpp +++ b/src/mongo/db/catalog/database_test.cpp @@ -237,43 +237,6 @@ TEST_F(DatabaseTest, ASSERT_EQUALS(dropOpTime, *reaperEarliestDropOpTime); } -/** - * Sets up ReplicationCoordinator for master/slave. - */ -void _setUpMasterSlave(ServiceContext* service) { - repl::ReplSettings settings; - settings.setOplogSizeBytes(10 * 1024 * 1024); - settings.setMaster(true); - repl::ReplicationCoordinator::set( - service, stdx::make_unique<repl::ReplicationCoordinatorMock>(service, settings)); - auto replCoord = repl::ReplicationCoordinator::get(service); - ASSERT_TRUE(repl::ReplicationCoordinator::modeMasterSlave == replCoord->getReplicationMode()); -} - -TEST_F(DatabaseTest, - DropCollectionDropsCollectionAndLogsOperationIfWritesAreReplicatedAndReplModeIsMasterSlave) { - _setUpMasterSlave(getServiceContext()); - - ASSERT_TRUE(_opCtx->writesAreReplicated()); - ASSERT_FALSE( - repl::ReplicationCoordinator::get(_opCtx.get())->isOplogDisabledFor(_opCtx.get(), _nss)); - - _testDropCollection(_opCtx.get(), _nss, true); - - // Drop optime is non-null because an op was written to the oplog. - auto dropOpTime = repl::ReplClientInfo::forClient(&cc()).getLastOp(); - ASSERT_GREATER_THAN(dropOpTime, repl::OpTime()); - - // Replicated collection should not be renamed under master/slave. - auto dpns = _nss.makeDropPendingNamespace(dropOpTime); - ASSERT_FALSE(mongo::AutoGetCollectionForRead(_opCtx.get(), dpns).getCollection()); - - // Reaper should not have the drop optime of the collection. - auto reaperEarliestDropOpTime = - repl::DropPendingCollectionReaper::get(_opCtx.get())->getEarliestDropOpTime(); - ASSERT_FALSE(reaperEarliestDropOpTime); -} - TEST_F(DatabaseTest, DropCollectionRejectsProvidedDropOpTimeIfWritesAreReplicated) { ASSERT_TRUE(_opCtx->writesAreReplicated()); ASSERT_FALSE( @@ -320,40 +283,6 @@ TEST_F( ASSERT_EQUALS(dropOpTime, *reaperEarliestDropOpTime); } -TEST_F( - DatabaseTest, - DropCollectionIgnoresProvidedDropOpTimeAndDropsCollectionButDoesNotLogOperationIfReplModeIsMasterSlave) { - _setUpMasterSlave(getServiceContext()); - - repl::UnreplicatedWritesBlock uwb(_opCtx.get()); - ASSERT_FALSE(_opCtx->writesAreReplicated()); - ASSERT_TRUE( - repl::ReplicationCoordinator::get(_opCtx.get())->isOplogDisabledFor(_opCtx.get(), _nss)); - - repl::OpTime dropOpTime(Timestamp(Seconds(100), 0), 1LL); - _testDropCollection(_opCtx.get(), _nss, true, dropOpTime); - - // Last optime in repl client is null because we did not write to the oplog. - ASSERT_EQUALS(repl::OpTime(), repl::ReplClientInfo::forClient(&cc()).getLastOp()); - - // Collection is not renamed under master/slave. - auto dpns = _nss.makeDropPendingNamespace(dropOpTime); - ASSERT_FALSE(mongo::AutoGetCollectionForRead(_opCtx.get(), dpns).getCollection()); - - // Reaper should not have the drop optime of the collection. - auto reaperEarliestDropOpTime = - repl::DropPendingCollectionReaper::get(_opCtx.get())->getEarliestDropOpTime(); - ASSERT_FALSE(reaperEarliestDropOpTime); -} - -TEST_F(DatabaseTest, DropPendingCollectionIsAllowedToHaveDocumentValidators) { - CollectionOptions opts; - opts.validator = BSON("x" << BSON("$type" - << "string")); - opts.validationAction = "error"; - _testDropCollection(_opCtx.get(), _nss, true, {}, opts); -} - void _testDropCollectionThrowsExceptionIfThereAreIndexesInProgress(OperationContext* opCtx, const NamespaceString& nss) { writeConflictRetry(opCtx, "testDropCollectionWithIndexesInProgress", nss.ns(), [opCtx, nss] { diff --git a/src/mongo/db/catalog/rename_collection_test.cpp b/src/mongo/db/catalog/rename_collection_test.cpp index db520e36ceb..60386382669 100644 --- a/src/mongo/db/catalog/rename_collection_test.cpp +++ b/src/mongo/db/catalog/rename_collection_test.cpp @@ -571,46 +571,6 @@ TEST_F(RenameCollectionTest, RenameCollectionMakesTargetCollectionDropPendingIfD << " not renamed to drop-pending collection after successful rename"; } -/** - * Sets up ReplicationCoordinator for master/slave. - */ -void _setUpMasterSlave(ServiceContext* service) { - repl::ReplSettings settings; - settings.setOplogSizeBytes(10 * 1024 * 1024); - settings.setMaster(true); - repl::ReplicationCoordinator::set( - service, stdx::make_unique<repl::ReplicationCoordinatorMock>(service, settings)); - auto replCoord = repl::ReplicationCoordinator::get(service); - ASSERT_TRUE(repl::ReplicationCoordinator::modeMasterSlave == replCoord->getReplicationMode()); -} - -TEST_F(RenameCollectionTest, - RenameCollectionDropsTargetCollectionIfDropTargetIsTrueAndReplModeIsMasterSlave) { - _setUpMasterSlave(getServiceContext()); - - _createCollection(_opCtx.get(), _sourceNss); - _createCollection(_opCtx.get(), _targetNss); - RenameCollectionOptions options; - options.dropTarget = true; - ASSERT_OK(renameCollection(_opCtx.get(), _sourceNss, _targetNss, options)); - ASSERT_FALSE(_collectionExists(_opCtx.get(), _sourceNss)) - << "source collection " << _sourceNss << " still exists after successful rename"; - ASSERT_TRUE(_collectionExists(_opCtx.get(), _targetNss)) << "target collection " << _targetNss - << " missing after successful rename"; - - ASSERT_TRUE(_opObserver->onRenameCollectionCalled); - - auto renameOpTime = _opObserver->renameOpTime; - ASSERT_GREATER_THAN(renameOpTime, repl::OpTime()); - - // Confirm that the target collection is not renamed to a drop-pending collection under - // master/slave. - auto dpns = _targetNss.makeDropPendingNamespace(renameOpTime); - ASSERT_FALSE(_collectionExists(_opCtx.get(), dpns)) - << "target collection " << _targetNss - << " renamed to drop-pending collection after successful rename"; -} - TEST_F(RenameCollectionTest, RenameCollectionForApplyOpsRejectsRenameOpTimeIfWritesAreReplicated) { ASSERT_TRUE(_opCtx->writesAreReplicated()); diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp index 6861095c326..f374290ec8f 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp @@ -594,24 +594,6 @@ TEST_F(ReplCoordTest, NodeReturnsImmediatelyWhenAwaitReplicationIsRanAgainstASta ASSERT_OK(statusAndDur.status); } -TEST_F(ReplCoordTest, NodeReturnsImmediatelyWhenAwaitReplicationIsRanAgainstAMasterSlaveNode) { - ReplSettings settings; - settings.setMaster(true); - init(settings); - auto opCtx = makeOperationContext(); - - OpTimeWithTermOne time(100, 1); - - WriteConcernOptions writeConcern; - writeConcern.wTimeout = WriteConcernOptions::kNoWaiting; - writeConcern.wNumNodes = 0; - writeConcern.wMode = WriteConcernOptions::kMajority; - // w:majority always works on master/slave - ReplicationCoordinator::StatusAndDuration statusAndDur = - getReplCoord()->awaitReplication(opCtx.get(), time, writeConcern); - ASSERT_OK(statusAndDur.status); -} - TEST_F(ReplCoordTest, NodeReturnsNotMasterWhenRunningAwaitReplicationAgainstASecondaryNode) { assertStartSuccess(BSON("_id" << "mySet" @@ -2184,24 +2166,6 @@ TEST_F(ReplCoordTest, GetReplicationModeNone) { } TEST_F(ReplCoordTest, - NodeReturnsModeMasterSlaveInResponseToGetReplicationModeWhenRunningWithTheMasterFlag) { - // modeMasterSlave if master set - ReplSettings settings; - settings.setMaster(true); - init(settings); - ASSERT_EQUALS(ReplicationCoordinator::modeMasterSlave, getReplCoord()->getReplicationMode()); -} - -TEST_F(ReplCoordTest, - NodeReturnsModeMasterSlaveInResponseToGetReplicationModeWhenRunningWithTheSlaveFlag) { - // modeMasterSlave if the slave flag was set - ReplSettings settings; - settings.setSlave(true); - init(settings); - ASSERT_EQUALS(ReplicationCoordinator::modeMasterSlave, getReplCoord()->getReplicationMode()); -} - -TEST_F(ReplCoordTest, NodeReturnsModeReplSetInResponseToGetReplicationModeWhenRunningWithTheReplSetFlag) { // modeReplSet if the set name was supplied. ReplSettings settings; @@ -2622,36 +2586,6 @@ TEST_F(ReplCoordTest, } } -TEST_F(ReplCoordTest, NodeDoesNotIncludeItselfWhenRunningGetHostsWrittenToInMasterSlave) { - ReplSettings settings; - settings.setMaster(true); - init(settings); - HostAndPort clientHost("node2:12345"); - auto opCtx = makeOperationContext(); - - - OID client = OID::gen(); - OpTimeWithTermOne time1(100, 1); - OpTimeWithTermOne time2(100, 2); - - getExternalState()->setClientHostAndPort(clientHost); - HandshakeArgs handshake; - ASSERT_OK(handshake.initialize(BSON("handshake" << client))); - ASSERT_OK(getReplCoord()->processHandshake(opCtx.get(), handshake)); - - getReplCoord()->setMyLastAppliedOpTime(time2); - getReplCoord()->setMyLastDurableOpTime(time2); - ASSERT_OK(getReplCoord()->setLastOptimeForSlave(client, time1.timestamp)); - - std::vector<HostAndPort> caughtUpHosts = getReplCoord()->getHostsWrittenTo(time2, false); - ASSERT_EQUALS(0U, caughtUpHosts.size()); // self doesn't get included in master-slave - - ASSERT_OK(getReplCoord()->setLastOptimeForSlave(client, time2.timestamp)); - caughtUpHosts = getReplCoord()->getHostsWrittenTo(time2, false); - ASSERT_EQUALS(1U, caughtUpHosts.size()); - ASSERT_EQUALS(clientHost, caughtUpHosts[0]); -} - TEST_F(ReplCoordTest, NodeReturnsNoNodesWhenGetOtherNodesInReplSetIsRunBeforeHavingAConfig) { start(); ASSERT_EQUALS(0U, getReplCoord()->getOtherNodesInReplSet().size()); @@ -3479,12 +3413,6 @@ protected: settings.setReplSetString("replset"); init(settings); } - - void initMasterSlaveMode() { - auto settings = ReplSettings(); - settings.setSlave(true); - init(settings); - } }; // An equality assertion for two std::set<OpTime> values. Prints the elements of each set when @@ -3683,25 +3611,6 @@ TEST_F(StableOpTimeTest, AdvanceCommitPointSetsStableOpTimeForStorage) { ASSERT_OPTIME_SET_EQ(expectedOpTimeCandidates, opTimeCandidates); } -TEST_F(StableOpTimeTest, SetMyLastAppliedDoesntAddTimestampCandidateInMasterSlaveMode) { - - /** - * Test that 'setMyLastAppliedOpTime' doesn't add timestamp candidates to the stable optime - * list when running in master-slave mode. - */ - - initMasterSlaveMode(); - auto repl = getReplCoord(); - - ASSERT(repl->getStableOpTimeCandidates_forTest().empty()); - - repl->setMyLastAppliedOpTime(OpTime({0, 1}, 0)); - repl->setMyLastAppliedOpTime(OpTime({0, 2}, 0)); - - // Make sure no timestamps candidates were added. - ASSERT(repl->getStableOpTimeCandidates_forTest().empty()); -} - TEST_F(StableOpTimeTest, ClearOpTimeCandidatesPastCommonPointAfterRollback) { assertStartSuccess(BSON("_id" diff --git a/src/mongo/shell/servers_misc.js b/src/mongo/shell/servers_misc.js index 379bffd3677..89a07564b66 100644 --- a/src/mongo/shell/servers_misc.js +++ b/src/mongo/shell/servers_misc.js @@ -68,111 +68,6 @@ ToolTest.prototype.runTool = function() { return runMongoProgram.apply(null, a); }; -ReplTest = function(name, ports) { - this.name = name; - this.ports = ports || allocatePorts(2); - this.kDefaultTimeoutMS = 10 * 60 * 1000; -}; - -ReplTest.prototype.getPort = function(master) { - if (master) - return this.ports[0]; - return this.ports[1]; -}; - -ReplTest.prototype.getPath = function(master) { - var p = MongoRunner.dataPath + this.name + "-"; - if (master) - p += "master"; - else - p += "slave"; - return p; -}; - -ReplTest.prototype.getOptions = function(master, extra, putBinaryFirst, norepl) { - - if (!extra) - extra = {}; - - if (!extra.oplogSize) - extra.oplogSize = "40"; - - var a = []; - if (putBinaryFirst) - a.push("mongod"); - a.push("--noprealloc", "--bind_ip", "127.0.0.1", "--smallfiles"); - - a.push("--port"); - a.push(this.getPort(master)); - - a.push("--dbpath"); - a.push(this.getPath(master)); - - if (jsTestOptions().noJournal && !('journal' in extra)) - a.push("--nojournal"); - if (jsTestOptions().noJournalPrealloc) - a.push("--nopreallocj"); - if (jsTestOptions().keyFile) { - a.push("--keyFile"); - a.push(jsTestOptions().keyFile); - } - - if (!norepl) { - if (master) { - a.push("--master"); - } else { - a.push("--slave"); - a.push("--source"); - a.push("127.0.0.1:" + this.ports[0]); - } - } - - for (var k in extra) { - var v = extra[k]; - if (k in MongoRunner.logicalOptions) - continue; - a.push("--" + k); - if (v != null && v !== "") - a.push(v); - } - - return a; -}; - -ReplTest.prototype.start = function(master, options, restart, norepl) { - var lockFile = this.getPath(master) + "/mongod.lock"; - removeFile(lockFile); - var o = this.getOptions(master, options, restart, norepl); - - if (restart) { - var conn = startMongoProgram.apply(null, o); - if (!master) { - conn.setSlaveOk(); - } - return conn; - } else { - var conn = _startMongod.apply(null, o); - if (jsTestOptions().keyFile || jsTestOptions().auth) { - jsTest.authenticate(conn); - } - if (!master) { - conn.setSlaveOk(); - } - return conn; - } -}; - -ReplTest.prototype.stop = function(master, signal) { - if (arguments.length == 0) { - this.stop(true); - this.stop(false); - return; - } - - print('*** ' + this.name + " completed successfully ***"); - return _stopMongoProgram(this.getPort(master), signal || 15); -}; - /** * Returns a port number that has not been given out to any other caller from the same mongo shell. */ |