summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2015-12-08 11:30:40 -0500
committerRandolph Tan <randolph@10gen.com>2015-12-09 11:55:21 -0500
commit0dd27a3602d2e172a60b4d1f0bd90e6c722e214a (patch)
treee5acd7b95aa8a12766d82356998c770c20be111c
parent037404ae302214b44ed4d3ed5da862f094f5299e (diff)
downloadmongo-0dd27a3602d2e172a60b4d1f0bd90e6c722e214a.tar.gz
SERVER-21139 Add more basic tests for drop collection
(cherry picked from commit e90ba97c1af931f471cacabaf5e02d7cfd4fd5c7)
-rw-r--r--jstests/sharding/basic_drop_coll.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/jstests/sharding/basic_drop_coll.js b/jstests/sharding/basic_drop_coll.js
new file mode 100644
index 00000000000..af9008cfcac
--- /dev/null
+++ b/jstests/sharding/basic_drop_coll.js
@@ -0,0 +1,54 @@
+/**
+ * Basic test from the drop collection command on a sharded cluster that verifies collections are
+ * cleanuped up properly.
+ */
+(function() {
+"use strict";
+
+var st = new ShardingTest({ shards: 2 });
+
+var testDB = st.s.getDB('test');
+
+// Test dropping an unsharded collection.
+
+assert.writeOK(testDB.bar.insert({ x: 1 }));
+assert.neq(null, testDB.bar.findOne({ x: 1 }));
+
+assert.commandWorked(testDB.runCommand({ drop: 'bar' }));
+assert.eq(null, testDB.bar.findOne({ x: 1 }));
+
+// Test dropping a sharded collection.
+
+assert.commandWorked(st.s.adminCommand({ enableSharding: 'test' }));
+st.ensurePrimaryShard('test', 'shard0000');
+st.s.adminCommand({ shardCollection: 'test.user', key: { _id: 1 }});
+st.s.adminCommand({ split: 'test.user', middle: { _id: 0 }});
+assert.commandWorked(st.s.adminCommand({ moveChunk: 'test.user',
+ find: { _id: 0 },
+ to: 'shard0001' }));
+
+assert.writeOK(testDB.user.insert({ _id: 10 }));
+assert.writeOK(testDB.user.insert({ _id: -10 }));
+
+assert.neq(null, st.d0.getDB('test').user.findOne({ _id: -10 }));
+assert.neq(null, st.d1.getDB('test').user.findOne({ _id: 10 }));
+
+var configDB = st.s.getDB('config');
+var collDoc = configDB.collections.findOne({ _id: 'test.user' });
+assert(!collDoc.dropped);
+
+assert.eq(2, configDB.chunks.count({ ns: 'test.user' }));
+
+assert.commandWorked(testDB.runCommand({ drop: 'user' }));
+
+assert.eq(null, st.d0.getDB('test').user.findOne());
+assert.eq(null, st.d1.getDB('test').user.findOne());
+
+collDoc = configDB.collections.findOne({ _id: 'test.user' });
+assert(collDoc.dropped);
+
+assert.eq(0, configDB.chunks.count({ ns: 'test.user' }));
+
+st.stop();
+
+})();