summaryrefslogtreecommitdiff
path: root/jstests/sharding/update_immutable_fields.js
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2014-03-04 17:41:56 -0500
committerRandolph Tan <randolph@10gen.com>2014-04-21 16:53:25 -0400
commit7acafe85d9bdd63122c19ba1cca86a7f55174941 (patch)
tree234effd8e5a5b6c63d8b12c74de2d9acb78a7509 /jstests/sharding/update_immutable_fields.js
parente87b42c4f13e48078f5c4aefba3caf18dcfba072 (diff)
downloadmongo-7acafe85d9bdd63122c19ba1cca86a7f55174941.tar.gz
SERVER-13425 migrate sharding jstest suite to use write commands api
Diffstat (limited to 'jstests/sharding/update_immutable_fields.js')
-rw-r--r--jstests/sharding/update_immutable_fields.js42
1 files changed, 11 insertions, 31 deletions
diff --git a/jstests/sharding/update_immutable_fields.js b/jstests/sharding/update_immutable_fields.js
index 35c0c77b721..25fb489e39e 100644
--- a/jstests/sharding/update_immutable_fields.js
+++ b/jstests/sharding/update_immutable_fields.js
@@ -40,58 +40,38 @@ var shard0Coll = getDirectShardedConn(st, coll.getFullName()).getCollection(coll
// No shard key
shard0Coll.remove({})
-shard0Coll.save({_id:3})
-assert.gleError(shard0Coll.getDB(), function(gle) {
- return "save without shard key passed - " + tojson(gle) + " doc: " + tojson(shard0Coll.findOne())
-});
+assert.writeError(shard0Coll.save({ _id: 3 }));
// Full shard key in save
-shard0Coll.save({_id: 1, a: 1})
-assert.gleSuccess(shard0Coll.getDB(), "save with shard key failed");
+assert.writeOK(shard0Coll.save({ _id: 1, a: 1 }));
// Full shard key on replacement (basically the same as above)
shard0Coll.remove({})
-shard0Coll.update({_id: 1}, {a:1}, true)
-assert.gleSuccess(shard0Coll.getDB(), "update + upsert (replacement) with shard key failed");
+assert.writeOK(shard0Coll.update({ _id: 1 }, { a: 1 }, true));
// Full shard key after $set
shard0Coll.remove({})
-shard0Coll.update({_id: 1}, {$set: {a: 1}}, true)
-assert.gleSuccess(shard0Coll.getDB(), "update + upsert ($set) with shard key failed");
+assert.writeOK(shard0Coll.update({ _id: 1 }, { $set: { a: 1 }}, true));
// Update existing doc (replacement), same shard key value
-shard0Coll.update({_id: 1}, {a:1})
-assert.gleSuccess(shard0Coll.getDB(), "update (replacement) with shard key failed");
+assert.writeOK(shard0Coll.update({ _id: 1 }, { a: 1 }));
//Update existing doc ($set), same shard key value
-shard0Coll.update({_id: 1}, {$set: {a: 1}})
-assert.gleSuccess(shard0Coll.getDB(), "update ($set) with shard key failed");
+assert.writeOK(shard0Coll.update({ _id: 1 }, { $set: { a: 1 }}));
// Error due to mutating the shard key (replacement)
-shard0Coll.update({_id: 1}, {b:1})
-assert.gleError(shard0Coll.getDB(), "update (replacement) removes shard key");
+assert.writeError(shard0Coll.update({ _id: 1 }, { b: 1 }));
// Error due to mutating the shard key ($set)
-shard0Coll.update({_id: 1}, {$unset: {a: 1}})
-assert.gleError(shard0Coll.getDB(), "update ($unset) removes shard key");
+assert.writeError(shard0Coll.update({ _id: 1 }, { $unset: { a: 1 }}));
// Error due to removing all the embedded fields.
shard0Coll.remove({})
-shard0Coll.save({_id: 2, a:{c:1, b:1}})
-assert.gleSuccess(shard0Coll.getDB(), "save with shard key failed -- 1");
+assert.writeOK(shard0Coll.save({ _id: 2, a: { c: 1, b: 1 }}));
-shard0Coll.update({}, {$unset: {"a.c": 1}})
-assert.gleError(shard0Coll.getDB(), function(gle) {
- return "unsetting part of shard key passed - " + tojson(gle) +
- " doc: " + tojson(shard0Coll.findOne())
-});
-
-shard0Coll.update({}, {$unset: {"a.b": 1, "a.c": 1}})
-assert.gleError(shard0Coll.getDB(), function(gle) {
- return "unsetting nested fields of shard key passed - " + tojson(gle) +
- " doc: " + tojson(shard0Coll.findOne())
-});
+assert.writeError(shard0Coll.update({}, { $unset: { "a.c": 1 }}));
+assert.writeError(shard0Coll.update({}, { $unset: { "a.b": 1, "a.c": 1 }}));
jsTest.log("DONE!"); // distinguishes shutdown failures
st.stop();