summaryrefslogtreecommitdiff
path: root/jstests/replsets/initial_sync_views.js
diff options
context:
space:
mode:
authorKyle Suarez <kyle.suarez@mongodb.com>2016-12-07 16:29:16 -0500
committerKyle Suarez <kyle.suarez@mongodb.com>2016-12-15 16:39:51 -0500
commit39bcdc6e6ef4980d6103ca0746ef1f4347aae841 (patch)
treeadc20efa167866363d8483dacf5c94489b96e661 /jstests/replsets/initial_sync_views.js
parent2ddd3a45a621784e8bcf3ca80fc6afdec6c5567b (diff)
downloadmongo-39bcdc6e6ef4980d6103ca0746ef1f4347aae841.tar.gz
SERVER-26765 move tests in jstests/views to other suites
This eliminates the views and views_rs suites; views testing will be done in other suites to allow them to be picked up in passthrough suites.
Diffstat (limited to 'jstests/replsets/initial_sync_views.js')
-rw-r--r--jstests/replsets/initial_sync_views.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/jstests/replsets/initial_sync_views.js b/jstests/replsets/initial_sync_views.js
new file mode 100644
index 00000000000..bf60951837b
--- /dev/null
+++ b/jstests/replsets/initial_sync_views.js
@@ -0,0 +1,41 @@
+/**
+ * Test initial sync with views present.
+ */
+
+(function() {
+ "use strict";
+
+ load("jstests/replsets/rslib.js");
+ let testName = "initial_sync_views";
+ let hostName = getHostName();
+
+ let replTest = new ReplSetTest({name: testName, nodes: 1});
+ replTest.startSet();
+ replTest.initiate();
+
+ let primaryDB = replTest.getPrimary().getDB(testName);
+
+ for (let i = 0; i < 10; ++i) {
+ assert.writeOK(primaryDB.coll.insert({a: i}));
+ }
+
+ // Setup view.
+ assert.commandWorked(
+ primaryDB.runCommand({create: "view", viewOn: "coll", pipeline: [{$match: {a: 5}}]}));
+
+ assert.eq(10, primaryDB.coll.find().itcount());
+ assert.eq(1, primaryDB.view.find().itcount());
+
+ // Add new member to the replica set and wait for initial sync to complete.
+ let secondary = replTest.add();
+ replTest.reInitiate();
+ replTest.awaitReplication();
+ replTest.awaitSecondaryNodes();
+
+ // Confirm secondary has expected collection and view document count.
+ let secondaryDB = secondary.getDB(testName);
+ assert.eq(10, secondaryDB.coll.find().itcount());
+ assert.eq(1, secondaryDB.view.find().itcount());
+
+ replTest.stopSet();
+})();