summaryrefslogtreecommitdiff
path: root/jstests/slowNightly
diff options
context:
space:
mode:
authorScott Hernandez <scotthernandez@gmail.com>2013-03-29 17:14:38 -0400
committerScott Hernandez <scotthernandez@gmail.com>2013-03-29 17:14:42 -0400
commit939e91aed13ecb55d2e9a43f5ea92bf4bf64a1c1 (patch)
treee5660bcbd3128f33e77045d2870f26b3fcd30d23 /jstests/slowNightly
parentf8699f77f90ff9b24d23729644ee7cd7ed0e9600 (diff)
downloadmongo-939e91aed13ecb55d2e9a43f5ea92bf4bf64a1c1.tar.gz
SERVER-9053: ttl: don't delete on non-primaries
Diffstat (limited to 'jstests/slowNightly')
-rw-r--r--jstests/slowNightly/ttl_repl_secondary_disabled.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/jstests/slowNightly/ttl_repl_secondary_disabled.js b/jstests/slowNightly/ttl_repl_secondary_disabled.js
new file mode 100644
index 00000000000..47a447e048d
--- /dev/null
+++ b/jstests/slowNightly/ttl_repl_secondary_disabled.js
@@ -0,0 +1,52 @@
+/** Test TTL docs are not deleted from secondaries directly
+ */
+
+var rt = new ReplSetTest( { name : "ttl_repl" , nodes: 2 } );
+
+// setup set
+var nodes = rt.startSet();
+rt.initiate();
+var master = rt.getMaster();
+rt.awaitSecondaryNodes();
+var slave1 = rt.getSecondary();
+
+// shortcuts
+var masterdb = master.getDB( 'd' );
+var slave1db = slave1.getDB( 'd' );
+var mastercol = masterdb[ 'c' ];
+var slave1col = slave1db[ 'c' ];
+
+// create TTL index, wait for TTL monitor to kick in, then check things
+mastercol.ensureIndex( { x : 1 } , { expireAfterSeconds : 10 } );
+
+rt.awaitReplication();
+
+//increase logging
+slave1col.getDB().adminCommand({setParameter:1, logLevel:1});
+
+//insert old doc (10 minutes old) directly on secondary using godinsert
+slave1col.runCommand("godinsert",
+ {obj: {_id: new Date(), x: new Date( (new Date()).getTime() - 600000 ) } })
+assert.eq(1, slave1col.count(), "missing inserted doc" );
+
+sleep(70*1000) //wait for 70seconds
+assert.eq(1, slave1col.count(), "ttl deleted my doc!" );
+
+// looking for this error : "Assertion: 13312:replSet error : logOp() but not primary"
+// indicating that the secondary tried to delete the doc, but shouldn't be writing
+var errorString = "13312";
+var foundError = false;
+var globalLogLines = slave1col.getDB().adminCommand({getLog:"global"}).log
+for (i in globalLogLines) {
+ var line = globalLogLines[i];
+ if (line.match( errorString )) {
+ foundError = true;
+ errorString = line; // replace error string with what we found.
+ break;
+ }
+}
+
+assert.eq(false, foundError, "found error in this line: " + errorString);
+
+// finish up
+rt.stopSet(); \ No newline at end of file