summaryrefslogtreecommitdiff
path: root/jstests/gle/block2.js
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2014-05-14 14:11:11 -0400
committerRandolph Tan <randolph@10gen.com>2014-05-15 14:04:11 -0400
commit0dabee8227d445a18fa5e8e49b2be60ba2a0beef (patch)
tree5cd9058a4483202c2f7e2ab6f5c44079a74ac157 /jstests/gle/block2.js
parent4de88387eec6c0bb08b10d0ba1574a656f56232d (diff)
downloadmongo-0dabee8227d445a18fa5e8e49b2be60ba2a0beef.tar.gz
SERVER-13741 Migrate remaining tests to use write commands
Diffstat (limited to 'jstests/gle/block2.js')
-rw-r--r--jstests/gle/block2.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/jstests/gle/block2.js b/jstests/gle/block2.js
new file mode 100644
index 00000000000..142d51519b2
--- /dev/null
+++ b/jstests/gle/block2.js
@@ -0,0 +1,58 @@
+/**
+ * Basic gle testing for master/slave environment. Write command version also
+ * available at jstests/repl.
+ */
+
+var rt = new ReplTest( "block1" );
+
+var m = rt.start( true );
+var s = rt.start( false );
+
+if (m.writeMode() == 'commands') {
+ jsTest.log('Skipping test since commands mode is already tested in repl/');
+}
+else {
+
+ function setup(){
+
+ dbm = m.getDB( "foo" );
+ dbs = s.getDB( "foo" );
+
+ tm = dbm.bar;
+ ts = dbs.bar;
+ }
+ setup();
+
+ function check( msg ){
+ assert.eq( tm.count() , ts.count() , "check: " + msg );
+ }
+
+ function worked( w , wtimeout ){
+ var gle = dbm.getLastError( w , wtimeout );
+ if (gle != null) {
+ printjson(gle);
+ }
+ return gle == null;
+ }
+
+ check( "A" );
+
+ tm.save( { x : 1 } );
+ assert( worked( 2 ) , "B" );
+
+ tm.save( { x : 2 } );
+ assert( worked( 2 , 3000 ) , "C" );
+
+ rt.stop( false );
+ tm.save( { x : 3 } );
+ assert.eq( 3 , tm.count() , "D1" );
+ assert( ! worked( 2 , 3000 ) , "D2" );
+
+ s = rt.start( false );
+ setup();
+ assert( worked( 2 , 30000 ) , "E" );
+
+}
+
+rt.stop();
+