diff options
author | Randolph Tan <randolph@10gen.com> | 2017-03-07 17:11:34 -0500 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2017-03-14 16:51:35 -0400 |
commit | e1ce1ad010926fc5c67851b88a212b6f035f3e77 (patch) | |
tree | a0cce3f3f2eacfc4e9f40d5971c9e6084efe8330 /jstests/sharding/logical_time_metadata.js | |
parent | 6fd95f8c1b97d72c411bc5a1c84b1d5a8efe4c07 (diff) | |
download | mongo-e1ce1ad010926fc5c67851b88a212b6f035f3e77.tar.gz |
SERVER-27750 Handle and include LogicalTime in mongos request/response
Diffstat (limited to 'jstests/sharding/logical_time_metadata.js')
-rw-r--r-- | jstests/sharding/logical_time_metadata.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/jstests/sharding/logical_time_metadata.js b/jstests/sharding/logical_time_metadata.js new file mode 100644 index 00000000000..efb1fcc785c --- /dev/null +++ b/jstests/sharding/logical_time_metadata.js @@ -0,0 +1,31 @@ +/** + * Basic test that checks that mongos includes the logical time metatadata in it's response. + * This does not test logical time propagation via the shell as there are many back channels + * where the logical time metadata can propagated, making it inherently racy. + */ +(function() { + var st = new ShardingTest({shards: {rs0: {nodes: 3}}}); + st.s.adminCommand({enableSharding: 'test'}); + + var db = st.s.getDB('test'); + + // insert on one shard and extract the logical time + var res = assert.commandWorked(db.runCommand({insert: 'user', documents: [{x: 10}]})); + assert.hasFields(res, ['logicalTime']); + + var logicalTimeMetadata = res.logicalTime; + assert.hasFields(logicalTimeMetadata, ['clusterTime', 'signature']); + + res = st.rs0.getPrimary().adminCommand({replSetGetStatus: 1}); + + var appliedTime = res.optimes.appliedOpTime.ts; + assert.eq(0, + timestampCmp(appliedTime, logicalTimeMetadata.clusterTime), + 'appliedTime: ' + tojson(appliedTime) + ' != clusterTime: ' + + tojson(logicalTimeMetadata.clusterTime)); + + assert.commandWorked(db.runCommand({ping: 1, logicalTime: logicalTimeMetadata})); + + st.stop(); + +})(); |