jstests/noPassthroughWithMongod/query_oplogreplay.js
// Test queries that set the OplogReplay flag.
Test queries that set the OplogReplay flag.
Test queries that set the OplogReplay flag .
function test(t) {
    t.drop();
    assert.commandWorked(t.getDB().createCollection(t.getName(), {capped: true, size: 16*1024}));
    function makeTS(i) {
        return Timestamp(1000, i)
    }
    for (var i = 0; i < 100; i++) {
        t.save({_id: i, ts: makeTS(i)});
    }
    assert.throws(function() {
        t.find().addOption(DBQuery.Option.oplogReplay).next();
    });
    assert.throws(function() {
        t.find({_id: 3}).addOption(DBQuery.Option.oplogReplay).next();
    });
    assert.throws(function() {
        t.find({$or: [{ts: {$gt: makeTS(3)}}, {foo: 3}]})
              .addOption(DBQuery.Option.oplogReplay).next();
    });
    assert.throws(function() {
        t.find({$nor: [{ts: {$gt: makeTS(4)}}, {foo: 4}]})
              .addOption(DBQuery.Option.oplogReplay).next();
    });
    assert.throws(function() {
        t.find({ts: {$lt: makeTS(4)}}).addOption(DBQuery.Option.oplogReplay).next();
    });
    assert.throws(function() {
        t.find({ts: {$lt: makeTS(4)}, _id: 3}).addOption(DBQuery.Option.oplogReplay).next();
    });
    var cursor = t.find({ts: {$gt: makeTS(20)}}).addOption(DBQuery.Option.oplogReplay);
    assert.eq(21, cursor.next()["_id"]);
    assert.eq(22, cursor.next()["_id"]);
    cursor = t.find({ts: {$gte: makeTS(20)}, _id: 25}).addOption(DBQuery.Option.oplogReplay);
    assert.eq(25, cursor.next()["_id"]);
    assert(!cursor.hasNext());
}
function test ( t ) { t . drop ( ) ; assert . commandWorked ( t . getDB ( ) . createCollection ( t . getName ( ) , { capped : true , size : 16 * 1024 } ) ) ; function makeTS ( i ) { return Timestamp ( 1000 , i ) } for ( var i = 0 ; i < 100 ; i ++ ) { t . save ( { _id : i , ts : makeTS ( i ) } ) ; } assert . throws ( function ( ) { t . find ( ) . addOption ( DBQuery . Option . oplogReplay ) . next ( ) ; } ) ; assert . throws ( function ( ) { t . find ( { _id : 3 } ) . addOption ( DBQuery . Option . oplogReplay ) . next ( ) ; } ) ; assert . throws ( function ( ) { t . find ( { $or : [ { ts : { $gt : makeTS ( 3 ) } } , { foo : 3 } ] } ) . addOption ( DBQuery . Option . oplogReplay ) . next ( ) ; } ) ; assert . throws ( function ( ) { t . find ( { $nor : [ { ts : { $gt : makeTS ( 4 ) } } , { foo : 4 } ] } ) . addOption ( DBQuery . Option . oplogReplay ) . next ( ) ; } ) ; assert . throws ( function ( ) { t . find ( { ts : { $lt : makeTS ( 4 ) } } ) . addOption ( DBQuery . Option . oplogReplay ) . next ( ) ; } ) ; assert . throws ( function ( ) { t . find ( { ts : { $lt : makeTS ( 4 ) } , _id : 3 } ) . addOption ( DBQuery . Option . oplogReplay ) . next ( ) ; } ) ; var cursor = t . find ( { ts : { $gt : makeTS ( 20 ) } } ) . addOption ( DBQuery . Option . oplogReplay ) ; assert . eq ( 21 , cursor . next ( ) [ "_id" ] ) ; assert . eq ( 22 , cursor . next ( ) [ "_id" ] ) ; cursor = t . find ( { ts : { $gte : makeTS ( 20 ) } , _id : 25 } ) . addOption ( DBQuery . Option . oplogReplay ) ; assert . eq ( 25 , cursor . next ( ) [ "_id" ] ) ; assert ( ! cursor . hasNext ( ) ) ; }
Test queries that set the OplogReplay flag.
Test queries that set the OplogReplay flag .
// Missing 'ts' field. // 'ts' field is not top-level. // Predicate over 'ts' is not $gt or $gte. // Query on just the 'ts' field. // Query over both 'ts' and '_id' should only pay attention to the 'ts' // field for finding the oplog start (SERVER-13566).