diff options
author | Jack Mulrow <jack.mulrow@mongodb.com> | 2017-05-30 15:38:34 -0400 |
---|---|---|
committer | Jack Mulrow <jack.mulrow@mongodb.com> | 2017-06-02 12:01:02 -0400 |
commit | 8162f04849106dc40adccfc479dd6aa6b6bfde2a (patch) | |
tree | 34e6ff791f6fb674cb9025fa8b8155cf544e6e61 | |
parent | f75fb8f5eee2b91599334681ab2b1ebcf20b491c (diff) | |
download | mongo-8162f04849106dc40adccfc479dd6aa6b6bfde2a.tar.gz |
SERVER-28293 Verify mongod processes $logicalTime like mongos
-rw-r--r-- | jstests/sharding/logical_time_api.js | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/jstests/sharding/logical_time_api.js b/jstests/sharding/logical_time_api.js index 03eb172d11e..3b794f06fbb 100644 --- a/jstests/sharding/logical_time_api.js +++ b/jstests/sharding/logical_time_api.js @@ -5,7 +5,7 @@ * - mongod from a non-sharded replica set * - standalone mongod * - * Expects logicalTime to come in the commandReply from a mongos and the metadata from a mongod. + * Expects logicalTime to come in the command body from both a mongos and a mongod. */ (function() { "use strict"; @@ -42,31 +42,35 @@ var st = new ShardingTest({name: "logical_time_api", shards: {rs0: {nodes: 1}}}); var testDB = st.s.getDB("test"); - var res = testDB.runCommandWithMetadata("insert", {insert: "foo", documents: [{x: 1}]}, {}); - assert.commandWorked(res.commandReply); - assert(containsValidLogicalTimeBson(res.commandReply), - "Expected commandReply from a mongos talking to a non-sharded collection on a sharded " + - "replica set to contain logicalTime, received: " + tojson(res.commandReply)); + var res = + assert.commandWorked(testDB.runCommand("insert", {insert: "foo", documents: [{x: 1}]})); + assert(containsValidLogicalTimeBson(res), + "Expected command body from a mongos talking to a non-sharded collection on a sharded " + + "replica set to contain logicalTime, received: " + tojson(res)); // A mongos that talks to a sharded collection on a sharded replica set returns a // logicalTime BSON object that matches the expected format. assert.commandWorked(st.s.adminCommand({enableSharding: "test"})); assert.commandWorked(st.s.adminCommand({shardCollection: "test.bar", key: {x: 1}})); - res = testDB.runCommandWithMetadata("insert", {insert: "bar", documents: [{x: 2}]}, {}); - assert.commandWorked(res.commandReply); - assert(containsValidLogicalTimeBson(res.commandReply), - "Expected commandReply from a mongos talking to a sharded collection on a sharded " + - "replica set to contain logicalTime, received: " + tojson(res.commandReply)); + res = assert.commandWorked(testDB.runCommand("insert", {insert: "bar", documents: [{x: 2}]})); + assert(containsValidLogicalTimeBson(res), + "Expected command body from a mongos talking to a sharded collection on a sharded " + + "replica set to contain logicalTime, received: " + tojson(res)); + + // Verify mongos can accept requests with $logicalTime in the command body. + assert.commandWorked(testDB.runCommand({isMaster: 1, $logicalTime: res.$logicalTime})); // A mongod in a sharded replica set returns a logicalTime bson that matches the expected // format. testDB = st.rs0.getPrimary().getDB("test"); - res = testDB.runCommandWithMetadata("insert", {insert: "foo", documents: [{x: 3}]}, {}); - assert.commandWorked(res.commandReply); - assert(containsValidLogicalTimeBson(res.metadata), - "Expected metadata in response from a mongod in a sharded replica set to contain " + - "logicalTime, received: " + tojson(res.metadata)); + res = assert.commandWorked(testDB.runCommand("insert", {insert: "foo", documents: [{x: 3}]})); + assert(containsValidLogicalTimeBson(res), + "Expected command body from a mongod in a sharded replica set to contain " + + "logicalTime, received: " + tojson(res)); + + // Verify mongod can accept requests with $logicalTime in the command body. + res = assert.commandWorked(testDB.runCommand({isMaster: 1, $logicalTime: res.$logicalTime})); st.stop(); @@ -76,11 +80,10 @@ replTest.initiate(); testDB = replTest.getPrimary().getDB("test"); - res = testDB.runCommandWithMetadata("insert", {insert: "foo", documents: [{x: 4}]}, {}); - assert.commandWorked(res.commandReply); - assert(!containsValidLogicalTimeBson(res.metadata), - "Expected metadata in response from a mongod in a non-sharded replica set to not " + - "contain logicalTime, received: " + tojson(res.metadata)); + res = assert.commandWorked(testDB.runCommand("insert", {insert: "foo", documents: [{x: 4}]})); + assert(!containsValidLogicalTimeBson(res), + "Expected command body from a mongod in a non-sharded replica set to not " + + "contain logicalTime, received: " + tojson(res)); replTest.stopSet(); @@ -88,11 +91,10 @@ var standalone = MongoRunner.runMongod(); testDB = standalone.getDB("test"); - res = testDB.runCommandWithMetadata("insert", {insert: "foo", documents: [{x: 5}]}, {}); - assert.commandWorked(res.commandReply); - assert(!containsValidLogicalTimeBson(res.metadata), - "Expected metadata in response from a standalone mongod to not contain logicalTime, " + - "received: " + tojson(res.metadata)); + res = assert.commandWorked(testDB.runCommand("insert", {insert: "foo", documents: [{x: 5}]})); + assert(!containsValidLogicalTimeBson(res), + "Expected command body from a standalone mongod to not contain logicalTime, " + + "received: " + tojson(res)); MongoRunner.stopMongod(standalone); })(); |