Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-28892

Test Causal Consistency in shell

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.7
    • Affects Version/s: None
    • Component/s: Sharding
    • None
    • Fully Compatible
    • Sharding 2017-05-08, Sharding 2017-05-29

      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 majority
        var st = new ShardingTest({shards:1, mongos:1, rs: {nodes:1, enableMajorityReadConcern: ""}}
        
        // once its started enable causal consistency
        db.setMongo().setCausalConsistency();
        
        // check its enabled using 
        assert.eq(db.getMongo().getCausalConsistency(), true)
        
        // check its enabled for a command (find, aggregate, count etc ) using 
        db.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 set 
        assert.isnull(mongo.getOperationTime(), ...)
        
        // make sure that cluster time is not set 
        assert.isnull(mongo.getClusterTime(), ...)
        
        db.runCommand({find:'foo'})
        // make sure that operation time is still not set 
        // make sure that cluster time is set 
        
        
        db.runCommand({insert:'foo', documents:[{x: 1}]})
        // now both cluster and operation time are set
        const time = mongo.getOperationTime()
        
        // increase operation time to one day ahead and run a command
        const 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
        

            Assignee:
            jack.mulrow@mongodb.com Jack Mulrow
            Reporter:
            misha.tyulenev@mongodb.com Misha Tyulenev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: