diff options
author | Maria van Keulen <maria@mongodb.com> | 2018-07-27 17:09:24 -0400 |
---|---|---|
committer | Maria van Keulen <maria@mongodb.com> | 2018-08-07 14:26:55 -0400 |
commit | 88a8b7b31ca41eca88e782d84e496911c93cc0ae (patch) | |
tree | f60e0bee8e351180ad2c256c3c8946ec35fadeb6 | |
parent | 4c16f0f336f4db77034e8aa594bbd4a5bac3f40c (diff) | |
download | mongo-88a8b7b31ca41eca88e782d84e496911c93cc0ae.tar.gz |
SERVER-36257 Remove copyDB and clone commands
69 files changed, 63 insertions, 2018 deletions
diff --git a/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough_auth.yml b/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough_auth.yml index ecd9d15cd95..64969e5d3d5 100644 --- a/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough_auth.yml +++ b/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough_auth.yml @@ -18,7 +18,6 @@ selector: # Skip any tests that run with auth explicitly. - jstests/core/*[aA]uth*.js # Skip any tests that require privileges for non test databases. - - jstests/core/copydb.js - jstests/core/system_profile.js # Cannot specify afterClusterTime and afterOpTime. - jstests/core/read_after_optime.js diff --git a/buildscripts/resmokeconfig/suites/replica_sets_auth_5.yml b/buildscripts/resmokeconfig/suites/replica_sets_auth_5.yml index 2dffbbb53ea..1b37c762894 100644 --- a/buildscripts/resmokeconfig/suites/replica_sets_auth_5.yml +++ b/buildscripts/resmokeconfig/suites/replica_sets_auth_5.yml @@ -25,7 +25,6 @@ selector: - jstests/replsets/last_op_visible.js - jstests/replsets/sessions_collection_auto_healing.js - jstests/replsets/maintenance2.js - - jstests/replsets/copydb.js - jstests/replsets/sized_zero_capped.js - jstests/replsets/initial_sync_document_validation.js - jstests/replsets/commands_that_write_accept_wc.js diff --git a/buildscripts/resmokeconfig/suites/replica_sets_auth_6.yml b/buildscripts/resmokeconfig/suites/replica_sets_auth_6.yml index ee5047dd78a..2e450c9189f 100644 --- a/buildscripts/resmokeconfig/suites/replica_sets_auth_6.yml +++ b/buildscripts/resmokeconfig/suites/replica_sets_auth_6.yml @@ -52,7 +52,6 @@ selector: - jstests/replsets/initiate_prohibits_w0.js - jstests/replsets/single_server_majority.js - jstests/replsets/rslib.js - - jstests/replsets/cloneDb.js - jstests/replsets/two_nodes_priority_take_over.js - jstests/replsets/initial_sync_cloner_dups.js - jstests/replsets/find_and_modify_wc.js diff --git a/buildscripts/resmokeconfig/suites/replica_sets_auth_misc.yml b/buildscripts/resmokeconfig/suites/replica_sets_auth_misc.yml index a3a5cf32650..b4876dabc47 100644 --- a/buildscripts/resmokeconfig/suites/replica_sets_auth_misc.yml +++ b/buildscripts/resmokeconfig/suites/replica_sets_auth_misc.yml @@ -125,7 +125,6 @@ selector: - jstests/replsets/last_op_visible.js - jstests/replsets/sessions_collection_auto_healing.js - jstests/replsets/maintenance2.js - - jstests/replsets/copydb.js - jstests/replsets/sized_zero_capped.js - jstests/replsets/initial_sync_document_validation.js - jstests/replsets/commands_that_write_accept_wc.js @@ -221,7 +220,6 @@ selector: - jstests/replsets/initiate_prohibits_w0.js - jstests/replsets/single_server_majority.js - jstests/replsets/rslib.js - - jstests/replsets/cloneDb.js - jstests/replsets/two_nodes_priority_take_over.js - jstests/replsets/initial_sync_cloner_dups.js - jstests/replsets/find_and_modify_wc.js diff --git a/buildscripts/resmokeconfig/suites/replica_sets_ese_4.yml b/buildscripts/resmokeconfig/suites/replica_sets_ese_4.yml index 3f52c8d2115..4dc399d7bea 100644 --- a/buildscripts/resmokeconfig/suites/replica_sets_ese_4.yml +++ b/buildscripts/resmokeconfig/suites/replica_sets_ese_4.yml @@ -44,7 +44,6 @@ selector: - jstests/replsets/initial_sync_oplog_rollover.js - jstests/replsets/rollback_drop_database.js - jstests/replsets/auth_no_pri.js - - jstests/replsets/cloneDb.js - jstests/replsets/slave_delay_clean_shutdown.js - jstests/replsets/rollback_drop_index_after_rename.js - jstests/replsets/reconfig.js diff --git a/buildscripts/resmokeconfig/suites/replica_sets_ese_5.yml b/buildscripts/resmokeconfig/suites/replica_sets_ese_5.yml index ab325e4baae..6258010f231 100644 --- a/buildscripts/resmokeconfig/suites/replica_sets_ese_5.yml +++ b/buildscripts/resmokeconfig/suites/replica_sets_ese_5.yml @@ -25,7 +25,6 @@ selector: - jstests/replsets/sessions_collection_auto_healing.js - jstests/replsets/get_replication_info_helper.js - jstests/replsets/maintenance2.js - - jstests/replsets/copydb.js - jstests/replsets/read_committed_lookup.js - jstests/replsets/initial_sync_update_missing_doc1.js - jstests/replsets/commands_that_write_accept_wc.js diff --git a/buildscripts/resmokeconfig/suites/replica_sets_ese_misc.yml b/buildscripts/resmokeconfig/suites/replica_sets_ese_misc.yml index 50df83f6be3..25c4069f197 100644 --- a/buildscripts/resmokeconfig/suites/replica_sets_ese_misc.yml +++ b/buildscripts/resmokeconfig/suites/replica_sets_ese_misc.yml @@ -98,7 +98,6 @@ selector: - jstests/replsets/initial_sync_oplog_rollover.js - jstests/replsets/rollback_drop_database.js - jstests/replsets/auth_no_pri.js - - jstests/replsets/cloneDb.js - jstests/replsets/slave_delay_clean_shutdown.js - jstests/replsets/rollback_drop_index_after_rename.js - jstests/replsets/reconfig.js @@ -119,7 +118,6 @@ selector: - jstests/replsets/sessions_collection_auto_healing.js - jstests/replsets/get_replication_info_helper.js - jstests/replsets/maintenance2.js - - jstests/replsets/copydb.js - jstests/replsets/read_committed_lookup.js - jstests/replsets/initial_sync_update_missing_doc1.js - jstests/replsets/commands_that_write_accept_wc.js diff --git a/buildscripts/resmokeconfig/suites/sharded_causally_consistent_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/sharded_causally_consistent_jscore_passthrough.yml index 0c04ff9b07c..8df91eab2f0 100644 --- a/buildscripts/resmokeconfig/suites/sharded_causally_consistent_jscore_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/sharded_causally_consistent_jscore_passthrough.yml @@ -15,15 +15,13 @@ selector: - jstests/core/apitest_db.js # serverStatus output doesn't have storageEngine. - jstests/core/apitest_db_profile_level.js # profiling. - jstests/core/apply_ops*.js # applyOps, SERVER-1439. - - jstests/core/bypass_doc_validation.js # copyDatabase + - jstests/core/bypass_doc_validation.js # sharded $out output not permitted - jstests/core/capped*.js # capped collections. - jstests/core/check_shard_index.js # checkShardingIndex. - jstests/core/collection_truncate.js # emptycapped. - jstests/core/compact_keeps_indexes.js # compact. - jstests/core/currentop.js # uses fsync. - - jstests/core/auth_copydb.js # copyDatabase. - jstests/core/collmod_without_uuid.js # applyOps, SERVER-1439 - - jstests/core/copydb.js # copyDatabase. - jstests/core/dbadmin.js # "local" database. - jstests/core/dbhash.js # dbhash. - jstests/core/dbhash2.js # dbhash. diff --git a/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml index e95109c3418..2d9980907f9 100644 --- a/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml @@ -12,15 +12,13 @@ selector: - jstests/core/apitest_db_profile_level.js # profiling. - jstests/core/apply_ops*.js # applyOps, SERVER-1439. - jstests/core/awaitdata_getmore_cmd.js # capped collections. - - jstests/core/bypass_doc_validation.js # copyDatabase + - jstests/core/bypass_doc_validation.js # sharded $out output not permitted - jstests/core/capped*.js # capped collections. - jstests/core/check_shard_index.js # checkShardingIndex. - jstests/core/collection_truncate.js # emptycapped. - jstests/core/collmod_without_uuid.js # applyOps, SERVER-1439 - jstests/core/compact_keeps_indexes.js # compact. - jstests/core/currentop.js # uses fsync. - - jstests/core/auth_copydb.js # copyDatabase. - - jstests/core/copydb.js # copyDatabase. - jstests/core/dbadmin.js # "local" database. - jstests/core/dbhash.js # dbhash. - jstests/core/dbhash2.js # dbhash. diff --git a/buildscripts/resmokeconfig/suites/sharding_14.yml b/buildscripts/resmokeconfig/suites/sharding_14.yml index 8ed96377d76..8bbdae7b330 100644 --- a/buildscripts/resmokeconfig/suites/sharding_14.yml +++ b/buildscripts/resmokeconfig/suites/sharding_14.yml @@ -28,7 +28,6 @@ selector: - jstests/sharding/server_status.js - jstests/sharding/ssv_config_check.js - jstests/sharding/update_zone_key_range.js - - jstests/sharding/copydb_from_mongos.js - jstests/sharding/auth2.js - jstests/sharding/change_stream_update_lookup_collation.js - jstests/sharding/mongos_query_comment.js @@ -38,7 +37,6 @@ selector: - jstests/sharding/authwhere.js - jstests/sharding/authmr.js - jstests/sharding/sessions_collection_auto_healing.js - - jstests/sharding/auth_copydb.js - jstests/sharding/read_does_not_create_namespaces.js - jstests/sharding/ismaster.js - jstests/sharding/balancer_shell_commands.js diff --git a/buildscripts/resmokeconfig/suites/sharding_auth.yml b/buildscripts/resmokeconfig/suites/sharding_auth.yml index f7698454d30..0404938d735 100644 --- a/buildscripts/resmokeconfig/suites/sharding_auth.yml +++ b/buildscripts/resmokeconfig/suites/sharding_auth.yml @@ -15,7 +15,6 @@ selector: - jstests/sharding/aggregation_currentop.js # SERVER-19318 - jstests/sharding/kill_sessions.js # Skip these additional tests when running with auth enabled. - - jstests/sharding/copydb_from_mongos.js # SERVER-13080 - jstests/sharding/parallel.js # Skip these tests that run with enableTestCommands off. - jstests/sharding/shard_config_db_collections.js diff --git a/buildscripts/resmokeconfig/suites/sharding_auth_audit.yml b/buildscripts/resmokeconfig/suites/sharding_auth_audit.yml index a1a469b1b98..8329ba32ce1 100644 --- a/buildscripts/resmokeconfig/suites/sharding_auth_audit.yml +++ b/buildscripts/resmokeconfig/suites/sharding_auth_audit.yml @@ -15,7 +15,6 @@ selector: - jstests/sharding/aggregation_currentop.js # SERVER-19318 - jstests/sharding/kill_sessions.js # Skip these additional tests when running with auth enabled. - - jstests/sharding/copydb_from_mongos.js # SERVER-13080 - jstests/sharding/parallel.js # Skip these tests that run with enableTestCommands off. - jstests/sharding/shard_config_db_collections.js diff --git a/buildscripts/resmokeconfig/suites/sharding_auth_audit_misc.yml b/buildscripts/resmokeconfig/suites/sharding_auth_audit_misc.yml index f4d7e1e89cb..5119d00f2d7 100644 --- a/buildscripts/resmokeconfig/suites/sharding_auth_audit_misc.yml +++ b/buildscripts/resmokeconfig/suites/sharding_auth_audit_misc.yml @@ -23,7 +23,6 @@ selector: - jstests/sharding/aggregation_currentop.js # SERVER-19318 - jstests/sharding/kill_sessions.js # Skip these additional tests when running with auth enabled. - - jstests/sharding/copydb_from_mongos.js # SERVER-13080 - jstests/sharding/parallel.js # Skip these tests that run with enableTestCommands off. - jstests/sharding/shard_config_db_collections.js diff --git a/buildscripts/resmokeconfig/suites/sharding_auth_misc.yml b/buildscripts/resmokeconfig/suites/sharding_auth_misc.yml index aaa7fb1be33..94c281671c6 100644 --- a/buildscripts/resmokeconfig/suites/sharding_auth_misc.yml +++ b/buildscripts/resmokeconfig/suites/sharding_auth_misc.yml @@ -22,7 +22,6 @@ selector: - jstests/sharding/aggregation_currentop.js # SERVER-19318 - jstests/sharding/kill_sessions.js # Skip these additional tests when running with auth enabled. - - jstests/sharding/copydb_from_mongos.js # SERVER-13080 - jstests/sharding/parallel.js # Skip these tests that run with enableTestCommands off. - jstests/sharding/shard_config_db_collections.js diff --git a/buildscripts/resmokeconfig/suites/sharding_ese_19.yml b/buildscripts/resmokeconfig/suites/sharding_ese_19.yml index e7e9123b362..e10958028e8 100644 --- a/buildscripts/resmokeconfig/suites/sharding_ese_19.yml +++ b/buildscripts/resmokeconfig/suites/sharding_ese_19.yml @@ -33,7 +33,6 @@ selector: - jstests/sharding/replication_with_undefined_shard_key.js - jstests/sharding/min_optime_recovery_on_failed_move_chunk_commit.js - jstests/sharding/change_stream_lookup_single_shard_cluster.js - - jstests/sharding/copydb_from_mongos.js - jstests/sharding/max_time_ms_sharded_new_commands.js - jstests/sharding/sessions_collection_auto_healing.js - jstests/sharding/major_version_check.js @@ -55,4 +54,4 @@ executor: TestData: enableEncryption: '' encryptionKeyFile: *keyFile - readMode: commands
\ No newline at end of file + readMode: commands diff --git a/buildscripts/resmokeconfig/suites/sharding_ese_20.yml b/buildscripts/resmokeconfig/suites/sharding_ese_20.yml index 37a56012cd5..c63015ebf7d 100644 --- a/buildscripts/resmokeconfig/suites/sharding_ese_20.yml +++ b/buildscripts/resmokeconfig/suites/sharding_ese_20.yml @@ -25,7 +25,6 @@ selector: - jstests/sharding/version2.js - jstests/sharding/split_against_shard_with_invalid_split_points.js - jstests/sharding/add_shard_to_zone.js - - jstests/sharding/auth_copydb.js - jstests/sharding/auth_no_config_primary.js - jstests/sharding/balancer_shell_commands.js - jstests/sharding/remove_shard_from_zone.js diff --git a/buildscripts/resmokeconfig/suites/sharding_ese_misc.yml b/buildscripts/resmokeconfig/suites/sharding_ese_misc.yml index 9a9517a7ede..14e128dc260 100644 --- a/buildscripts/resmokeconfig/suites/sharding_ese_misc.yml +++ b/buildscripts/resmokeconfig/suites/sharding_ese_misc.yml @@ -323,7 +323,6 @@ selector: - jstests/sharding/replication_with_undefined_shard_key.js - jstests/sharding/min_optime_recovery_on_failed_move_chunk_commit.js - jstests/sharding/change_stream_lookup_single_shard_cluster.js - - jstests/sharding/copydb_from_mongos.js - jstests/sharding/max_time_ms_sharded_new_commands.js - jstests/sharding/sessions_collection_auto_healing.js - jstests/sharding/major_version_check.js @@ -345,7 +344,6 @@ selector: - jstests/sharding/version2.js - jstests/sharding/split_against_shard_with_invalid_split_points.js - jstests/sharding/add_shard_to_zone.js - - jstests/sharding/auth_copydb.js - jstests/sharding/auth_no_config_primary.js - jstests/sharding/balancer_shell_commands.js - jstests/sharding/remove_shard_from_zone.js diff --git a/buildscripts/resmokeconfig/suites/sharding_last_stable_mongos_and_mixed_shards_11.yml b/buildscripts/resmokeconfig/suites/sharding_last_stable_mongos_and_mixed_shards_11.yml index a5390a196f4..c94514ac0b9 100644 --- a/buildscripts/resmokeconfig/suites/sharding_last_stable_mongos_and_mixed_shards_11.yml +++ b/buildscripts/resmokeconfig/suites/sharding_last_stable_mongos_and_mixed_shards_11.yml @@ -14,7 +14,6 @@ selector: roots: - jstests/sharding/mongos_query_comment.js - jstests/sharding/read_after_optime.js - - jstests/sharding/copydb_from_mongos.js - jstests/sharding/server_status.js - jstests/sharding/missing_key.js - jstests/sharding/listDatabases.js @@ -34,7 +33,6 @@ selector: - jstests/sharding/remove_shard_from_zone.js - jstests/sharding/addshard6.js - jstests/sharding/autodiscover_config_rs_from_secondary.js - - jstests/sharding/auth_copydb.js - jstests/sharding/mrShardedOutputAuth.js - jstests/sharding/authmr.js - jstests/sharding/forget_mr_temp_ns.js diff --git a/buildscripts/resmokeconfig/suites/sharding_last_stable_mongos_and_mixed_shards_misc.yml b/buildscripts/resmokeconfig/suites/sharding_last_stable_mongos_and_mixed_shards_misc.yml index 881db6b9765..661efbfa354 100644 --- a/buildscripts/resmokeconfig/suites/sharding_last_stable_mongos_and_mixed_shards_misc.yml +++ b/buildscripts/resmokeconfig/suites/sharding_last_stable_mongos_and_mixed_shards_misc.yml @@ -298,7 +298,6 @@ selector: - jstests/sharding/disable_autosplit.js - jstests/sharding/mongos_query_comment.js - jstests/sharding/read_after_optime.js - - jstests/sharding/copydb_from_mongos.js - jstests/sharding/server_status.js - jstests/sharding/missing_key.js - jstests/sharding/listDatabases.js @@ -318,7 +317,6 @@ selector: - jstests/sharding/remove_shard_from_zone.js - jstests/sharding/addshard6.js - jstests/sharding/autodiscover_config_rs_from_secondary.js - - jstests/sharding/auth_copydb.js - jstests/sharding/mrShardedOutputAuth.js - jstests/sharding/authmr.js - jstests/sharding/forget_mr_temp_ns.js diff --git a/buildscripts/resmokeconfig/suites/sharding_misc.yml b/buildscripts/resmokeconfig/suites/sharding_misc.yml index 6e3dea7760e..5ef0a8eb6dd 100644 --- a/buildscripts/resmokeconfig/suites/sharding_misc.yml +++ b/buildscripts/resmokeconfig/suites/sharding_misc.yml @@ -332,7 +332,6 @@ selector: - jstests/sharding/server_status.js - jstests/sharding/ssv_config_check.js - jstests/sharding/update_zone_key_range.js - - jstests/sharding/copydb_from_mongos.js - jstests/sharding/auth2.js - jstests/sharding/change_stream_update_lookup_collation.js - jstests/sharding/mongos_query_comment.js @@ -342,7 +341,6 @@ selector: - jstests/sharding/authwhere.js - jstests/sharding/authmr.js - jstests/sharding/sessions_collection_auto_healing.js - - jstests/sharding/auth_copydb.js - jstests/sharding/read_does_not_create_namespaces.js - jstests/sharding/ismaster.js - jstests/sharding/balancer_shell_commands.js diff --git a/buildscripts/templates/generate_resmoke_suites/sharding_auth.yml.j2 b/buildscripts/templates/generate_resmoke_suites/sharding_auth.yml.j2 index 86d41ade5f6..f7beb4884f1 100644 --- a/buildscripts/templates/generate_resmoke_suites/sharding_auth.yml.j2 +++ b/buildscripts/templates/generate_resmoke_suites/sharding_auth.yml.j2 @@ -32,7 +32,6 @@ selector: - jstests/sharding/aggregation_currentop.js # SERVER-19318 - jstests/sharding/kill_sessions.js # Skip these additional tests when running with auth enabled. - - jstests/sharding/copydb_from_mongos.js # SERVER-13080 - jstests/sharding/parallel.js # Skip these tests that run with enableTestCommands off. - jstests/sharding/shard_config_db_collections.js diff --git a/buildscripts/templates/generate_resmoke_suites/sharding_auth_audit.yml.j2 b/buildscripts/templates/generate_resmoke_suites/sharding_auth_audit.yml.j2 index 0a46cb4585f..8c7a770fd5e 100644 --- a/buildscripts/templates/generate_resmoke_suites/sharding_auth_audit.yml.j2 +++ b/buildscripts/templates/generate_resmoke_suites/sharding_auth_audit.yml.j2 @@ -33,7 +33,6 @@ selector: - jstests/sharding/aggregation_currentop.js # SERVER-19318 - jstests/sharding/kill_sessions.js # Skip these additional tests when running with auth enabled. - - jstests/sharding/copydb_from_mongos.js # SERVER-13080 - jstests/sharding/parallel.js # Skip these tests that run with enableTestCommands off. - jstests/sharding/shard_config_db_collections.js diff --git a/jstests/auth/copyauth.js b/jstests/auth/copyauth.js deleted file mode 100644 index 9caa51a6e87..00000000000 --- a/jstests/auth/copyauth.js +++ /dev/null @@ -1,275 +0,0 @@ -// Test copyDatabase command with various combinations of authed/unauthed and single node/replica -// set source and dest. - -TestData.authMechanism = "SCRAM-SHA-1"; // SERVER-11428 -DB.prototype._defaultAuthenticationMechanism = "SCRAM-SHA-1"; // SERVER-11428 - -// We turn off gossiping the mongo shell's clusterTime because this test connects to replica sets -// and sharded clusters as a user other than __system. Attempting to advance the clusterTime while -// it has been signed with a dummy key results in an authorization error. -TestData.skipGossipingClusterTime = true; - -var baseName = "jstests_clone_copyauth"; - -/* - * Helper to spawn a replica set, sharded cluster, or a single mongod and hide it all behind the - * same interface. - * - * Arguments: - * - * clusterType - type of cluster to start. Options are "sharded", "repl", or "single". - * startWithAuth - whether to start the cluster with authentication. - * startWithTransitionToAuth - whether to start the cluster with --transitionToAuth (startWithAuth - * must also be true). - * - * Member variables: - * - * conn - a connection to the node used to access this cluster, whether it's the mongod, a primary - * mongod in a replica set, or a mongos. - * connString - the full connection string used to connect to this cluster. For a replica set this - * is the full connection string including the replica set name. - * - * Member functions: - * - * stop() - stop and cleanup whatever nodes the helper spawned when it was created. - * @tags: [requires_replication, requires_sharding] - */ -function ClusterSpawnHelper(clusterType, startWithAuth, startWithTransitionToAuth) { - var singleNodeConfig = {}; - if (startWithAuth) { - singleNodeConfig.keyFile = "jstests/libs/key1"; - if (startWithTransitionToAuth) { - singleNodeConfig.transitionToAuth = ""; - } - } - if (clusterType === "sharded") { - var shardingTestConfig = { - name: baseName + "_source", - keyFile: singleNodeConfig.keyFile, - mongos: [singleNodeConfig], - shards: [singleNodeConfig], - config: [singleNodeConfig] - }; - var shardingTest = new ShardingTest(shardingTestConfig); - this.conn = shardingTest.s; - this.connString = this.conn.host; - } else if (clusterType === "repl") { - var replSetTestConfig = { - name: baseName + "_source", - nodes: 3, - nodeOptions: singleNodeConfig, - keyFile: singleNodeConfig.keyFile - }; - var replSetTest = new ReplSetTest(replSetTestConfig); - replSetTest.startSet(); - replSetTest.initiate(); - if (startWithAuth) { - authutil.asCluster( - replSetTest.nodes, replSetTestConfig.nodeOptions.keyFile, function() { - replSetTest.awaitReplication(); - }); - } else { - replSetTest.awaitReplication(); - } - this.conn = replSetTest.getPrimary(); - this.connString = replSetTest.getURL(); - } else { - this.conn = MongoRunner.runMongod(singleNodeConfig); - this.connString = this.conn.host; - } - - this.stop = function() { - if (clusterType === "sharded") { - shardingTest.stop(); - } else if (clusterType === "repl") { - replSetTest.stopSet(); - } else { - MongoRunner.stopMongod(this.conn); - } - }; -} - -/* - * Helper to test the running the "copydb" command between various kinds of clusters and various - * combinations of authentication on the source and target. - * - * @param {Object} configObj - * - * { - * sourceClusterType {string}: Type of cluster to use as the source of the copy. Options are - * "single", "repl", "sharded". - * isSourceUsingAuth {bool}: Whether to use auth in the source cluster for the copy. - * targetClusterType {string}: Type of cluster to use as the target of the copy. Options are - * "single", "repl", "sharded". - * isTargetUsingAuth {bool}: Whether to use auth in the target cluster for the copy. - * } - */ -function copydbBetweenClustersTest(configObj) { - // First sanity check the arguments in our configObj - var requiredKeys = [ - 'sourceClusterType', - 'isSourceUsingAuth', - 'targetClusterType', - 'isTargetUsingAuth', - 'isSourceUsingTransitionToAuth', - 'isTargetUsingTransitionToAuth' - ]; - - var i; - for (i = 0; i < requiredKeys.length; i++) { - assert(configObj.hasOwnProperty(requiredKeys[i]), - "Missing required key: " + requiredKeys[i] + " in config object"); - } - - // 1. Get a connection to the source database, insert data and setup auth if applicable - source = new ClusterSpawnHelper(configObj.sourceClusterType, - configObj.isSourceUsingAuth, - configObj.isSourceUsingTransitionToAuth); - - if (configObj.isSourceUsingAuth) { - // Create a super user so we can create a regular user and not be locked out afterwards - source.conn.getDB("admin").createUser( - {user: "sourceSuperUser", pwd: "sourceSuperUser", roles: ["root"]}); - source.conn.getDB("admin").auth("sourceSuperUser", "sourceSuperUser"); - - source.conn.getDB(baseName)[baseName].save({i: 1}); - assert.eq(1, source.conn.getDB(baseName)[baseName].count()); - assert.eq(1, source.conn.getDB(baseName)[baseName].findOne().i); - - // Insert a document and create a regular user that we will use for the target - // authenticating with the source - source.conn.getDB(baseName).createUser({user: "foo", pwd: "bar", roles: ["dbOwner"]}); - - source.conn.getDB("admin").logout(); - - var readWhenLoggedOut = function() { - source.conn.getDB(baseName)[baseName].findOne(); - }; - if (configObj.isSourceUsingTransitionToAuth) { - // transitionToAuth does not turn on access control - assert.doesNotThrow(readWhenLoggedOut); - } else { - assert.throws(readWhenLoggedOut); - } - } else { - source.conn.getDB(baseName)[baseName].save({i: 1}); - assert.eq(1, source.conn.getDB(baseName)[baseName].count()); - assert.eq(1, source.conn.getDB(baseName)[baseName].findOne().i); - } - - // 2. Get a connection to the target database, and set up auth if necessary - target = new ClusterSpawnHelper(configObj.targetClusterType, - configObj.isTargetUsingAuth, - configObj.isTargetUsingTransitionToAuth); - - if (configObj.isTargetUsingAuth) { - target.conn.getDB("admin").createUser( - {user: "targetSuperUser", pwd: "targetSuperUser", roles: ["root"]}); - - var readWhenLoggedOut = function() { - target.conn.getDB(baseName)[baseName].findOne(); - }; - if (configObj.isTargetUsingTransitionToAuth) { - // transitionToAuth does not turn on access control - assert.doesNotThrow(readWhenLoggedOut); - } else { - assert.throws(readWhenLoggedOut); - } - - target.conn.getDB("admin").auth("targetSuperUser", "targetSuperUser"); - } - - // 3. Run the copydb command - target.conn.getDB(baseName).dropDatabase(); - assert.eq(0, target.conn.getDB(baseName)[baseName].count()); - if (configObj.isSourceUsingAuth) { - // We only need to pass username and password if the target has to send authentication - // information to the source cluster - assert.commandWorked(target.conn.getDB(baseName).copyDatabase( - baseName, baseName, source.connString, "foo", "bar")); - } else { - // We are copying from a cluster with no auth - assert.commandWorked( - target.conn.getDB(baseName).copyDatabase(baseName, baseName, source.connString)); - } - assert.eq(1, target.conn.getDB(baseName)[baseName].count()); - assert.eq(1, target.conn.getDB(baseName)[baseName].findOne().i); - - if (configObj.isTargetUsingAuth) { - target.conn.getDB("admin").logout(); - } - - // 4. Do any necessary cleanup - source.stop(); - target.stop(); -} - -(function() { - "use strict"; - - var sourceClusterTypeValues = ["single", "repl", "sharded"]; - var isSourceUsingAuthValues = [true, false]; - var isSourceUsingTransitionToAuthValues = [true, false]; - var targetClusterTypeValues = ["single", "repl", "sharded"]; - var isTargetUsingAuthValues = [true, false]; - var isTargetUsingTransitionToAuthValues = [true, false]; - for (var i = 0; i < sourceClusterTypeValues.length; i++) { - for (var j = 0; j < isSourceUsingAuthValues.length; j++) { - for (var k = 0; k < targetClusterTypeValues.length; k++) { - for (var l = 0; l < isTargetUsingAuthValues.length; l++) { - if (sourceClusterTypeValues[i] === "sharded" && - targetClusterTypeValues[k] === "sharded") { - // SERVER-13112 - continue; - } - if (sourceClusterTypeValues[i] === "repl" && - targetClusterTypeValues[k] === "repl") { - // SERVER-13077 - continue; - } - if (isSourceUsingAuthValues[j] === true && - targetClusterTypeValues[k] === "sharded") { - // SERVER-6427 - continue; - } - if (sourceClusterTypeValues[i] === "repl" && - isSourceUsingAuthValues[j] === false && - targetClusterTypeValues[k] === "sharded" && - isTargetUsingAuthValues[l] === true) { - // SERVER-18103 - continue; - } - - for (var m = 0; m < isSourceUsingTransitionToAuthValues.length; m++) { - if (isSourceUsingTransitionToAuthValues[m] === true && - isSourceUsingAuthValues[j] === false) { - // transitionToAuth requires auth parameters - continue; - } - for (var n = 0; n < isTargetUsingTransitionToAuthValues.length; n++) { - if (isTargetUsingTransitionToAuthValues[n] === true && - isTargetUsingAuthValues[l] === false) { - // transitionToAuth requires auth parameters - continue; - } - var testCase = { - 'sourceClusterType': sourceClusterTypeValues[i], - 'isSourceUsingAuth': isSourceUsingAuthValues[j], - 'targetClusterType': targetClusterTypeValues[k], - 'isTargetUsingAuth': isTargetUsingAuthValues[l], - 'isSourceUsingTransitionToAuth': - isSourceUsingTransitionToAuthValues[m], - 'isTargetUsingTransitionToAuth': - isTargetUsingTransitionToAuthValues[n] - }; - print("Running copydb with auth test:"); - printjson(testCase); - copydbBetweenClustersTest(testCase); - } - } - } - } - } - } -}()); -print(baseName + " success!"); diff --git a/jstests/auth/copyauth2.js b/jstests/auth/copyauth2.js deleted file mode 100644 index 3355e6d67d1..00000000000 --- a/jstests/auth/copyauth2.js +++ /dev/null @@ -1,44 +0,0 @@ -// Basic test that copydb works with auth enabled when copying within the same cluster -// @tags: [requires_sharding] - -function runTest(a, b) { - a.createUser({user: "chevy", pwd: "chase", roles: ["read", {role: 'readWrite', db: b._name}]}); - a.foo.insert({a: 1}); - b.getSiblingDB("admin").logout(); - - a.auth("chevy", "chase"); - - assert.eq(1, a.foo.count(), "A"); - assert.eq(0, b.foo.count(), "B"); - - a.copyDatabase(a._name, b._name); - assert.eq(1, a.foo.count(), "C"); - assert.eq(1, b.foo.count(), "D"); -} - -// run all tests standalone -var conn = MongoRunner.runMongod({auth: ""}); -var a = conn.getDB("copydb2-test-a"); -var b = conn.getDB("copydb2-test-b"); -var adminDB = conn.getDB("admin"); -adminDB.createUser({user: "root", pwd: "root", roles: ["root"]}); -adminDB.auth("root", "root"); -runTest(a, b); -MongoRunner.stopMongod(conn); - -/** Doesn't work in a sharded setup due to SERVER-13080 -// run all tests sharded -var st = new ShardingTest({ - shards: 2, - mongos: 1, - keyFile: "jstests/libs/key1", -}); -var a = st.s.getDB( "copydb2-test-a" ); -var b = st.s.getDB( "copydb2-test-b" ); -st.s.getDB( "admin" ).createUser({user: "root", pwd: "root", roles: ["root"]}); -st.s.getDB( "admin" ).auth("root", "root"); -runTest(a, b); -st.stop(); -*/ - -print("Successfully completed copyauth2.js test."); diff --git a/jstests/auth/copyauth_between_shards.js b/jstests/auth/copyauth_between_shards.js deleted file mode 100644 index aed4a6847a0..00000000000 --- a/jstests/auth/copyauth_between_shards.js +++ /dev/null @@ -1,60 +0,0 @@ -// Test copyDatabase command inside a sharded cluster with and without auth. Tests with auth are -// currently disabled due to SERVER-13080. -// @tags: [requires_sharding, requires_replication] - -var baseName = "jstests_clone_copyauth_between_shards"; - -function copydbWithinShardedCluster(useReplSets, passCredentials, useAuth) { - var clusterConfig = {shards: 1, mongos: 1, config: 1}; - - if (useAuth) { - clusterConfig.auth = ""; - clusterConfig.keyFile = "jstests/libs/key1"; - } - - if (useReplSets) { - clusterConfig.rs = {}; - } - var st = new ShardingTest(clusterConfig); - - var mongos = st.s; - - var test1 = mongos.getDB('test1'); - var test2 = mongos.getDB('test2'); - - if (useAuth) { - mongos.getDB("admin").createUser({user: "super", pwd: "super", roles: ["root"]}); - assert.throws(function() { - mongos.getDB("test1")["test1"].findOne(); - }); - mongos.getDB("admin").auth("super", "super"); - } - - test1.getCollection('test').insert({foo: 'bar'}); - jsTestLog('Test document on source db:'); - printjson(test1.getCollection('test').findOne()); - jsTestLog('copydb'); - - // The copyDatabase command acts differently depending on whether we pass username and password - if (passCredentials) { - var result = - mongos.getDB('admin').copyDatabase('test1', 'test2', undefined, "super", "super"); - } else { - var result = mongos.getDB('admin').copyDatabase('test1', 'test2'); - } - printjson(result); - assert.eq(result.ok, 1.0); - jsTestLog('Test document on destination db:'); - printjson(test2.getCollection('test').findOne()); - st.stop(); -} - -// SERVER-13080 -// copydbWithinShardedCluster(true, true, true); -// copydbWithinShardedCluster(false, true, true); -// copydbWithinShardedCluster(true, false, true); -// copydbWithinShardedCluster(false, false, true); -copydbWithinShardedCluster(true, false, false); -copydbWithinShardedCluster(false, false, false); - -print(baseName + " success!"); diff --git a/jstests/auth/lib/commands_lib.js b/jstests/auth/lib/commands_lib.js index ed7ae60138b..f3635477545 100644 --- a/jstests/auth/lib/commands_lib.js +++ b/jstests/auth/lib/commands_lib.js @@ -2291,26 +2291,6 @@ var authCommandsLib = { ] }, { - testname: "copydb", - command: {copydb: 1, fromdb: firstDbName, todb: secondDbName}, - skipSharded: true, // Does not work sharded due to SERVER-13080 - testcases: [ - { - runOnDb: adminDbName, - roles: {readWriteAnyDatabase: 1, root: 1, __system: 1}, - privileges: [ - {resource: {db: firstDbName, collection: ""}, actions: ["find"]}, - {resource: {db: firstDbName, collection: "system.js"}, actions: ["find"]}, - { - resource: {db: secondDbName, collection: ""}, - actions: ["insert", "createIndex"] - }, - {resource: {db: secondDbName, collection: "system.js"}, actions: ["insert"]}, - ] - }, - ] - }, - { testname: "createRole_authenticationRestrictions", command: { createRole: "testRole", diff --git a/jstests/auth/localhostAuthBypass.js b/jstests/auth/localhostAuthBypass.js index e3bb03b661d..f68ed6dfba4 100644 --- a/jstests/auth/localhostAuthBypass.js +++ b/jstests/auth/localhostAuthBypass.js @@ -54,11 +54,8 @@ var assertCannotRunCommands = function(mongo) { assert.throws(function() { mongo.getDB("test").createUser({user: username, pwd: password, roles: ['readWrite']}); }); - // DB operations - var authorizeErrorCode = 13; - assert.commandFailedWithCode( - mongo.getDB("test").copyDatabase("admin", "admin2"), authorizeErrorCode, "copyDatabase"); // Create collection + var authorizeErrorCode = 13; assert.commandFailedWithCode( mongo.getDB("test").createCollection("log", {capped: true, size: 5242880, max: 5000}), authorizeErrorCode, diff --git a/jstests/core/auth_copydb.js b/jstests/core/auth_copydb.js deleted file mode 100644 index b8a85ae1c03..00000000000 --- a/jstests/core/auth_copydb.js +++ /dev/null @@ -1,26 +0,0 @@ -// @tags: [ -// requires_non_retryable_commands, -// requires_fastcount, -// requires_auth, -// assumes_write_concern_unchanged -// ] - -a = db.getSisterDB("copydb2-test-a"); -b = db.getSisterDB("copydb2-test-b"); - -a.dropDatabase(); -b.dropDatabase(); -a.dropAllUsers(); -b.dropAllUsers(); - -a.foo.save({a: 1}); - -a.createUser({user: "chevy", pwd: "chase", roles: jsTest.basicUserRoles}); - -assert.eq(1, a.foo.count(), "A"); -assert.eq(0, b.foo.count(), "B"); - -// SERVER-727 -a.copyDatabase(a._name, b._name, "", "chevy", "chase"); -assert.eq(1, a.foo.count(), "C"); -assert.eq(1, b.foo.count(), "D"); diff --git a/jstests/core/bypass_doc_validation.js b/jstests/core/bypass_doc_validation.js index d05d20cf2ca..b3290ef4e04 100644 --- a/jstests/core/bypass_doc_validation.js +++ b/jstests/core/bypass_doc_validation.js @@ -5,7 +5,6 @@ * * - aggregation with $out * - applyOps (when not sharded) - * - copyDb * - doTxn (when not sharded) * - findAndModify * - insert @@ -85,19 +84,6 @@ coll.aggregate(pipeline, {bypassDocumentValidation: true}); assert.eq(1, outputColl.count({aggregation: 1})); - // Test the copyDb command. - const copyDbName = dbName + '_copy'; - const copyDb = myDb.getSiblingDB(copyDbName); - assert.commandWorked(copyDb.dropDatabase()); - let res = db.adminCommand( - {copydb: 1, fromdb: dbName, todb: copyDbName, bypassDocumentValidation: false}); - assertFailsValidation(res); - assert.eq(0, copyDb[collName].count()); - assert.commandWorked(copyDb.dropDatabase()); - assert.commandWorked(db.adminCommand( - {copydb: 1, fromdb: dbName, todb: copyDbName, bypassDocumentValidation: true})); - assert.eq(coll.count(), db.getSiblingDB(copyDbName)[collName].count()); - // Test the findAndModify command. assert.throws(function() { coll.findAndModify( @@ -114,7 +100,7 @@ const reduce = function() { return 'mapReduce'; }; - res = myDb.runCommand({ + let res = myDb.runCommand({ mapReduce: collName, map: map, reduce: reduce, diff --git a/jstests/core/collation.js b/jstests/core/collation.js index d6857527bdf..5d199ae8915 100644 --- a/jstests/core/collation.js +++ b/jstests/core/collation.js @@ -1899,41 +1899,6 @@ assert.eq(8, coll.findOne({_id: "foo"}).x); } - // Test that the collections created with the "copydb" command inherit the default collation of - // the corresponding collection. - { - const sourceDB = db.getSiblingDB("collation"); - const destDB = db.getSiblingDB("collation_cloned"); - - sourceDB.dropDatabase(); - destDB.dropDatabase(); - - // Create a collection with a non-simple default collation. - assert.commandWorked( - sourceDB.runCommand({create: coll.getName(), collation: {locale: "en", strength: 2}})); - var sourceCollectionInfos = sourceDB.getCollectionInfos({name: coll.getName()}); - - assert.writeOK(sourceDB[coll.getName()].insert({_id: "FOO"})); - assert.writeOK(sourceDB[coll.getName()].insert({_id: "bar"})); - assert.eq([{_id: "FOO"}], - sourceDB[coll.getName()].find({_id: "foo"}).toArray(), - "query should have performed a case-insensitive match"); - - assert.commandWorked( - sourceDB.adminCommand({copydb: 1, fromdb: sourceDB.getName(), todb: destDB.getName()})); - var destCollectionInfos = destDB.getCollectionInfos({name: coll.getName()}); - - // The namespace for the _id index will differ since the source and destination collections - // are in different databases. Same for UUID. - delete sourceCollectionInfos[0].idIndex.ns; - delete sourceCollectionInfos[0].info.uuid; - delete destCollectionInfos[0].idIndex.ns; - delete destCollectionInfos[0].info.uuid; - - assert.eq(sourceCollectionInfos, destCollectionInfos); - assert.eq([{_id: "FOO"}], destDB[coll.getName()].find({_id: "foo"}).toArray()); - } - // Test that the collection created with the "cloneCollectionAsCapped" command inherits the // default collation of the corresponding collection. We skip running this command in a sharded // cluster because it isn't supported by mongos. diff --git a/jstests/core/commands_namespace_parsing.js b/jstests/core/commands_namespace_parsing.js index 104b72f3456..db61de2b07b 100644 --- a/jstests/core/commands_namespace_parsing.js +++ b/jstests/core/commands_namespace_parsing.js @@ -233,13 +233,6 @@ assertFailsWithInvalidNamespacesForField( "to", {renameCollection: "test.b", to: ""}, isFullyQualified, isAdminCommand); - // Test copydb fails with an invalid fromdb name. - assertFailsWithInvalidNamespacesForField( - "fromdb", {copydb: 1, fromdb: "", todb: "b"}, isNotFullyQualified, isAdminCommand); - // Test copydb fails with an invalid todb name. - assertFailsWithInvalidNamespacesForField( - "todb", {copydb: 1, fromdb: "a", todb: ""}, isNotFullyQualified, isAdminCommand); - // Test drop fails with an invalid collection name. assertFailsWithInvalidNamespacesForField( "drop", {drop: ""}, isNotFullyQualified, isNotAdminCommand); diff --git a/jstests/core/copydb.js b/jstests/core/copydb.js deleted file mode 100644 index 991734f3f8d..00000000000 --- a/jstests/core/copydb.js +++ /dev/null @@ -1,28 +0,0 @@ -// @tags: [ -// requires_non_retryable_commands, -// requires_fastcount, -// -// # copyDatabase is not available on embedded -// incompatible_with_embedded -// ] - -// Basic tests for the copydb command. These only test copying from the same server; these do not -// test the ability of copydb to pull a database from another server (with or without auth). - -// Test basic command usage. -var db1 = db.getSisterDB("copydb-test-db1"); -var db2 = db.getSisterDB("copydb-test-db2"); -assert.commandWorked(db1.dropDatabase()); -assert.commandWorked(db2.dropDatabase()); -assert.writeOK(db1.foo.save({db1: 1})); -assert.commandWorked(db1.foo.ensureIndex({db1: 1})); -assert.eq(1, db1.foo.count(), "A"); -assert.eq(0, db2.foo.count(), "B"); -assert.commandWorked(db1.copyDatabase(db1._name, db2._name)); -assert.eq(1, db1.foo.count(), "C"); -assert.eq(1, db2.foo.count(), "D"); -assert.eq(db1.foo.getIndexes().length, db2.foo.getIndexes().length); - -// Test command input validation. -assert.commandFailed(db1.adminCommand( - {copydb: 1, fromdb: db1.getName(), todb: "copydb.invalid"})); // Name can't contain dot. diff --git a/jstests/core/system_profile.js b/jstests/core/system_profile.js index 5198feebe80..2a805ba8942 100644 --- a/jstests/core/system_profile.js +++ b/jstests/core/system_profile.js @@ -68,14 +68,3 @@ assert.commandWorked(testDB.dropDatabase()); assert.commandWorked(testDB.createCollection("foo")); assert.commandFailed(testDB.adminCommand( {renameCollection: testDB.foo.getFullName(), to: testDB.system.profile.getFullName()})); - -// Copying a database containing "system.profile" should succeed. The "system.profile" collection -// should not be copied. -assert.commandWorked(testDB.dropDatabase()); -assert.commandWorked(testDB.createCollection("foo")); -assert.commandWorked(testDB.createCollection("system.profile")); -assert.commandWorked(testDBCopy.dropDatabase()); -assert.commandWorked( - testDB.adminCommand({copydb: 1, fromdb: testDB.getName(), todb: testDBCopy.getName()})); -assert(testDBCopy.foo.exists()); -assert.isnull(testDBCopy.system.profile.exists()); diff --git a/jstests/core/views/views_all_commands.js b/jstests/core/views/views_all_commands.js index b6f21425b0c..4283f459268 100644 --- a/jstests/core/views/views_all_commands.js +++ b/jstests/core/views/views_all_commands.js @@ -131,7 +131,6 @@ skip: "Tested in views/views_sharded.js", }, clearLog: {skip: isUnrelated}, - clone: {skip: "Tested in replsets/cloneDb.js"}, cloneCollection: {skip: "Tested in noPassthroughWithMongod/clonecollection.js"}, cloneCollectionAsCapped: { command: {cloneCollectionAsCapped: "view", toCollection: "testcapped", size: 10240}, @@ -147,7 +146,6 @@ connectionStatus: {skip: isUnrelated}, convertToCapped: {command: {convertToCapped: "view", size: 12345}, expectFailure: true}, coordinateCommitTransaction: {skip: isUnrelated}, - copydb: {skip: "Tested in replsets/copydb.js"}, copydbsaslstart: {skip: isUnrelated}, count: {command: {count: "view"}}, cpuload: {skip: isAnInternalCommand}, diff --git a/jstests/libs/override_methods/auto_retry_on_network_error.js b/jstests/libs/override_methods/auto_retry_on_network_error.js index c68d0de200c..a37f9d1650e 100644 --- a/jstests/libs/override_methods/auto_retry_on_network_error.js +++ b/jstests/libs/override_methods/auto_retry_on_network_error.js @@ -67,7 +67,6 @@ "cloneCollectionAsCapped", "collMod", "convertToCapped", - "copydb", "create", "createIndexes", "createRole", diff --git a/jstests/libs/override_methods/set_read_and_write_concerns.js b/jstests/libs/override_methods/set_read_and_write_concerns.js index b41faa315df..b68d6c1c5a4 100644 --- a/jstests/libs/override_methods/set_read_and_write_concerns.js +++ b/jstests/libs/override_methods/set_read_and_write_concerns.js @@ -65,7 +65,6 @@ "collMod", "commitTransaction", "convertToCapped", - "copydb", "create", "createIndexes", "createRole", diff --git a/jstests/noPassthrough/copydb_illegal_collections.js b/jstests/noPassthrough/copydb_illegal_collections.js deleted file mode 100644 index 29c41d08ffc..00000000000 --- a/jstests/noPassthrough/copydb_illegal_collections.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * This test creates a replica set and tries copying the local database. It expects an error on - * the `copydb` command when it runs across an illegal namespace to copy, e.g: - * `local.system.replset` -> `db2.system.replset`. - * @tags: [requires_replication, requires_persistence] - */ -(function() { - "use strict"; - var rst = new ReplSetTest({nodes: 1}); - - rst.startSet(); - rst.initiate(); - - var conn = rst.getPrimary(); // Waits for PRIMARY state. - conn = rst.restart(0, {noReplSet: true}); // Restart as a standalone node. - assert.neq(null, conn, "failed to restart"); - - // Must drop the oplog in order to induce the correct error below. - conn.getDB("local").oplog.rs.drop(); - - var db1 = conn.getDB("local"); - var db2 = conn.getDB("db2"); - - var res = db1.adminCommand({copydb: 1, fromdb: db1._name, todb: db2._name}); - - assert.commandFailedWithCode(res, ErrorCodes.InvalidNamespace); - assert.gt(res["errmsg"].indexOf("cannot write to 'db2.system.replset'"), -1); - rst.stopSet(); -})(); diff --git a/jstests/noPassthrough/index_version_autoupgrade.js b/jstests/noPassthrough/index_version_autoupgrade.js index c9b4e523448..f6bbb55eee8 100644 --- a/jstests/noPassthrough/index_version_autoupgrade.js +++ b/jstests/noPassthrough/index_version_autoupgrade.js @@ -129,16 +129,6 @@ return coll; }, false); - // Test that the "copydb" command doesn't upgrade existing indexes to the latest version. - testIndexVersionAutoUpgrades(function(coll) { - assert.commandWorked(coll.getDB().adminCommand({ - copydb: 1, - fromdb: coll.getDB().getName(), - todb: "copied", - })); - return coll.getDB().getSiblingDB("copied")[coll.getName()]; - }, false); - // Test that the "cloneCollection" command doesn't upgrade existing indexes to the latest // version. var cloneConn = MongoRunner.runMongod({}); @@ -153,18 +143,5 @@ }, false); MongoRunner.stopMongod(cloneConn); - // Test that the "clone" command doesn't upgrade existing indexes to the latest version. - cloneConn = MongoRunner.runMongod({}); - assert.neq(null, cloneConn, "mongod was unable to start up"); - testIndexVersionAutoUpgrades(function(coll) { - var cloneDB = cloneConn.getDB(coll.getDB().getName()); - assert.commandWorked(cloneDB.runCommand({ - clone: conn.host, - fromDB: coll.getDB().getName(), - })); - return cloneDB[coll.getName()]; - }, false); - MongoRunner.stopMongod(cloneConn); - MongoRunner.stopMongod(conn); })(); diff --git a/jstests/noPassthroughWithMongod/server7428.js b/jstests/noPassthroughWithMongod/server7428.js deleted file mode 100644 index 7b5278a10e1..00000000000 --- a/jstests/noPassthroughWithMongod/server7428.js +++ /dev/null @@ -1,24 +0,0 @@ -// Regression test for SERVER-7428. - -// TODO(spencer): move this test out of slowNightly directory once there is a better place for tests -// that start their own mongod's but aren't slow - -// Verify that the copyDatabase command works appropriately when the -// target mongo instance has authentication enabled. - -(function() { - - // Setup fromDb with no auth - var fromDb = MongoRunner.runMongod(); - - // Setup toDb with auth - var toDb = MongoRunner.runMongod({auth: ""}); - var admin = toDb.getDB("admin"); - admin.createUser({user: "foo", pwd: "bar", roles: jsTest.adminUserRoles}); - admin.auth("foo", "bar"); - - admin.copyDatabase('test', 'test', fromDb.host); - - MongoRunner.stopMongod(fromDb); - MongoRunner.stopMongod(toDb); -})(); diff --git a/jstests/replsets/cloneDb.js b/jstests/replsets/cloneDb.js deleted file mode 100644 index f4ed71bb972..00000000000 --- a/jstests/replsets/cloneDb.js +++ /dev/null @@ -1,128 +0,0 @@ -// Test cloning a database from a replica set (as full replica set uri, just the PRIMARY, or just a -// SECONDARY) to a standalone server and viceversa (SERVER-1643) - -(function() { - "use strict"; - - if (jsTest.options().keyFile) { - jsTest.log("Skipping test because clone command doesn't work with authentication enabled:" + - " SERVER-4245"); - } else { - var numDocs = 2000; - - // 1kb string - var str = new Array(1000).toString(); - - var replsetDBName = 'cloneDBreplset'; - var standaloneDBName = 'cloneDBstandalone'; - var testColName = 'foo'; - var testViewName = 'view'; - - jsTest.log("Create replica set"); - var replTest = new ReplSetTest({name: 'testSet', nodes: 3}); - replTest.startSet(); - replTest.initiate(); - var master = replTest.getPrimary(); - var secondary = replTest._slaves[0]; - var masterDB = master.getDB(replsetDBName); - masterDB.dropDatabase(); - - jsTest.log("Create standalone server"); - var standalone = MongoRunner.runMongod(); - standalone.getDB("admin").runCommand({setParameter: 1, logLevel: 5}); - var standaloneDB = standalone.getDB(replsetDBName); - standaloneDB.dropDatabase(); - - jsTest.log("Insert data into replica set"); - var bulk = masterDB[testColName].initializeUnorderedBulkOp(); - for (var i = 0; i < numDocs; i++) { - bulk.insert({x: i, text: str}); - } - assert.writeOK(bulk.execute({w: 3})); - - jsTest.log("Create view on replica set"); - assert.commandWorked(masterDB.runCommand({create: testViewName, viewOn: testColName})); - - // Make sure all writes have replicated to secondary. - replTest.awaitReplication(); - - jsTest.log("Clone db from replica set to standalone server"); - standaloneDB.cloneDatabase(replTest.getURL()); - assert.eq(numDocs, - standaloneDB[testColName].find().itcount(), - 'cloneDatabase from replset to standalone failed (document counts do not match)'); - assert.eq(numDocs, - standaloneDB[testViewName].find().itcount(), - 'cloneDatabase from replset to standalone failed (count on view incorrect)'); - - jsTest.log("Clone db from replica set PRIMARY to standalone server"); - standaloneDB.dropDatabase(); - standaloneDB.cloneDatabase(master.host); - assert.eq(numDocs, - standaloneDB[testColName].find().itcount(), - 'cloneDatabase from PRIMARY to standalone failed (document counts do not match)'); - assert.eq(numDocs, - standaloneDB[testViewName].find().itcount(), - 'cloneDatabase from PRIMARY to standalone failed (count on view incorrect)'); - - jsTest.log("Clone db from replica set SECONDARY to standalone server (should not copy)"); - standaloneDB.dropDatabase(); - standaloneDB.cloneDatabase(secondary.host); - assert.eq( - 0, - standaloneDB[testColName].find().itcount(), - 'cloneDatabase from SECONDARY to standalone copied documents without slaveOk: true'); - - jsTest.log("Clone db from replica set SECONDARY to standalone server using slaveOk"); - standaloneDB.dropDatabase(); - standaloneDB.runCommand({clone: secondary.host, slaveOk: true}); - assert.eq( - numDocs, - standaloneDB[testColName].find().itcount(), - 'cloneDatabase from SECONDARY to standalone failed (document counts do not match)'); - assert.eq(numDocs, - standaloneDB[testViewName].find().itcount(), - 'cloneDatabase from SECONDARY to standalone failed (count on view incorrect)'); - - jsTest.log("Switch db and insert data into standalone server"); - masterDB = master.getDB(standaloneDBName); - var secondaryDB = secondary.getDB(standaloneDBName); - standaloneDB = standalone.getDB(standaloneDBName); - masterDB.dropDatabase(); - secondaryDB.dropDatabase(); - standaloneDB.dropDatabase(); - - bulk = standaloneDB[testColName].initializeUnorderedBulkOp(); - for (var i = 0; i < numDocs; i++) { - bulk.insert({x: i, text: str}); - } - assert.writeOK(bulk.execute()); - - assert.commandWorked(standaloneDB.runCommand({create: testViewName, viewOn: testColName})); - - jsTest.log("Clone db from standalone server to replica set PRIMARY"); - masterDB.cloneDatabase(standalone.host); - replTest.awaitReplication(); - assert.eq(numDocs, - masterDB[testColName].find().itcount(), - 'cloneDatabase from standalone to PRIMARY failed (document counts do not match)'); - assert.eq(numDocs, - masterDB[testViewName].find().itcount(), - 'cloneDatabase from standalone to PRIMARY failed (count on view incorrect)'); - - jsTest.log("Clone db from standalone server to replica set SECONDARY"); - masterDB.dropDatabase(); - replTest.awaitReplication(); - secondaryDB.cloneDatabase(standalone.host); - assert.eq( - 0, - secondaryDB[testColName].find().itcount(), - 'cloneDatabase from standalone to SECONDARY succeeded and should not accept writes'); - - jsTest.log("Shut down replica set and standalone server"); - MongoRunner.stopMongod(standalone); - - replTest.stopSet(); - } - -})(); diff --git a/jstests/replsets/copydb.js b/jstests/replsets/copydb.js deleted file mode 100644 index 2c11e553618..00000000000 --- a/jstests/replsets/copydb.js +++ /dev/null @@ -1,97 +0,0 @@ -// Tests the copydb command in a replica set. -// Ensures that documents and indexes are replicated to secondary. - -(function() { - 'use strict'; - - var replTest = new ReplSetTest({name: 'copydbTest', nodes: 3}); - - replTest.startSet(); - replTest.initiate(); - var primary = replTest.getPrimary(); - var secondary = replTest._slaves[0]; - - var sourceDBName = 'copydb-repl-test-source'; - var targetDBName = 'copydb-repl-test-target'; - - var primarySourceDB = primary.getDB(sourceDBName); - assert.commandWorked(primarySourceDB.dropDatabase(), - 'failed to drop source database ' + sourceDBName + ' on primary'); - - var primaryTargetDB = primary.getDB(targetDBName); - assert.commandWorked(primaryTargetDB.dropDatabase(), - 'failed to drop target database ' + targetDBName + ' on primary'); - - assert.writeOK(primarySourceDB.foo.save({a: 1}), - 'failed to insert document in source collection'); - assert.commandWorked(primarySourceDB.foo.ensureIndex({a: 1}), - 'failed to create index in source collection on primary'); - assert.commandWorked(primarySourceDB.runCommand({create: "fooView", viewOn: "foo"}), - 'failed to create view on source collection on primary'); - - assert.eq(1, - primarySourceDB.foo.find().itcount(), - 'incorrect number of documents in source collection on primary before copy'); - assert.eq(1, - primarySourceDB.fooView.find().itcount(), - 'incorrect number of documents in source view on primary before copy'); - assert.eq(0, - primaryTargetDB.foo.find().itcount(), - 'target collection on primary should be empty before copy'); - - assert.commandWorked( - primarySourceDB.copyDatabase(primarySourceDB.getName(), primaryTargetDB.getName()), - 'failed to copy database'); - - assert.eq(primarySourceDB.foo.find().itcount(), - primaryTargetDB.foo.find().itcount(), - 'incorrect number of documents in target collection on primary after copy'); - - // Confirm that 'fooView' is still a view namespace after copy. - let res = primaryTargetDB.runCommand({listCollections: 1, filter: {name: "fooView"}}); - assert.commandWorked(res); - assert(res.cursor.firstBatch.length === 1); - assert(res.cursor.firstBatch[0].hasOwnProperty("type"), tojson(res)); - assert.eq("view", - res.cursor.firstBatch[0].type, - "Namespace exected to be view: " + tojson(res.cursor.firstBatch[0])); - - assert.eq(primarySourceDB.fooView.find().itcount(), - primaryTargetDB.fooView.find().itcount(), - 'incorrect number of documents in target view on primary after copy'); - - assert.eq(primarySourceDB.foo.getIndexes().length, - primaryTargetDB.foo.getIndexes().length, - 'incorrect number of indexes in target collection on primary after copy'); - - replTest.awaitReplication(); - - var secondarySourceDB = secondary.getDB(sourceDBName); - - assert.eq(primarySourceDB.foo.find().itcount(), - secondarySourceDB.foo.find().itcount(), - 'incorrect number of documents in source collection on secondary after copy'); - - assert.eq(primarySourceDB.fooView.find().itcount(), - secondarySourceDB.fooView.find().itcount(), - 'incorrect number of documents in source view on secondary after copy'); - - assert.eq(primarySourceDB.foo.getIndexes().length, - secondarySourceDB.foo.getIndexes().length, - 'incorrect number of indexes in source collection on secondary after copy'); - - var secondaryTargetDB = secondary.getDB(targetDBName); - - assert.eq(primaryTargetDB.foo.find().itcount(), - secondaryTargetDB.foo.find().itcount(), - 'incorrect number of documents in target collection on secondary after copy'); - - assert.eq(primaryTargetDB.fooView.find().itcount(), - secondaryTargetDB.fooView.find().itcount(), - 'incorrect number of documents in target view on secondary after copy'); - - assert.eq(primaryTargetDB.foo.getIndexes().length, - secondaryTargetDB.foo.getIndexes().length, - 'incorrect number of indexes in target collection on secondary after copy'); - replTest.stopSet(); -}()); diff --git a/jstests/replsets/localhostAuthBypass.js b/jstests/replsets/localhostAuthBypass.js index 22a512f19d0..5a0a1b95562 100644 --- a/jstests/replsets/localhostAuthBypass.js +++ b/jstests/replsets/localhostAuthBypass.js @@ -43,11 +43,8 @@ var assertCannotRunCommands = function(mongo, isPrimary) { {out: "other"}); }); - // DB operations - var authorizeErrorCode = 13; - assert.commandFailedWithCode( - mongo.getDB("test").copyDatabase("admin", "admin2"), authorizeErrorCode, "copyDatabase"); // Create collection + var authorizeErrorCode = 13; assert.commandFailedWithCode( mongo.getDB("test").createCollection("log", {capped: true, size: 5242880, max: 5000}), authorizeErrorCode, diff --git a/jstests/sharding/auth_copydb.js b/jstests/sharding/auth_copydb.js deleted file mode 100644 index 1c732546b2b..00000000000 --- a/jstests/sharding/auth_copydb.js +++ /dev/null @@ -1,49 +0,0 @@ -// Tests the copydb command on mongos with auth -(function() { - 'use strict'; - load('jstests/libs/feature_compatibility_version.js'); - - // TODO: Remove 'shardAsReplicaSet: false' when SERVER-32672 is fixed. - var st = new ShardingTest( - {shards: 1, mongos: 1, other: {keyFile: 'jstests/libs/key1', shardAsReplicaSet: false}}); - var mongos = st.s0; - var destAdminDB = mongos.getDB('admin'); - var destTestDB = mongos.getDB('test'); - - var sourceMongodConn = MongoRunner.runMongod({}); - var sourceTestDB = sourceMongodConn.getDB('test'); - - // Ensure sourceMongodConn has featureCompatibilityVersion=lastStableFCV so that the sharded - // cluster can communicate with it if it has featureCompatibilityVersion=lastStableFCV - assert.commandWorked( - sourceMongodConn.adminCommand({setFeatureCompatibilityVersion: lastStableFCV})); - - sourceTestDB.foo.insert({a: 1}); - - destAdminDB.createUser({ - user: 'admin', - pwd: 'password', - roles: jsTest.adminUserRoles - }); // Turns on access control enforcement - - jsTestLog("Running copydb that should fail"); - var res = destAdminDB.runCommand( - {copydb: 1, fromhost: sourceMongodConn.host, fromdb: 'test', todb: 'test'}); - printjson(res); - assert.commandFailed(res); - - destAdminDB.auth('admin', 'password'); - assert.eq(0, destTestDB.foo.count()); // Be extra sure the copydb didn't secretly succeed. - - jsTestLog("Running copydb that should succeed"); - res = destAdminDB.runCommand( - {copydb: 1, fromhost: sourceMongodConn.host, fromdb: 'test', todb: 'test'}); - printjson(res); - assert.commandWorked(res); - - assert.eq(1, destTestDB.foo.count()); - assert.eq(1, destTestDB.foo.findOne().a); - - st.stop(); - MongoRunner.stopMongod(sourceMongodConn); -})(); diff --git a/jstests/sharding/copydb_from_mongos.js b/jstests/sharding/copydb_from_mongos.js deleted file mode 100644 index 66db42407ca..00000000000 --- a/jstests/sharding/copydb_from_mongos.js +++ /dev/null @@ -1,22 +0,0 @@ -(function() { - - var st = new ShardingTest({shards: 1}); - - var testDB = st.s.getDB('test'); - assert.writeOK(testDB.foo.insert({a: 1})); - - var res = - testDB.adminCommand({copydb: 1, fromhost: st.s.host, fromdb: 'test', todb: 'test_copy'}); - assert.commandWorked(res); - - var copy = st.s.getDB('test_copy'); - assert.eq(1, copy.foo.count()); - assert.eq(1, copy.foo.findOne().a); - - // Test invalid todb database name. - assert.commandFailed(testDB.adminCommand( - {copydb: 1, fromhost: st.s.host, fromdb: 'test_copy', todb: 'test/copy'})); - - st.stop(); - -})(); diff --git a/jstests/sharding/database_and_shard_versioning_all_commands.js b/jstests/sharding/database_and_shard_versioning_all_commands.js index ec7a1c564fe..09b60667d4c 100644 --- a/jstests/sharding/database_and_shard_versioning_all_commands.js +++ b/jstests/sharding/database_and_shard_versioning_all_commands.js @@ -6,20 +6,13 @@ 'use strict'; load('jstests/libs/profiler.js'); + load('jstests/sharding/libs/last_stable_mongos_commands.js'); const dbName = "test"; const collName = "foo"; const ns = dbName + "." + collName; const SHARD_VERSION_UNSHARDED = [Timestamp(0, 0), ObjectId("000000000000000000000000")]; - // These commands exist in the 4.0 mongo shell, so we must define a test case in mixed version - // suites. However, a check exists in this test that asserts that every command tested exists - // on mongos. In an all-4.2 environment, these commands won't exist. To increase test coverage, - // and allow us to run on same- and mixed-version suites, we will allow these commands to have - // a test defined without always existing on the mongos being used. - const fcv40OnlyCommands = - ['abortTransaction', 'commitTransaction', 'eval', 'geoNear', 'group', 'reIndex']; - function validateTestCase(testCase) { assert(testCase.skip || testCase.command, "must specify exactly one of 'skip' or 'command' for test case " + tojson(testCase)); @@ -115,7 +108,6 @@ assert(mongosConn.getDB(dbName).getCollection(collName).drop()); } }, - copydb: {skip: "not allowed through mongos"}, count: { sendsDbVersion: true, sendsShardVersion: true, @@ -207,7 +199,6 @@ echo: {skip: "does not forward command to primary shard"}, enableSharding: {skip: "does not forward command to primary shard"}, endSessions: {skip: "goes through the cluster write path"}, - eval: {skip: "must define test coverage for 4.0 backwards compatibility"}, explain: {skip: "TODO SERVER-31226"}, features: {skip: "executes locally on mongos (not sent to any remote node)"}, filemd5: { @@ -227,7 +218,6 @@ }, flushRouterConfig: {skip: "executes locally on mongos (not sent to any remote node)"}, fsync: {skip: "broadcast to all shards"}, - geoNear: {skip: "must define test coverage for 4.0 backwards compatibility"}, getCmdLineOpts: {skip: "executes locally on mongos (not sent to any remote node)"}, getDiagnosticData: {skip: "executes locally on mongos (not sent to any remote node)"}, getLastError: {skip: "does not forward command to primary shard"}, @@ -241,7 +231,6 @@ grantPrivilegesToRole: {skip: "always targets the config server"}, grantRolesToRole: {skip: "always targets the config server"}, grantRolesToUser: {skip: "always targets the config server"}, - group: {skip: "must define test coverage for 4.0 backwards compatibility"}, hostInfo: {skip: "executes locally on mongos (not sent to any remote node)"}, insert: { sendsDbVersion: false, @@ -361,7 +350,6 @@ refreshLogicalSessionCacheNow: {skip: "goes through the cluster write path"}, refreshSessions: {skip: "executes locally on mongos (not sent to any remote node)"}, refreshSessionsInternal: {skip: "executes locally on mongos (not sent to any remote node)"}, - reIndex: {skip: "must define test coverage for 4.0 backwards compatibility"}, removeShard: {skip: "not on a user database"}, removeShardFromZone: {skip: "not on a user database"}, renameCollection: { @@ -432,6 +420,10 @@ whatsmyuri: {skip: "executes locally on mongos (not sent to any remote node)"}, }; + commandsRemovedFromMongosIn42.forEach(function(cmd) { + testCases[cmd] = {skip: "must define test coverage for 4.0 backwards compatibility"}; + }); + class AllCommandsTestRunner { constructor() { this.st = new ShardingTest(this.getShardingTestOptions()); @@ -548,7 +540,15 @@ // After iterating through all the existing commands, ensure there were no additional // test cases that did not correspond to any mongos command. for (let key of Object.keys(testCases)) { - if (fcv40OnlyCommands.includes(key)) { + // We have defined real test cases for commands added in 4.2 so that the test cases + // are exercised in the regular suites, but because these test cases can't run in + // the last stable suite, we skip processing them here to avoid failing the below + // assertion. We have defined "skip" test cases for commands removed in 4.2 so the + // test case is defined in last stable suites (in which these commands still exist + // on the mongos), but these test cases won't be run in regular suites, so we skip + // processing them below as well. + if (commandsAddedToMongosIn42.includes(key) || + commandsRemovedFromMongosIn42.includes(key)) { continue; } assert(testCases[key].validated || testCases[key].conditional, diff --git a/jstests/sharding/libs/last_stable_mongos_commands.js b/jstests/sharding/libs/last_stable_mongos_commands.js new file mode 100644 index 00000000000..43a1da0acfa --- /dev/null +++ b/jstests/sharding/libs/last_stable_mongos_commands.js @@ -0,0 +1,16 @@ +// These commands were removed from mongos 4.2, but will still appear in the listCommands output +// of a 4.0 mongos. A last-stable mongos will be unable to run a command on a latest version shard +// that no longer supports that command. To increase test coverage and allow us to run on same- and +// mixed-version suites, we allow these commands to have a test defined without always existing on +// the servers being used. +const commandsRemovedFromMongosIn42 = [ + 'copydb', + 'eval', + 'geoNear', + 'group', + 'reIndex', +]; +// These commands were added in mongos 4.2, so will not appear in the listCommands output of a 4.0 +// mongos. We will allow these commands to have a test defined without always existing on the mongos +// being used. +const commandsAddedToMongosIn42 = ['abortTransaction', 'commitTransaction']; diff --git a/jstests/sharding/localhostAuthBypass.js b/jstests/sharding/localhostAuthBypass.js index d2035acdba2..996fb949175 100644 --- a/jstests/sharding/localhostAuthBypass.js +++ b/jstests/sharding/localhostAuthBypass.js @@ -95,9 +95,6 @@ TestData.skipCheckingUUIDsConsistentAcrossCluster = true; to: st.shard0.shardName // Arbitrary shard. }); assert.commandFailedWithCode(res, authorizeErrorCode, "moveChunk"); - assert.commandFailedWithCode(mongo.getDB("test").copyDatabase("admin", "admin2"), - authorizeErrorCode, - "copyDatabase"); // Create collection assert.commandFailedWithCode( mongo.getDB("test").createCollection("log", {capped: true, size: 5242880, max: 5000}), diff --git a/jstests/sharding/printShardingStatus.js b/jstests/sharding/printShardingStatus.js index 15fc549050e..25009589e67 100644 --- a/jstests/sharding/printShardingStatus.js +++ b/jstests/sharding/printShardingStatus.js @@ -88,7 +88,6 @@ // Take a copy of the config db, in order to test the harder-to-setup cases below. // Copy into a standalone to also test running printShardingStatus() against a config dump. - // TODO: Replace this manual copy with copydb once SERVER-13080 is fixed. var config = mongos.getDB("config"); var configCopy = standalone.getDB("configCopy"); config.getCollectionInfos().forEach(function(c) { diff --git a/jstests/sharding/safe_secondary_reads_drop_recreate.js b/jstests/sharding/safe_secondary_reads_drop_recreate.js index 65eb2e0c03b..e26497dfddd 100644 --- a/jstests/sharding/safe_secondary_reads_drop_recreate.js +++ b/jstests/sharding/safe_secondary_reads_drop_recreate.js @@ -20,6 +20,7 @@ "use strict"; load('jstests/libs/profiler.js'); + load('jstests/sharding/libs/last_stable_mongos_commands.js'); let db = "test"; let coll = "foo"; @@ -105,7 +106,6 @@ connPoolSync: {skip: "does not return user data"}, connectionStatus: {skip: "does not return user data"}, convertToCapped: {skip: "primary only"}, - copydb: {skip: "primary only"}, copydbsaslstart: {skip: "primary only"}, count: { setUp: function(mongosConn) { @@ -152,7 +152,6 @@ emptycapped: {skip: "primary only"}, enableSharding: {skip: "primary only"}, endSessions: {skip: "does not return user data"}, - eval: {skip: "must define test coverage for 4.0 backwards compatibility"}, explain: {skip: "TODO SERVER-30068"}, features: {skip: "does not return user data"}, filemd5: {skip: "does not return user data"}, @@ -172,7 +171,6 @@ forceerror: {skip: "does not return user data"}, fsync: {skip: "does not return user data"}, fsyncUnlock: {skip: "does not return user data"}, - geoNear: {skip: "must define test coverage for 4.0 backwards compatibility"}, geoSearch: {skip: "not supported in mongos"}, getCmdLineOpts: {skip: "does not return user data"}, getDiagnosticData: {skip: "does not return user data"}, @@ -188,7 +186,6 @@ grantPrivilegesToRole: {skip: "primary only"}, grantRolesToRole: {skip: "primary only"}, grantRolesToUser: {skip: "primary only"}, - group: {skip: "must define test coverage for 4.0 backwards compatibility"}, handshake: {skip: "does not return user data"}, hostInfo: {skip: "does not return user data"}, insert: {skip: "primary only"}, @@ -244,7 +241,6 @@ planCacheListQueryShapes: {skip: "does not return user data"}, planCacheSetFilter: {skip: "does not return user data"}, profile: {skip: "primary only"}, - reIndex: {skip: "does not return user data"}, reapLogicalSessionCacheNow: {skip: "does not return user data"}, refreshLogicalSessionCacheNow: {skip: "does not return user data"}, refreshSessions: {skip: "does not return user data"}, @@ -307,6 +303,10 @@ whatsmyuri: {skip: "does not return user data"} }; + commandsRemovedFromMongosIn42.forEach(function(cmd) { + testCases[cmd] = {skip: "must define test coverage for 4.0 backwards compatibility"}; + }); + let scenarios = { dropRecreateAsUnshardedOnSameShard: function( staleMongos, freshMongos, test, commandProfile) { diff --git a/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js b/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js index 67270de532a..6b682d1609d 100644 --- a/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js +++ b/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js @@ -25,6 +25,7 @@ "use strict"; load('jstests/libs/profiler.js'); + load('jstests/sharding/libs/last_stable_mongos_commands.js'); let db = "test"; let coll = "foo"; @@ -118,7 +119,6 @@ connPoolSync: {skip: "does not return user data"}, connectionStatus: {skip: "does not return user data"}, convertToCapped: {skip: "primary only"}, - copydb: {skip: "primary only"}, copydbsaslstart: {skip: "primary only"}, count: { setUp: function(mongosConn) { @@ -176,7 +176,6 @@ emptycapped: {skip: "primary only"}, enableSharding: {skip: "primary only"}, endSessions: {skip: "does not return user data"}, - eval: {skip: "must define test coverage for 4.0 backwards compatibility"}, explain: {skip: "TODO SERVER-30068"}, features: {skip: "does not return user data"}, filemd5: {skip: "does not return user data"}, @@ -202,7 +201,6 @@ forceerror: {skip: "does not return user data"}, fsync: {skip: "does not return user data"}, fsyncUnlock: {skip: "does not return user data"}, - geoNear: {skip: "must define test coverage for 4.0 backwards compatibility"}, geoSearch: {skip: "not supported in mongos"}, getCmdLineOpts: {skip: "does not return user data"}, getDiagnosticData: {skip: "does not return user data"}, @@ -218,7 +216,6 @@ grantPrivilegesToRole: {skip: "primary only"}, grantRolesToRole: {skip: "primary only"}, grantRolesToUser: {skip: "primary only"}, - group: {skip: "must define test coverage for 4.0 backwards compatibility"}, handshake: {skip: "does not return user data"}, hostInfo: {skip: "does not return user data"}, insert: {skip: "primary only"}, @@ -279,7 +276,6 @@ planCacheListQueryShapes: {skip: "does not return user data"}, planCacheSetFilter: {skip: "does not return user data"}, profile: {skip: "primary only"}, - reIndex: {skip: "does not return user data"}, reapLogicalSessionCacheNow: {skip: "does not return user data"}, refreshLogicalSessionCacheNow: {skip: "does not return user data"}, refreshSessions: {skip: "does not return user data"}, @@ -342,6 +338,10 @@ whatsmyuri: {skip: "does not return user data"} }; + commandsRemovedFromMongosIn42.forEach(function(cmd) { + testCases[cmd] = {skip: "must define test coverage for 4.0 backwards compatibility"}; + }); + // Set the secondaries to priority 0 and votes 0 to prevent the primaries from stepping down. let rsOpts = {nodes: [{rsConfig: {votes: 1}}, {rsConfig: {priority: 0, votes: 0}}]}; let st = new ShardingTest({mongos: 2, shards: {rs0: rsOpts, rs1: rsOpts}}); diff --git a/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js b/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js index 1f372a38fed..03822856590 100644 --- a/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js +++ b/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js @@ -20,6 +20,7 @@ "use strict"; load('jstests/libs/profiler.js'); + load('jstests/sharding/libs/last_stable_mongos_commands.js'); let db = "test"; let coll = "foo"; @@ -106,7 +107,6 @@ connPoolSync: {skip: "does not return user data"}, connectionStatus: {skip: "does not return user data"}, convertToCapped: {skip: "primary only"}, - copydb: {skip: "primary only"}, copydbsaslstart: {skip: "primary only"}, count: { setUp: function(mongosConn) { @@ -154,7 +154,6 @@ emptycapped: {skip: "primary only"}, enableSharding: {skip: "primary only"}, endSessions: {skip: "does not return user data"}, - eval: {skip: "must define test coverage for 4.0 backwards compatibility"}, explain: {skip: "TODO SERVER-30068"}, features: {skip: "does not return user data"}, filemd5: {skip: "does not return user data"}, @@ -175,7 +174,6 @@ forceerror: {skip: "does not return user data"}, fsync: {skip: "does not return user data"}, fsyncUnlock: {skip: "does not return user data"}, - geoNear: {skip: "must define test coverage for 4.0 backwards compatibility"}, geoSearch: {skip: "not supported in mongos"}, getCmdLineOpts: {skip: "does not return user data"}, getDiagnosticData: {skip: "does not return user data"}, @@ -191,7 +189,6 @@ grantPrivilegesToRole: {skip: "primary only"}, grantRolesToRole: {skip: "primary only"}, grantRolesToUser: {skip: "primary only"}, - group: {skip: "must define test coverage for 4.0 backwards compatibility"}, handshake: {skip: "does not return user data"}, hostInfo: {skip: "does not return user data"}, insert: {skip: "primary only"}, @@ -253,7 +250,6 @@ refreshLogicalSessionCacheNow: {skip: "does not return user data"}, refreshSessions: {skip: "does not return user data"}, refreshSessionsInternal: {skip: "does not return user data"}, - reIndex: {skip: "does not return user data"}, removeShard: {skip: "primary only"}, removeShardFromZone: {skip: "primary only"}, renameCollection: {skip: "primary only"}, @@ -312,6 +308,10 @@ whatsmyuri: {skip: "does not return user data"} }; + commandsRemovedFromMongosIn42.forEach(function(cmd) { + testCases[cmd] = {skip: "must define test coverage for 4.0 backwards compatibility"}; + }); + // Set the secondaries to priority 0 and votes 0 to prevent the primaries from stepping down. let rsOpts = {nodes: [{rsConfig: {votes: 1}}, {rsConfig: {priority: 0, votes: 0}}]}; let st = new ShardingTest({mongos: 2, shards: {rs0: rsOpts, rs1: rsOpts}}); diff --git a/src/mongo/client/dbclient_base.cpp b/src/mongo/client/dbclient_base.cpp index 5332e631759..378cc0a5e37 100644 --- a/src/mongo/client/dbclient_base.cpp +++ b/src/mongo/client/dbclient_base.cpp @@ -560,21 +560,6 @@ bool DBClientBase::createCollection( return runCommand(db.c_str(), b.done(), *info); } -bool DBClientBase::copyDatabase(const string& fromdb, - const string& todb, - const string& fromhost, - BSONObj* info) { - BSONObj o; - if (info == 0) - info = &o; - BSONObjBuilder b; - b.append("copydb", 1); - b.append("fromhost", fromhost); - b.append("fromdb", fromdb); - b.append("todb", todb); - return runCommand("admin", b.done(), *info); -} - list<BSONObj> DBClientBase::getCollectionInfos(const string& db, const BSONObj& filter) { list<BSONObj> infos; diff --git a/src/mongo/client/dbclient_base.h b/src/mongo/client/dbclient_base.h index 7ce43ba657b..cee91bd8bf0 100644 --- a/src/mongo/client/dbclient_base.h +++ b/src/mongo/client/dbclient_base.h @@ -424,31 +424,6 @@ public: return res; } - /** Copy database from one server or name to another server or name. - - Generally, you should dropDatabase() first as otherwise the copied information will MERGE - into whatever data is already present in this database. - - For security reasons this function only works when you are authorized to access the "admin" - db. However, if you have access to said db, you can copy any database from one place to - another. - TODO: this needs enhancement to be more flexible in terms of security. - - This method provides a way to "rename" a database by copying it to a new db name and - location. The copy is "repaired" and compacted. - - fromdb database name from which to copy. - todb database name to copy to. - fromhost hostname of the database (and optionally, ":port") from which to - copy the data. copies from self if "". - - returns true if successful - */ - bool copyDatabase(const std::string& fromdb, - const std::string& todb, - const std::string& fromhost = "", - BSONObj* info = 0); - /** validate a collection, checking for errors and reporting back statistics. this operation is slow and blocking. */ diff --git a/src/mongo/client/mongo_uri_connect.cpp b/src/mongo/client/mongo_uri_connect.cpp index 4ef8b7dc4a3..b81e98195a6 100644 --- a/src/mongo/client/mongo_uri_connect.cpp +++ b/src/mongo/client/mongo_uri_connect.cpp @@ -81,24 +81,6 @@ BSONObj parseAuthMechanismProperties(const std::string& propStr) { return bob.obj(); } -std::string authKeyCopyDBMongoCR(const std::string& username, - const std::string& password, - const std::string& nonce) { - md5digest d; - std::string passwordDigest = createPasswordDigest(username, password); - { - md5_state_t st; - md5_init(&st); - md5_append(&st, reinterpret_cast<const md5_byte_t*>(nonce.c_str()), nonce.size()); - md5_append(&st, reinterpret_cast<const md5_byte_t*>(username.data()), username.length()); - md5_append(&st, - reinterpret_cast<const md5_byte_t*>(passwordDigest.c_str()), - passwordDigest.size()); - md5_finish(&st, d); - } - return digestToString(d); -} - } // namespace BSONObj MongoURI::_makeAuthObjFromOptions(int maxWireVersion) const { diff --git a/src/mongo/db/catalog/collection.h b/src/mongo/db/catalog/collection.h index 5d5c5c368e2..deb0ceb3aad 100644 --- a/src/mongo/db/catalog/collection.h +++ b/src/mongo/db/catalog/collection.h @@ -426,7 +426,6 @@ public: * real delete. * 'loc' key to uniquely identify a record in a collection. * 'opDebug' Optional argument. When not null, will be used to record operation statistics. - * 'cappedOK' if true, allows deletes on capped collections (Cloner::copyDB uses this). * 'noWarn' if unindexing the record causes an error, if noWarn is true the error * will not be logged. */ diff --git a/src/mongo/db/cloner.cpp b/src/mongo/db/cloner.cpp index 5208128d87d..2dce75495d9 100644 --- a/src/mongo/db/cloner.cpp +++ b/src/mongo/db/cloner.cpp @@ -46,7 +46,6 @@ #include "mongo/db/catalog/database_holder.h" #include "mongo/db/catalog/index_create.h" #include "mongo/db/commands.h" -#include "mongo/db/commands/copydb.h" #include "mongo/db/commands/list_collections_filter.h" #include "mongo/db/commands/rename_collection.h" #include "mongo/db/concurrency/write_conflict_exception.h" diff --git a/src/mongo/db/cloner.h b/src/mongo/db/cloner.h index 61c0694e8f3..4775eb00e33 100644 --- a/src/mongo/db/cloner.h +++ b/src/mongo/db/cloner.h @@ -58,7 +58,7 @@ public: /** * Copies an entire database from the specified host. * clonedColls: when not-null, the function will return with this populated with a list of - * the collections that were cloned. This is for the user-facing clone command. + * the collections that were cloned. * collectionsToClone: When opts.createCollections is false, this list reflects the collections * that are cloned. When opts.createCollections is true, this parameter is * ignored and the collection list is fetched from the remote via _conn. diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript index 6d391e461bf..0d195add230 100644 --- a/src/mongo/db/commands/SConscript +++ b/src/mongo/db/commands/SConscript @@ -91,7 +91,6 @@ env.Library( env.Library( target="core", source=[ - "copydb_common.cpp", "fail_point_cmd.cpp", "find_and_modify_common.cpp", "generic.cpp", @@ -277,11 +276,9 @@ env.Library( target="mongod", source=[ "apply_ops_cmd.cpp", - "clone.cpp", "clone_collection.cpp", "collection_to_capped.cpp", "compact.cpp", - "copydb.cpp", "copydb_start_commands.cpp", "cpuload.cpp", "dbcheck.cpp", diff --git a/src/mongo/db/commands/clone.cpp b/src/mongo/db/commands/clone.cpp deleted file mode 100644 index 451632600ed..00000000000 --- a/src/mongo/db/commands/clone.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/** -* Copyright (C) 2008 10gen Inc. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero General Public License, version 3, -* as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. -* -* As a special exception, the copyright holders give permission to link the -* code of portions of this program with the OpenSSL library under certain -* conditions as described in each individual source file and distribute -* linked combinations including the program with the OpenSSL library. You -* must comply with the GNU Affero General Public License in all respects for -* all of the code used other than as permitted herein. If you modify file(s) -* with this exception, you may extend this exception to your version of the -* file(s), but you are not obligated to do so. If you do not wish to do so, -* delete this exception statement from your version. If you delete this -* exception statement from all source files in the program, then also delete -* it in the license file. -*/ - -#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kCommand -#include "mongo/platform/basic.h" - -#include "mongo/base/status.h" -#include "mongo/db/auth/action_set.h" -#include "mongo/db/auth/authorization_session.h" -#include "mongo/db/auth/resource_pattern.h" -#include "mongo/db/catalog/document_validation.h" -#include "mongo/db/cloner.h" -#include "mongo/db/commands.h" -#include "mongo/db/concurrency/d_concurrency.h" -#include "mongo/db/jsobj.h" -#include "mongo/s/grid.h" -#include "mongo/util/log.h" - -namespace { - -using namespace mongo; - -using std::set; -using std::string; -using std::stringstream; - -/* The clone command is deprecated. See http://dochub.mongodb.org/core/copydb-clone-deprecation. - Usage: - mydb.$cmd.findOne( { clone: "fromhost" } ); - Note: doesn't work with authentication enabled, except as internal operation or for - old-style users for backwards compatibility. -*/ -class CmdClone : public BasicCommand { -public: - CmdClone() : BasicCommand("clone") {} - - AllowedOnSecondary secondaryAllowed(ServiceContext*) const override { - return AllowedOnSecondary::kNever; - } - - virtual bool supportsWriteConcern(const BSONObj& cmd) const override { - return true; - } - - std::string help() const override { - return "clone this database from an instance of the db on another host\n" - "{clone: \"host13\"[, slaveOk: <bool>]}"; - } - - virtual Status checkAuthForCommand(Client* client, - const std::string& dbname, - const BSONObj& cmdObj) const { - ActionSet actions; - actions.addAction(ActionType::insert); - actions.addAction(ActionType::createIndex); - if (shouldBypassDocumentValidationForCommand(cmdObj)) { - actions.addAction(ActionType::bypassDocumentValidation); - } - - if (!AuthorizationSession::get(client)->isAuthorizedForActionsOnResource( - ResourcePattern::forDatabaseName(dbname), actions)) { - return Status(ErrorCodes::Unauthorized, "Unauthorized"); - } - return Status::OK(); - } - - virtual bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - BSONObjBuilder& result) { - const char* deprecationWarning = - "Support for the clone command has been deprecated. See " - "http://dochub.mongodb.org/core/copydb-clone-deprecation"; - warning() << deprecationWarning; - result.append("note", deprecationWarning); - boost::optional<DisableDocumentValidation> maybeDisableValidation; - if (shouldBypassDocumentValidationForCommand(cmdObj)) { - maybeDisableValidation.emplace(opCtx); - } - - string from = cmdObj.getStringField("clone"); - if (from.empty()) - return false; - - CloneOptions opts; - opts.fromDB = dbname; - opts.slaveOk = cmdObj["slaveOk"].trueValue(); - - // collsToIgnore is only used by movePrimary and contains a list of the - // sharded collections. - if (cmdObj["collsToIgnore"].type() == Array) { - BSONObjIterator it(cmdObj["collsToIgnore"].Obj()); - - while (it.more()) { - BSONElement e = it.next(); - if (e.type() == String) { - opts.shardedColls.insert(e.String()); - } - } - } - - // Clone the non-ignored collections. - set<string> clonedColls; - Lock::DBLock dbXLock(opCtx, dbname, MODE_X); - - Cloner cloner; - Status status = cloner.copyDb(opCtx, dbname, from, opts, &clonedColls); - - BSONArrayBuilder barr; - barr.append(clonedColls); - result.append("clonedColls", barr.arr()); - - uassertStatusOK(status); - return true; - } - -} cmdClone; - -} // namespace diff --git a/src/mongo/db/commands/clone_collection.cpp b/src/mongo/db/commands/clone_collection.cpp index 3aa2c3ddc9e..af8d26eb518 100644 --- a/src/mongo/db/commands/clone_collection.cpp +++ b/src/mongo/db/commands/clone_collection.cpp @@ -41,7 +41,6 @@ #include "mongo/db/catalog/document_validation.h" #include "mongo/db/cloner.h" #include "mongo/db/commands.h" -#include "mongo/db/commands/copydb.h" #include "mongo/db/commands/rename_collection.h" #include "mongo/db/db.h" #include "mongo/db/index_builder.h" diff --git a/src/mongo/db/commands/copydb.cpp b/src/mongo/db/commands/copydb.cpp deleted file mode 100644 index 7b799d10bbf..00000000000 --- a/src/mongo/db/commands/copydb.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/** -* Copyright (C) 2008 10gen Inc. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero General Public License, version 3, -* as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. -* -* As a special exception, the copyright holders give permission to link the -* code of portions of this program with the OpenSSL library under certain -* conditions as described in each individual source file and distribute -* linked combinations including the program with the OpenSSL library. You -* must comply with the GNU Affero General Public License in all respects for -* all of the code used other than as permitted herein. If you modify file(s) -* with this exception, you may extend this exception to your version of the -* file(s), but you are not obligated to do so. If you do not wish to do so, -* delete this exception statement from your version. If you delete this -* exception statement from all source files in the program, then also delete -* it in the license file. -*/ - -#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kCommand -#include "mongo/platform/basic.h" - -#include "mongo/base/status.h" -#include "mongo/client/sasl_client_authenticate.h" -#include "mongo/db/auth/action_set.h" -#include "mongo/db/auth/authorization_session.h" -#include "mongo/db/auth/resource_pattern.h" -#include "mongo/db/auth/sasl_command_constants.h" -#include "mongo/db/catalog/document_validation.h" -#include "mongo/db/catalog_raii.h" -#include "mongo/db/cloner.h" -#include "mongo/db/commands.h" -#include "mongo/db/commands/copydb.h" -#include "mongo/db/commands/copydb_start_commands.h" -#include "mongo/db/concurrency/d_concurrency.h" -#include "mongo/db/jsobj.h" -#include "mongo/db/namespace_string.h" -#include "mongo/util/log.h" - -namespace { - -using namespace mongo; - -using std::string; -using std::stringstream; - -/* The copydb command is deprecated. See http://dochub.mongodb.org/core/copydb-clone-deprecation. - * Usage: - * admindb.$cmd.findOne( { copydb: 1, fromhost: <connection string>, fromdb: <db>, - * todb: <db>[, username: <username>, nonce: <nonce>, key: <key>] } ); - * - * The "copydb" command is used to copy a database. Note that this is a very broad definition. - * This means that the "copydb" command can be used in the following ways: - * - * 1. To copy a database within a single node - * 2. To copy a database within a sharded cluster, possibly to another shard - * 3. To copy a database from one cluster to another - * - * Note that in all cases both the target and source database must be unsharded. - * - * The "copydb" command gets sent by the client or the mongos to the destination of the copy - * operation. The node, cluster, or shard that recieves the "copydb" command must then query - * the source of the database to be copied for all the contents and metadata of the database. - * - * - * - * When used with auth, there are two different considerations. - * - * The first is authentication with the target. The only entity that needs to authenticate with - * the target node is the client, so authentication works there the same as it would with any - * other command. - * - * The second is the authentication of the target with the source, which is needed because the - * target must query the source directly for the contents of the database. To do this, the - * client must use the "copydbgetnonce" command, in which the target will get a nonce from the - * source and send it back to the client. The client can then hash its password with the nonce, - * send it to the target when it runs the "copydb" command, which can then use that information - * to authenticate with the source. - * - * NOTE: mongos doesn't know how to call or handle the "copydbgetnonce" command. See - * SERVER-6427. - * - * NOTE: Since internal cluster auth works differently, "copydb" currently doesn't work between - * shards in a cluster when auth is enabled. See SERVER-13080. - */ -class CmdCopyDb : public ErrmsgCommandDeprecated { -public: - CmdCopyDb() : ErrmsgCommandDeprecated("copydb") {} - - virtual bool adminOnly() const { - return true; - } - - AllowedOnSecondary secondaryAllowed(ServiceContext*) const override { - return AllowedOnSecondary::kNever; - } - - virtual bool supportsWriteConcern(const BSONObj& cmd) const override { - return true; - } - - virtual Status checkAuthForCommand(Client* client, - const std::string& dbname, - const BSONObj& cmdObj) const { - return copydb::checkAuthForCopydbCommand(client, dbname, cmdObj); - } - - std::string help() const override { - return "copy a database from another host to this host\n" - "usage: {copydb: 1, fromhost: <connection string>, fromdb: <db>, todb: <db>" - "[, slaveOk: <bool>, username: <username>, nonce: <nonce>, key: <key>]}"; - } - - virtual bool errmsgRun(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { - const char* deprecationWarning = - "Support for the copydb command has been deprecated. See " - "http://dochub.mongodb.org/core/copydb-clone-deprecation"; - warning() << deprecationWarning; - result.append("note", deprecationWarning); - boost::optional<DisableDocumentValidation> maybeDisableValidation; - if (shouldBypassDocumentValidationForCommand(cmdObj)) - maybeDisableValidation.emplace(opCtx); - - string fromhost = cmdObj.getStringField("fromhost"); - bool fromSelf = fromhost.empty(); - if (fromSelf) { - /* copy from self */ - stringstream ss; - ss << "localhost:" << serverGlobalParams.port; - fromhost = ss.str(); - } - - CloneOptions cloneOptions; - const auto fromdbElt = cmdObj["fromdb"]; - uassert(ErrorCodes::TypeMismatch, - "'fromdb' must be of type String", - fromdbElt.type() == BSONType::String); - cloneOptions.fromDB = fromdbElt.str(); - cloneOptions.slaveOk = cmdObj["slaveOk"].trueValue(); - cloneOptions.useReplAuth = false; - - const auto todbElt = cmdObj["todb"]; - uassert(ErrorCodes::TypeMismatch, - "'todb' must be of type String", - todbElt.type() == BSONType::String); - const std::string todb = todbElt.str(); - - uassert(ErrorCodes::InvalidNamespace, - str::stream() << "Invalid 'todb' name: " << todb, - NamespaceString::validDBName(todb, NamespaceString::DollarInDbNameBehavior::Allow)); - uassert(ErrorCodes::InvalidNamespace, - str::stream() << "Invalid 'fromdb' name: " << cloneOptions.fromDB, - NamespaceString::validDBName(cloneOptions.fromDB, - NamespaceString::DollarInDbNameBehavior::Allow)); - - if (fromhost.empty()) { - errmsg = - "params missing - {copydb: 1, fromhost: <connection string>, " - "fromdb: <db>, todb: <db>}"; - return false; - } - - Cloner cloner; - - auto& authConn = CopyDbAuthConnection::forClient(opCtx->getClient()); - - if (cmdObj.hasField(saslCommandConversationIdFieldName) && - cmdObj.hasField(saslCommandPayloadFieldName)) { - uassert(25487, "must call copydbsaslstart first", authConn.get()); - BSONObj ret; - if (!authConn->runCommand( - cloneOptions.fromDB, - BSON("saslContinue" << 1 << cmdObj[saslCommandConversationIdFieldName] - << cmdObj[saslCommandPayloadFieldName]), - ret)) { - errmsg = "unable to login " + ret.toString(); - authConn.reset(); - return false; - } - - if (!ret["done"].Bool()) { - CommandHelpers::filterCommandReplyForPassthrough(ret, &result); - return true; - } - - result.append("done", true); - cloner.setConnection(std::move(authConn)); - } else if (!fromSelf) { - // If fromSelf leave the cloner's conn empty, it will use a DBDirectClient instead. - const ConnectionString cs(uassertStatusOK(ConnectionString::parse(fromhost))); - - auto conn = cs.connect(StringData(), errmsg); - if (!conn) { - return false; - } - cloner.setConnection(std::move(conn)); - } - - // Either we didn't need the authConn (if we even had one), or we already moved it - // into the cloner so just make sure we don't keep it around if we don't need it. - authConn.reset(); - - if (fromSelf) { - // SERVER-4328 todo lock just the two db's not everything for the fromself case - // SERVER-34431 TODO: Add calls to DatabaseShardingState::get().checkDbVersion() - // for source databases. - Lock::GlobalWrite lk(opCtx); - uassertStatusOK(cloner.copyDb(opCtx, todb, fromhost, cloneOptions, NULL)); - } else { - AutoGetDb autoDb(opCtx, todb, MODE_X); - uassertStatusOK(cloner.copyDb(opCtx, todb, fromhost, cloneOptions, NULL)); - } - - return true; - } - -} cmdCopyDB; - -} // namespace diff --git a/src/mongo/db/commands/copydb.h b/src/mongo/db/commands/copydb.h deleted file mode 100644 index 0f2cec12a72..00000000000 --- a/src/mongo/db/commands/copydb.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (C) 2013 10gen Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the GNU Affero General Public License in all respects for - * all of the code used other than as permitted herein. If you modify file(s) - * with this exception, you may extend this exception to your version of the - * file(s), but you are not obligated to do so. If you do not wish to do so, - * delete this exception statement from your version. If you delete this - * exception statement from all source files in the program, then also delete - * it in the license file. - */ - -#pragma once - -#include <string> -#include <vector> - -#include "mongo/db/auth/privilege.h" -#include "mongo/db/jsobj.h" - -namespace mongo { - -class Client; - -namespace copydb { - -Status checkAuthForCopydbCommand(Client* client, const std::string& dbname, const BSONObj& cmdObj); - -} // namespace copydb -} // namespace mongo diff --git a/src/mongo/db/commands/copydb_common.cpp b/src/mongo/db/commands/copydb_common.cpp deleted file mode 100644 index 583c4054cfc..00000000000 --- a/src/mongo/db/commands/copydb_common.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/** -* Copyright (C) 2013 10gen Inc. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero General Public License, version 3, -* as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. -* -* As a special exception, the copyright holders give permission to link the -* code of portions of this program with the OpenSSL library under certain -* conditions as described in each individual source file and distribute -* linked combinations including the program with the OpenSSL library. You -* must comply with the GNU Affero General Public License in all respects for -* all of the code used other than as permitted herein. If you modify file(s) -* with this exception, you may extend this exception to your version of the -* file(s), but you are not obligated to do so. If you do not wish to do so, -* delete this exception statement from your version. If you delete this -* exception statement from all source files in the program, then also delete -* it in the license file. -*/ - -#include "mongo/db/commands/copydb.h" - -#include <string> -#include <vector> - -#include "mongo/db/auth/action_set.h" -#include "mongo/db/auth/action_type.h" -#include "mongo/db/auth/authorization_session.h" -#include "mongo/db/auth/privilege.h" -#include "mongo/db/catalog/document_validation.h" -#include "mongo/db/client.h" -#include "mongo/db/jsobj.h" -#include "mongo/db/namespace_string.h" - -namespace mongo { -namespace copydb { - -Status checkAuthForCopydbCommand(Client* client, const std::string& dbname, const BSONObj& cmdObj) { - const auto fromdbElt = cmdObj["fromdb"]; - if (fromdbElt.type() != BSONType::String) { - return Status(ErrorCodes::TypeMismatch, "'fromdb' must be of type String"); - } - const auto todbElt = cmdObj["todb"]; - if (todbElt.type() != BSONType::String) { - return Status(ErrorCodes::TypeMismatch, "'todb' must be of type String"); - } - - bool fromSelf = StringData(cmdObj.getStringField("fromhost")).empty(); - const StringData fromdb = fromdbElt.valueStringData(); - const StringData todb = todbElt.valueStringData(); - - // get system collections - std::vector<std::string> legalClientSystemCollections; - legalClientSystemCollections.push_back("system.js"); - if (fromdb == "admin") { - legalClientSystemCollections.push_back("system.users"); - legalClientSystemCollections.push_back("system.roles"); - legalClientSystemCollections.push_back("system.version"); - } else if (fromdb == "local") { // TODO(spencer): shouldn't be possible. See SERVER-11383 - legalClientSystemCollections.push_back("system.replset"); - } - - // Check authorization on destination db - ActionSet actions; - actions.addAction(ActionType::insert); - actions.addAction(ActionType::createIndex); - if (shouldBypassDocumentValidationForCommand(cmdObj)) { - actions.addAction(ActionType::bypassDocumentValidation); - } - - if (!AuthorizationSession::get(client)->isAuthorizedForActionsOnResource( - ResourcePattern::forDatabaseName(todb), actions)) { - return Status(ErrorCodes::Unauthorized, "Unauthorized"); - } - - actions.removeAllActions(); - actions.addAction(ActionType::insert); - for (size_t i = 0; i < legalClientSystemCollections.size(); ++i) { - if (!AuthorizationSession::get(client)->isAuthorizedForActionsOnNamespace( - NamespaceString(todb, legalClientSystemCollections[i]), actions)) { - return Status(ErrorCodes::Unauthorized, "Unauthorized"); - } - } - - if (fromSelf) { - // If copying from self, also require privileges on source db - actions.removeAllActions(); - actions.addAction(ActionType::find); - if (!AuthorizationSession::get(client)->isAuthorizedForActionsOnResource( - ResourcePattern::forDatabaseName(fromdb), actions)) { - return Status(ErrorCodes::Unauthorized, "Unauthorized"); - } - for (size_t i = 0; i < legalClientSystemCollections.size(); ++i) { - if (!AuthorizationSession::get(client)->isAuthorizedForActionsOnNamespace( - NamespaceString(fromdb, legalClientSystemCollections[i]), actions)) { - return Status(ErrorCodes::Unauthorized, "Unauthorized"); - } - } - } - return Status::OK(); -} - -} // namespace copydb -} // namespace mongo diff --git a/src/mongo/db/commands/copydb_start_commands.cpp b/src/mongo/db/commands/copydb_start_commands.cpp index e06116a9bd8..495e17093d8 100644 --- a/src/mongo/db/commands/copydb_start_commands.cpp +++ b/src/mongo/db/commands/copydb_start_commands.cpp @@ -41,7 +41,6 @@ #include "mongo/db/client.h" #include "mongo/db/cloner.h" #include "mongo/db/commands.h" -#include "mongo/db/commands/copydb.h" #include "mongo/db/jsobj.h" #include "mongo/db/operation_context.h" #include "mongo/rpc/get_status_from_command_result.h" diff --git a/src/mongo/embedded/common-operations.cpp b/src/mongo/embedded/common-operations.cpp deleted file mode 100644 index 4a6d7e08a24..00000000000 --- a/src/mongo/embedded/common-operations.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/** - * Copyright (C) 2017 MongoDB Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the GNU Affero General Public License in all respects - * for all of the code used other than as permitted herein. If you modify - * file(s) with this exception, you may extend this exception to your - * version of the file(s), but you are not obligated to do so. If you do not - * wish to do so, delete this exception statement from your version. If you - * delete this exception statement from all source files in the program, - * then also delete it in the license file. - */ - -#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kStorage - -#include "mongo/embedded/common-operations.h" - -#include <mongoc.h> -#include <stdio.h> - -#include "mongo/embedded/mongoc_client.h" -#include "mongo/util/log.h" - -/** - * WARNING: This function is an example lifted directly from the C driver - * for use testing the connection to the c driver. It is written in C, - * and should not be used for anything besides basic testing. - */ -bool mongo::embeddedTest::insert_data(mongoc_collection_t* collection) { - mongoc_bulk_operation_t* bulk; - enum N { ndocs = 4 }; - bson_t* docs[ndocs]; - bson_error_t error; - int i = 0; - bool ret; - - bulk = mongoc_collection_create_bulk_operation(collection, true, NULL); - - docs[0] = BCON_NEW("x", BCON_DOUBLE(1.0), "tags", "[", "dog", "cat", "]"); - docs[1] = BCON_NEW("x", BCON_DOUBLE(2.0), "tags", "[", "cat", "]"); - docs[2] = BCON_NEW("x", BCON_DOUBLE(2.0), "tags", "[", "mouse", "cat", "dog", "]"); - docs[3] = BCON_NEW("x", BCON_DOUBLE(3.0), "tags", "[", "]"); - - for (i = 0; i < ndocs; i++) { - mongoc_bulk_operation_insert(bulk, docs[i]); - bson_destroy(docs[i]); - docs[i] = NULL; - } - - ret = mongoc_bulk_operation_execute(bulk, NULL, &error); - - if (!ret) { - log() << "Error inserting data: " << error.message; - } - - mongoc_bulk_operation_destroy(bulk); - return ret; -} - -/** - * WARNING: This function is an example lifted directly from the C driver - * for use testing the connection to the c driver. It is written in C, - * and should not be used for anything besides basic testing. - */ -bool copydb(mongoc_client_t* client, const char* other_host_and_port) { - mongoc_database_t* admindb; - bson_t* command; - bson_t reply; - bson_error_t error; - bool res; - - BSON_ASSERT(other_host_and_port); - /* Must do this from the admin db */ - admindb = mongoc_client_get_database(client, "admin"); - - command = BCON_NEW("copydb", - BCON_INT32(1), - "fromdb", - BCON_UTF8("test"), - "todb", - BCON_UTF8("test2"), - - /* If you want from a different host */ - "fromhost", - BCON_UTF8(other_host_and_port)); - res = mongoc_database_command_simple(admindb, command, NULL, &reply, &error); - if (!res) { - mongo::log() << "Error with copydb: " << error.message; - goto copy_cleanup; - } - - -copy_cleanup: - bson_destroy(&reply); - bson_destroy(command); - mongoc_database_destroy(admindb); - - return res; -} -/** - * WARNING: This function is an example lifted directly from the C driver - * for use testing the connection to the c driver. It is written in C, - * and should not be used for anything besides basic testing. - */ -bool clone_collection(mongoc_database_t* database, const char* other_host_and_port) { - bson_t* command; - bson_t reply; - bson_error_t error; - bool res; - - BSON_ASSERT(other_host_and_port); - command = BCON_NEW("cloneCollection", - BCON_UTF8("test.remoteThings"), - "from", - BCON_UTF8(other_host_and_port), - "query", - "{", - "x", - BCON_INT32(1), - "}"); - res = mongoc_database_command_simple(database, command, NULL, &reply, &error); - if (!res) { - mongo::log() << "Error with clone: " << error.message; - goto clone_cleanup; - } - - -clone_cleanup: - bson_destroy(&reply); - bson_destroy(command); - - return res; -} -/** - * WARNING: This function is an example lifted directly from the C driver - * for use testing the connection to the c driver. It is written in C, - * and should not be used for anything besides basic testing. - */ -bool mongo::embeddedTest::explain(mongoc_collection_t* collection) { - - bson_t* command; - bson_t reply; - bson_error_t error; - bool res; - - command = BCON_NEW("explain", - "{", - "find", - BCON_UTF8((const char*)"things"), - "filter", - "{", - "x", - BCON_INT32(1), - "}", - "}"); - res = mongoc_collection_command_simple(collection, command, NULL, &reply, &error); - if (!res) { - log() << "Error with explain: " << error.message; - goto explain_cleanup; - } - - -explain_cleanup: - bson_destroy(&reply); - bson_destroy(command); - return res; -} -/** - * WARNING: This function is an example lifted directly from the C driver - * for use testing the connection to the c driver. It is written in C, - * and should not be used for anything besides basic testing. - */ -int mongo::embeddedTest::run_c_driver_all() { - mongoc_database_t* database = NULL; - mongoc_client_t* client = NULL; - mongoc_collection_t* collection = NULL; - char* host_and_port = NULL; - int res = 0; - char* other_host_and_port = NULL; - - - client = mongoc_client_new(NULL); - - if (!client) { - log() << " Invalid client "; - res = 2; - goto cleanup; - } - - mongoc_client_set_error_api(client, 2); - database = mongoc_client_get_database(client, "test"); - collection = mongoc_database_get_collection(database, (const char*)"things"); - - if (!mongo::embeddedTest::insert_data(collection)) { - res = 3; - goto cleanup; - } - - if (!mongo::embeddedTest::explain(collection)) { - res = 4; - goto cleanup; - } - - if (other_host_and_port) { - if (!copydb(client, other_host_and_port)) { - res = 5; - goto cleanup; - } - - if (!clone_collection(database, other_host_and_port)) { - res = 6; - goto cleanup; - } - } - -cleanup: - if (collection) { - mongoc_collection_destroy(collection); - } - - if (database) { - mongoc_database_destroy(database); - } - - if (client) { - mongoc_client_destroy(client); - } - - bson_free(host_and_port); - mongoc_cleanup(); - return res; -} diff --git a/src/mongo/embedded/common-operations.h b/src/mongo/embedded/common-operations.h deleted file mode 100644 index b5f91eb1d23..00000000000 --- a/src/mongo/embedded/common-operations.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (C) 2017 MongoDB Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the GNU Affero General Public License in all respects - * for all of the code used other than as permitted herein. If you modify - * file(s) with this exception, you may extend this exception to your - * version of the file(s), but you are not obligated to do so. If you do not - * wish to do so, delete this exception statement from your version. If you - * delete this exception statement from all source files in the program, - * then also delete it in the license file. - */ - -#pragma once - -#include <mongoc.h> - -namespace mongo { - -namespace embeddedTest { - -bool explain(mongoc_collection_t* collection); - -bool insert_data(mongoc_collection_t* collection); - -int run_c_driver_all(); - -} // namespace embeddedTest - -} // namespace mongo diff --git a/src/mongo/embedded/functions_for_test.cpp b/src/mongo/embedded/functions_for_test.cpp index 6f1b78f07f8..d0e5d78cc0c 100644 --- a/src/mongo/embedded/functions_for_test.cpp +++ b/src/mongo/embedded/functions_for_test.cpp @@ -75,46 +75,6 @@ bool mongo::embeddedTest::insert_data(mongoc_collection_t* collection) { * for use testing the connection to the c driver. It is written in C, * and should not be used for anything besides basic testing. */ -bool copydb(mongoc_client_t* client, const char* other_host_and_port) { - mongoc_database_t* admindb; - bson_t* command; - bson_t reply; - bson_error_t error; - bool res; - - BSON_ASSERT(other_host_and_port); - /* Must do this from the admin db */ - admindb = mongoc_client_get_database(client, "admin"); - - command = BCON_NEW("copydb", - BCON_INT32(1), - "fromdb", - BCON_UTF8("test"), - "todb", - BCON_UTF8("test2"), - - /* If you want from a different host */ - "fromhost", - BCON_UTF8(other_host_and_port)); - res = mongoc_database_command_simple(admindb, command, NULL, &reply, &error); - if (!res) { - mongo::log() << "Error with copydb: " << error.message; - goto copy_cleanup; - } - - -copy_cleanup: - bson_destroy(&reply); - bson_destroy(command); - mongoc_database_destroy(admindb); - - return res; -} -/** - * WARNING: This function is an example lifted directly from the C driver - * for use testing the connection to the c driver. It is written in C, - * and should not be used for anything besides basic testing. - */ bool clone_collection(mongoc_database_t* database, const char* other_host_and_port) { bson_t* command; bson_t reply; @@ -215,13 +175,8 @@ int mongo::embeddedTest::run_c_driver_all() { } if (other_host_and_port) { - if (!copydb(client, other_host_and_port)) { - res = 5; - goto cleanup; - } - if (!clone_collection(database, other_host_and_port)) { - res = 6; + res = 5; goto cleanup; } } diff --git a/src/mongo/s/commands/commands_public.cpp b/src/mongo/s/commands/commands_public.cpp index 3b92e72caed..96c448988aa 100644 --- a/src/mongo/s/commands/commands_public.cpp +++ b/src/mongo/s/commands/commands_public.cpp @@ -37,7 +37,6 @@ #include "mongo/db/auth/authorization_session.h" #include "mongo/db/auth/privilege.h" #include "mongo/db/commands.h" -#include "mongo/db/commands/copydb.h" #include "mongo/db/commands/rename_collection.h" #include "mongo/executor/task_executor_pool.h" #include "mongo/rpc/get_status_from_command_result.h" @@ -232,107 +231,6 @@ public: } renameCollectionCmd; -class CopyDBCmd : public BasicCommand { -public: - CopyDBCmd() : BasicCommand("copydb") {} - - AllowedOnSecondary secondaryAllowed(ServiceContext*) const override { - return AllowedOnSecondary::kNever; - } - - bool adminOnly() const override { - return true; - } - - Status checkAuthForCommand(Client* client, - const std::string& dbname, - const BSONObj& cmdObj) const override { - return copydb::checkAuthForCopydbCommand(client, dbname, cmdObj); - } - - bool supportsWriteConcern(const BSONObj& cmd) const override { - return true; - } - - bool run(OperationContext* opCtx, - const std::string& dbName, - const BSONObj& cmdObj, - BSONObjBuilder& result) override { - const auto todbElt = cmdObj["todb"]; - uassert(ErrorCodes::InvalidNamespace, - "'todb' must be of type String", - todbElt.type() == BSONType::String); - const std::string todb = todbElt.str(); - uassert(ErrorCodes::InvalidNamespace, - "Invalid todb argument", - NamespaceString::validDBName(todb, NamespaceString::DollarInDbNameBehavior::Allow)); - - auto toDbInfo = uassertStatusOK(createShardDatabase(opCtx, todb)); - uassert(ErrorCodes::IllegalOperation, - "Cannot copy to a sharded database", - !toDbInfo.shardingEnabled()); - - const auto copyDbCmdObj = cmdObj["fromhost"] ? cmdObj : [&] { - const auto fromDbElt = cmdObj["fromdb"]; - uassert(ErrorCodes::InvalidNamespace, - "'fromdb' must be of type String", - fromDbElt.type() == BSONType::String); - const std::string fromdb = fromDbElt.str(); - uassert(ErrorCodes::InvalidNamespace, - "invalid fromdb argument", - NamespaceString::validDBName(fromdb, - NamespaceString::DollarInDbNameBehavior::Allow)); - - auto fromDbInfo = uassertStatusOK(createShardDatabase(opCtx, fromdb)); - uassert(ErrorCodes::IllegalOperation, - "Cannot copy from a sharded database", - !fromDbInfo.shardingEnabled()); - - // If the source and destination are the same, there is no need to attach the 'fromhost' - // field since the copy is entirely local to the node - if (fromDbInfo.primaryId() == toDbInfo.primaryId()) { - return cmdObj; - } - - BSONObjBuilder copyDbCmdObjBuilder; - - // Copy everything but the "fromhost" parameter - BSONForEach(e, cmdObj) { - if (strcmp(e.fieldName(), "fromhost")) { - copyDbCmdObjBuilder.append(e); - } - } - - // Append "fromhost" as the database's primary - { - const auto shard = uassertStatusOK( - Grid::get(opCtx)->shardRegistry()->getShard(opCtx, fromDbInfo.primaryId())); - copyDbCmdObjBuilder.append("fromhost", shard->getConnString().toString()); - } - - return copyDbCmdObjBuilder.obj(); - }(); - - // copyDb creates multiple collections and should handle collection creation differently - auto response = executeCommandAgainstDatabasePrimary( - opCtx, - NamespaceString::kAdminDb, - toDbInfo, - appendAllowImplicitCreate( - CommandHelpers::filterCommandRequestForPassthrough(copyDbCmdObj), true), - ReadPreferenceSetting(ReadPreference::PrimaryOnly), - Shard::RetryPolicy::kNoRetry); - - const auto cmdResponse = uassertStatusOK(std::move(response.swResponse)); - const auto status = getStatusFromCommandResult(cmdResponse.data); - - result.appendElementsUnique( - CommandHelpers::filterCommandReplyForPassthrough(cmdResponse.data)); - return status.isOK(); - } - -} clusterCopyDBCmd; - class ConvertToCappedCmd : public BasicCommand { public: ConvertToCappedCmd() : BasicCommand("convertToCapped") {} diff --git a/src/mongo/shell/db.js b/src/mongo/shell/db.js index 01cd07e89e3..0304410caef 100644 --- a/src/mongo/shell/db.js +++ b/src/mongo/shell/db.js @@ -465,7 +465,8 @@ var DB; }; /** - Clone database on another server to here. + Clone database on another server to here. This functionality was removed as of MongoDB 4.2. + The shell helper is kept to maintain compatibility with previous versions of MongoDB. <p> Generally, you should dropDatabase() first as otherwise the cloned information will MERGE into whatever data is already present in this database. (That is however a valid way to use @@ -481,7 +482,7 @@ var DB; */ DB.prototype.cloneDatabase = function(from) { print( - "WARNING: db.cloneDatabase is deprecated. See http://dochub.mongodb.org/core/copydb-clone-deprecation"); + "WARNING: db.cloneDatabase will only function with MongoDB 4.0 and below. See http://dochub.mongodb.org/core/4.2-copydb-clone"); assert(isString(from) && from.length); return this._dbCommand({clone: from}); }; @@ -512,7 +513,9 @@ var DB; }; /** - Copy database from one server or name to another server or name. + Copy database from one server or name to another server or name. This functionality was + removed as of MongoDB 4.2. The shell helper is kept to maintain compatibility with previous + versions of MongoDB. Generally, you should dropDatabase() first as otherwise the copied information will MERGE into whatever data is already present in this database (and you will get duplicate objects @@ -534,7 +537,7 @@ var DB; DB.prototype.copyDatabase = function( fromdb, todb, fromhost, username, password, mechanism, slaveOk) { print( - "WARNING: db.copyDatabase is deprecated. See http://dochub.mongodb.org/core/copydb-clone-deprecation"); + "WARNING: db.copyDatabase will only function with MongoDB 4.0 and below. See http://dochub.mongodb.org/core/4.2-copydb-clone"); assert(isString(fromdb) && fromdb.length); assert(isString(todb) && todb.length); fromhost = fromhost || ""; @@ -596,9 +599,10 @@ var DB; print( "\tdb.aggregate([pipeline], {options}) - performs a collectionless aggregation on this database; returns a cursor"); print("\tdb.auth(username, password)"); - print("\tdb.cloneDatabase(fromhost) - deprecated"); + print("\tdb.cloneDatabase(fromhost) - will only function with MongoDB 4.0 and below"); print("\tdb.commandHelp(name) returns the help for the command"); - print("\tdb.copyDatabase(fromdb, todb, fromhost) - deprecated"); + print( + "\tdb.copyDatabase(fromdb, todb, fromhost) - will only function with MongoDB 4.0 and below"); print("\tdb.createCollection(name, {size: ..., capped: ..., max: ...})"); print("\tdb.createView(name, viewOn, [{$operator: {...}}, ...], {viewOptions})"); print("\tdb.createUser(userDocument)"); |