summaryrefslogtreecommitdiff
path: root/jstests/dur
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2014-04-25 14:04:36 -0400
committerRandolph Tan <randolph@10gen.com>2014-05-06 16:32:44 -0400
commit87dc3ae516e1d12a632dc604710661e38ed7b3dd (patch)
tree3a483a3d0c38ce00a7f4d7dba0e9cba7f7eba5f3 /jstests/dur
parent6b945ec15c61f6bd4bfbaf382624d886ec8441d2 (diff)
downloadmongo-87dc3ae516e1d12a632dc604710661e38ed7b3dd.tar.gz
SERVER-13741 Migrate remaining tests to use write commands
Diffstat (limited to 'jstests/dur')
-rwxr-xr-xjstests/dur/a_quick.js6
-rw-r--r--jstests/dur/closeall.js39
-rw-r--r--jstests/dur/diskfull.js11
-rw-r--r--jstests/dur/dropdb.js4
-rwxr-xr-xjstests/dur/dur1.js6
-rwxr-xr-xjstests/dur/dur1_tool.js7
-rw-r--r--jstests/dur/indexbg2.js4
-rwxr-xr-xjstests/dur/manyRestart.js6
-rw-r--r--jstests/dur/md5.js7
-rwxr-xr-xjstests/dur/oplog.js3
10 files changed, 27 insertions, 66 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 a1efba5595d..a604439424d 100644
--- a/jstests/dur/diskfull.js
+++ b/jstests/dur/diskfull.js
@@ -50,15 +50,12 @@ 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();
for( i = 0; i < 10000; ++i ) {
- d.foo.insert( { _id:i, b:big } );
+ 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/md5.js b/jstests/dur/md5.js
index 1773091186a..1b4ec43340e 100644
--- a/jstests/dur/md5.js
+++ b/jstests/dur/md5.js
@@ -29,13 +29,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");
}
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();