diff options
author | Adam Midvidy <amidvidy@gmail.com> | 2016-02-24 15:43:27 -0500 |
---|---|---|
committer | Adam Midvidy <amidvidy@gmail.com> | 2016-02-24 22:08:58 -0500 |
commit | 3a5c0f9bcb46f083863622e0d734cf29023e7275 (patch) | |
tree | 6f37bfac50eb5c799f96ed951e0efc7b35574e70 /jstests | |
parent | aaa5074a59327cdd2d0a462bb27c98f1c1c3ec6a (diff) | |
download | mongo-3a5c0f9bcb46f083863622e0d734cf29023e7275.tar.gz |
SERVER-22184 check for the new error format in peekError
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/sharding/error_propagation.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/jstests/sharding/error_propagation.js b/jstests/sharding/error_propagation.js new file mode 100644 index 00000000000..9948da66190 --- /dev/null +++ b/jstests/sharding/error_propagation.js @@ -0,0 +1,23 @@ +(function() { + // Tests that errors encountered on shards are correctly returned to the client when mongos uses + // the legacy DBClientCursor method of executing commands on shards. We use aggregation here + // specifically because it is one of the few query paths that still uses the legacy DBClient + // classes in mongos. + "use strict"; + + var st = new ShardingTest({mongos: 1, shards: 1, rs: {nodes: 3}}); + + var db = st.getDB('test'); + db.setSlaveOk(true); + + assert.writeOK(db.foo.insert({a:1}, {writeConcern: {w:3}})); + assert.commandWorked(db.runCommand({aggregate: 'foo', + pipeline: [{$project: {total: {'$add': ['$a', 1]}}}]})); + + assert.writeOK(db.foo.insert({a: [1, 2]}, {writeConcern: {w:3}})); + + var res = db.runCommand({aggregate: 'foo', + pipeline: [{$project: {total: {'$add': ['$a', 1]}}}]}); + assert.commandFailed(res); + assert.eq("$add only supports numeric or date types, not Array", res.errmsg, printjson(res)); +}()); |