diff options
author | Randolph Tan <randolph@10gen.com> | 2014-11-24 14:08:40 -0500 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2014-11-25 13:29:09 -0500 |
commit | d1152d4bc387f53d2fda7ef5ce640f9a55d0c1d8 (patch) | |
tree | 879f72969eb7791f64cc91e63d26312deb92c5bf /jstests/dur | |
parent | e34a30fbf39b50ed86d5c9de6a97fc28ad19a466 (diff) | |
download | mongo-d1152d4bc387f53d2fda7ef5ce640f9a55d0c1d8.tar.gz |
SERVER-13741 Migrate remaining tests to use write commands
(cherry picked from commit 0dabee8227d445a18fa5e8e49b2be60ba2a0beef)
Conflicts:
buildscripts/smoke.py
jstests/dur/diskfull.js
jstests/dur/md5.js
jstests/noPassthroughWithMongod/index_multi.js
jstests/repl/master1.js
jstests/sharding/sync1.js
jstests/sharding/sync4.js
jstests/sharding/sync8.js
jstests/tool/dumprestore_auth3.js
Conflicts:
buildscripts/smoke.py
Diffstat (limited to 'jstests/dur')
-rwxr-xr-x | jstests/dur/a_quick.js | 6 | ||||
-rw-r--r-- | jstests/dur/closeall.js | 39 | ||||
-rw-r--r-- | jstests/dur/diskfull.js | 13 | ||||
-rw-r--r-- | jstests/dur/dropdb.js | 4 | ||||
-rwxr-xr-x | jstests/dur/dur1.js | 6 | ||||
-rwxr-xr-x | jstests/dur/dur1_tool.js | 7 | ||||
-rw-r--r-- | jstests/dur/indexbg2.js | 4 | ||||
-rwxr-xr-x | jstests/dur/manyRestart.js | 6 | ||||
-rwxr-xr-x | jstests/dur/oplog.js | 3 |
9 files changed, 28 insertions, 60 deletions
diff --git a/jstests/dur/a_quick.js b/jstests/dur/a_quick.js index ab36f91327e..bbec8af6939 100755 --- a/jstests/dur/a_quick.js +++ b/jstests/dur/a_quick.js @@ -62,8 +62,7 @@ tst.log("start mongod without dur"); var conn = startMongodEmpty("--port", 30000, "--dbpath", path1, "--nodur"); tst.log("without dur work"); var d = conn.getDB("test"); -d.foo.insert({ _id:123 }); -d.getLastError(); +assert.writeOK(d.foo.insert({ _id: 123 })); tst.log("stop without dur"); stopMongod(30000); @@ -72,8 +71,7 @@ tst.log("start mongod with dur"); conn = startMongodEmpty("--port", 30001, "--dbpath", path2, "--dur", "--durOptions", 8); tst.log("with dur work"); d = conn.getDB("test"); -d.foo.insert({ _id: 123 }); -d.getLastError(); // wait +assert.writeOK(d.foo.insert({ _id: 123 })); // we could actually do getlasterror fsync:1 now, but maybe this is agood // as it will assure that commits happen on a timely basis. a bunch of the other dur/*js diff --git a/jstests/dur/closeall.js b/jstests/dur/closeall.js index 3d7119ab134..8c3864e8118 100644 --- a/jstests/dur/closeall.js +++ b/jstests/dur/closeall.js @@ -30,26 +30,24 @@ function f(variant, quickCommits, paranoid) { print("closeall.js run test"); print("wait for initial sync to finish") // SERVER-4852 - db1.foo.insert({}); - err = db1.getLastErrorObj(2); - printjson(err) - assert.isnull(err.err); - db1.foo.remove({}); - err = db1.getLastErrorObj(2); - printjson(err) - assert.isnull(err.err); + assert.writeOK(db1.foo.insert({}, { writeConcern: { w: 2 }})); + assert.writeOK(db1.foo.remove({}, { writeConcern: { w: 2 }})); print("initial sync done") - for( var i = 0; i < N; i++ ) { - db1.foo.insert({x:1}); // this does wait for a return code so we will get some parallelism - if( i % 7 == 0 ) - db1.foo.insert({x:99, y:2}); - if( i % 49 == 0 ) - db1.foo.update({ x: 99 }, { a: 1, b: 2, c: 3, d: 4 }); - if (i % 100 == 0) - db1.foo.find(); - if( i == 800 ) - db1.foo.ensureIndex({ x: 1 }); + var writeOps = startParallelShell('var coll = db.getSiblingDB("closealltest").foo; \ + var bulk = coll.initializeUnorderedBulkOp(); \ + for( var i = 0; i < ' + N + '; i++ ) { \ + bulk.insert({ x: 1 }); \ + if ( i % 7 == 0 ) \ + bulk.insert({ x: 99, y: 2 }); \ + if ( i % 49 == 0 ) \ + bulk.find({ x: 99 }).update( \ + { a: 1, b: 2, c: 3, d: 4 }); \ + if( i == 800 ) \ + coll.ensureIndex({ x: 1 }); \ + }', 30001); + + for( var i = 0; i < N; i++ ) { var res = null; try { if( variant == 1 ) @@ -61,7 +59,6 @@ function f(variant, quickCommits, paranoid) { res = db2.adminCommand("closeAllDatabases"); } catch (e) { - sleep(5000); // sleeping a little makes console output order prettier print("\n\n\nFAIL closeall.js closeAllDatabases command invocation threw an exception. i:" + i); try { print("getlasterror:"); @@ -74,8 +71,6 @@ function f(variant, quickCommits, paranoid) { print("got another exception : " + e); } print("\n\n\n"); - // sleep a little to capture possible mongod output? - sleep(2000); throw e; } assert( res.ok, "closeAllDatabases res.ok=false"); @@ -87,6 +82,8 @@ function f(variant, quickCommits, paranoid) { print("closeall.js shutting down servers"); stopMongod(30002); stopMongod(30001); + + writeOps(); } // Skip this test on 32-bit Windows (unfixable failures in MapViewOfFileEx) diff --git a/jstests/dur/diskfull.js b/jstests/dur/diskfull.js index 3aba989b7f8..fbd0e496dc3 100644 --- a/jstests/dur/diskfull.js +++ b/jstests/dur/diskfull.js @@ -59,18 +59,15 @@ function work() { log("work"); try { var d = conn.getDB("test"); - - big = new Array( 5000 ).toString(); + var big = new Array( 5000 ).toString(); + var bulk = d.foo.initializeUnorderedBulkOp(); // This part of the test depends on the partition size used in the build env // Currently, unused, but with larger partitions insert enough documents here // to create a second db file - for( i = 0; i < 1; ++i ) { - d.foo.insert( { _id:i, b:big } ); + for( i = 0; i < 10000; ++i ) { + bulk.insert({ _id: i, b: big }); } - - gle = d.getLastError(); - if ( gle ) - throw gle; + assert.writeOK(bulk.execute()); } catch ( e ) { print( e ); raise( e ); diff --git a/jstests/dur/dropdb.js b/jstests/dur/dropdb.js index 4fb94cc7d1e..54de6bdd7f2 100644 --- a/jstests/dur/dropdb.js +++ b/jstests/dur/dropdb.js @@ -62,10 +62,8 @@ function work() { d.dropDatabase(); - d.foo.insert({ _id: 100 }); - // assure writes applied in case we kill -9 on return from this function - assert(d.runCommand({ getlasterror: 1, fsync: 1 }).ok, "getlasterror not ok"); + assert.writeOK(d.foo.insert({ _id: 100 }, { writeConcern: { fsync: 1 }})); } function verify() { diff --git a/jstests/dur/dur1.js b/jstests/dur/dur1.js index cb4495aea52..0aecaaac21c 100755 --- a/jstests/dur/dur1.js +++ b/jstests/dur/dur1.js @@ -64,12 +64,6 @@ function work() { // try building an index. however, be careful as object id's in system.indexes would vary, so we do it manually: d.system.indexes.insert({ _id: 99, ns: "test.a", key: { x: 1 }, name: "x_1", v: 0 }); -// d.a.update({ _id: 4 }, { $inc: { x: 1} }); -// d.a.reIndex(); - - // assure writes applied in case we kill -9 on return from this function - d.getLastError();
-
log("endwork");
return d; } diff --git a/jstests/dur/dur1_tool.js b/jstests/dur/dur1_tool.js index fdfe05236f4..adee933fdb4 100755 --- a/jstests/dur/dur1_tool.js +++ b/jstests/dur/dur1_tool.js @@ -63,13 +63,6 @@ function work() { // try building an index. however, be careful as object id's in system.indexes would vary, so we do it manually: d.system.indexes.insert({ _id: 99, ns: "test.a", key: { x: 1 }, name: "x_1", v: 0 }); - -// d.a.update({ _id: 4 }, { $inc: { x: 1} }); -// d.a.reIndex(); - - // assure writes applied in case we kill -9 on return from this function - d.getLastError();
-
log("endwork");
return d; } diff --git a/jstests/dur/indexbg2.js b/jstests/dur/indexbg2.js index a7484f0a561..d239d4eaa44 100644 --- a/jstests/dur/indexbg2.js +++ b/jstests/dur/indexbg2.js @@ -15,5 +15,5 @@ for( var i = 1000; i < 2000; ++i ) { t.insert( {_id:i,a:'abcd',b:'bcde',x:'four score and seven years ago'} ); t.remove( {_id:i} ); } -t.insert( {_id:2000,a:'abcd',b:'bcde',x:'four score and seven years ago'} ); -assert( !t.getDB().getLastError() ); +assert.writeOK(t.insert({ _id: 2000, a: 'abcd', b: 'bcde', x: 'four score and seven years ago' })); + diff --git a/jstests/dur/manyRestart.js b/jstests/dur/manyRestart.js index f434278ca9a..5a68afdecbb 100755 --- a/jstests/dur/manyRestart.js +++ b/jstests/dur/manyRestart.js @@ -63,12 +63,6 @@ function work() { // try building an index. however, be careful as object id's in system.indexes would vary, so we do it manually: d.system.indexes.insert({ _id: 99, ns: "test.a", key: { x: 1 }, name: "x_1", v: 0 }); - -// d.a.update({ _id: 4 }, { $inc: { x: 1} }); -// d.a.reIndex(); - - // assure writes applied in case we kill -9 on return from this function - d.getLastError(); log("endwork"); return d; } diff --git a/jstests/dur/oplog.js b/jstests/dur/oplog.js index cd7d7c5e6ef..8ded3c980a9 100755 --- a/jstests/dur/oplog.js +++ b/jstests/dur/oplog.js @@ -81,9 +81,6 @@ function work() { d.foo.insert({ _id: 6, q: "aaaaa", b: big, z: 3 }); d.foo.update({ _id: 5 }, { $set: { z: 99} }); - // assure writes applied in case we kill -9 on return from this function - d.getLastError(); - log("endwork"); verify(); |