diff options
author | Randolph Tan <randolph@10gen.com> | 2014-03-04 17:41:56 -0500 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2014-04-21 16:53:25 -0400 |
commit | 7acafe85d9bdd63122c19ba1cca86a7f55174941 (patch) | |
tree | 234effd8e5a5b6c63d8b12c74de2d9acb78a7509 /jstests/sharding/mongos_validate_writes.js | |
parent | e87b42c4f13e48078f5c4aefba3caf18dcfba072 (diff) | |
download | mongo-7acafe85d9bdd63122c19ba1cca86a7f55174941.tar.gz |
SERVER-13425 migrate sharding jstest suite to use write commands api
Diffstat (limited to 'jstests/sharding/mongos_validate_writes.js')
-rw-r--r-- | jstests/sharding/mongos_validate_writes.js | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/jstests/sharding/mongos_validate_writes.js b/jstests/sharding/mongos_validate_writes.js index 6a6fb36eeef..4bfbb2048f3 100644 --- a/jstests/sharding/mongos_validate_writes.js +++ b/jstests/sharding/mongos_validate_writes.js @@ -39,12 +39,10 @@ coll.ensureIndex({ b : 1 }) printjson( admin.runCommand({ shardCollection : coll + "", key : { b : 1 } }) ) // Make sure that we can successfully insert, even though we have stale state -staleCollA.insert({ b : "b" }) -assert.eq( null, staleCollA.getDB().getLastError() ) +assert.writeOK(staleCollA.insert({ b : "b" })); // Make sure we unsuccessfully insert with old info -staleCollB.insert({ a : "a" }) -assert.neq( null, staleCollB.getDB().getLastError() ) +assert.writeError(staleCollB.insert({ a : "a" })); // Change the collection sharding state coll.drop() @@ -52,12 +50,10 @@ coll.ensureIndex({ c : 1 }) printjson( admin.runCommand({ shardCollection : coll + "", key : { c : 1 } }) ) // Make sure we can successfully upsert, even though we have stale state -staleCollA.update({ c : "c" }, { c : "c" }, true ) -assert.eq( null, staleCollA.getDB().getLastError() ) +assert.writeOK(staleCollA.update({ c : "c" }, { c : "c" }, true )); // Make sure we unsuccessfully upsert with old info -staleCollB.update({ b : "b" }, { b : "b" }, true ) -assert.neq( null, staleCollB.getDB().getLastError() ) +assert.writeError(staleCollB.update({ b : "b" }, { b : "b" }, true )); // Change the collection sharding state coll.drop() @@ -65,16 +61,13 @@ coll.ensureIndex({ d : 1 }) printjson( admin.runCommand({ shardCollection : coll + "", key : { d : 1 } }) ) // Make sure we can successfully update, even though we have stale state -coll.insert({ d : "d" }) -coll.getDB().getLastError(); +assert.writeOK(coll.insert({ d : "d" })); -staleCollA.update({ d : "d" }, { $set : { x : "x" } }, false, false ) -assert.eq( null, staleCollA.getDB().getLastError() ) +assert.writeOK(staleCollA.update({ d : "d" }, { $set : { x : "x" } }, false, false )); assert.eq( staleCollA.findOne().x, "x" ) // Make sure we unsuccessfully update with old info -staleCollB.update({ c : "c" }, { $set : { x : "y" } }, false, false ) -assert.neq( null, staleCollB.getDB().getLastError() ) +assert.writeError(staleCollB.update({ c : "c" }, { $set : { x : "y" } }, false, false )); assert.eq( staleCollB.findOne().x, "x" ) // Change the collection sharding state @@ -87,16 +80,12 @@ printjson( admin.runCommand({ split : coll + "", middle : { e : 0 } }) ) printjson( admin.runCommand({ moveChunk : coll + "", find : { e : 0 }, to : "shard0001" }) ) // Make sure we can successfully remove, even though we have stale state -coll.insert({ e : "e" }) -// Need to make sure the insert makes it to the shard -assert.eq( null, coll.getDB().getLastError() ) +assert.writeOK(coll.insert({ e : "e" })); -staleCollA.remove({ e : "e" }, true) -assert.eq( null, staleCollA.getDB().getLastError() ) +assert.writeOK(staleCollA.remove({ e : "e" }, true)); assert.eq( null, staleCollA.findOne() ) // Make sure we unsuccessfully remove with old info -staleCollB.remove({ d : "d" }, true ) -assert.neq( null, staleCollB.getDB().getLastError() ) +assert.writeError(staleCollB.remove({ d : "d" }, true )); st.stop() |