Details
Description
Use ShardingTest to verify that CausalConsistency is supported by shell
- add negative tests verifying that causal consistency is enabled for the commands mentioned in
SERVER-28869// start a shard that could use read majorityvar st = new ShardingTest({shards:1, mongos:1, rs: {nodes:1, enableMajorityReadConcern: ""}}// once its started enable causal consistencydb.setMongo().setCausalConsistency();// check its enabled usingassert.eq(db.getMongo().getCausalConsistency(), true)// check its enabled for a command (find, aggregate, count etc ) usingdb.getMongo().isCausalConsistencyEnabled(cmdName) {}
- add negative tests verifying that causal consistency is not enabled when its not explicitly set or for commands not in the list
- add tests that check that commands work as (using find as an example):
// make sure that operation time is not setassert.isnull(mongo.getOperationTime(), ...)// make sure that cluster time is not setassert.isnull(mongo.getClusterTime(), ...)db.runCommand({find:'foo'})// make sure that operation time is still not set// make sure that cluster time is setdb.runCommand({insert:'foo', documents:[{x: 1}]})// now both cluster and operation time are setconst time = mongo.getOperationTime()// increase operation time to one day ahead and run a commandconst time = mongo.setOperationTime(increasedTime)db.runCommand({find:'foo'})// now it should fail with "Operation time can not be greater than cluster time" error// use the logical time returned as a new operation time and run the read// the result should match the write and returned operation time must be >= passed operation time