mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Make some white-box tests less flaky
If we want the *internal* state of the oplog driver to be consistent, we need to make sure that we start our observes at a consistent point in the oplog. (ie, initial inserts need to have been fully processed, so that we don't process them during the original QUERYING phase, which can give us a different unpublished buffer.) Note that only the white-box tests (looked at _unpublishedBuffer, eg) appeared to be flaky: the actual docs published seemed to be correct in all cases.
This commit is contained in:
@@ -818,6 +818,8 @@ if (Meteor.isServer) {
|
||||
|
||||
// Insert a doc and start observing.
|
||||
var docId1 = ins({foo: 22, bar: 5});
|
||||
waitUntilOplogCaughtUp();
|
||||
|
||||
// State: [ 5:1 | ]!
|
||||
var o = observer();
|
||||
var usesOplog = o.handle._multiplexer._observeDriver._usesOplog;
|
||||
@@ -1154,6 +1156,10 @@ if (Meteor.isServer) {
|
||||
ids[i] = ins({ x: x, y: i });
|
||||
});
|
||||
|
||||
// Ensure that we are past all the 'i' entries before we run the query, so
|
||||
// that we get the expected phase transitions.
|
||||
waitUntilOplogCaughtUp();
|
||||
|
||||
var o = observer();
|
||||
var usesOplog = o.handle._multiplexer._observeDriver._usesOplog;
|
||||
// x: [1 1 2 | 2 3 3] 4 5 5 5 9
|
||||
@@ -2407,8 +2413,7 @@ Meteor.isServer && Tinytest.add("mongo-livedata - oplog - include selector field
|
||||
// during the observeChanges, the bug in question is not consistently
|
||||
// reproduced.) We don't have to do this for polling observe (eg
|
||||
// --disable-oplog).
|
||||
var oplog = MongoInternals.defaultRemoteCollectionDriver().mongo._oplogHandle;
|
||||
oplog && oplog.waitUntilCaughtUp();
|
||||
waitUntilOplogCaughtUp();
|
||||
|
||||
var output = [];
|
||||
var handle = coll.find({a: 1, b: 2}, {fields: {c: 1}}).observeChanges({
|
||||
@@ -2450,8 +2455,7 @@ Meteor.isServer && Tinytest.add("mongo-livedata - oplog - transform", function (
|
||||
// during the observeChanges, the bug in question is not consistently
|
||||
// reproduced.) We don't have to do this for polling observe (eg
|
||||
// --disable-oplog).
|
||||
var oplog = MongoInternals.defaultRemoteCollectionDriver().mongo._oplogHandle;
|
||||
oplog && oplog.waitUntilCaughtUp();
|
||||
waitUntilOplogCaughtUp();
|
||||
|
||||
var cursor = coll.find({}, {transform: function (doc) {
|
||||
return doc.x;
|
||||
@@ -2513,8 +2517,7 @@ Meteor.isServer && Tinytest.add("mongo-livedata - oplog - drop collection", func
|
||||
|
||||
// Wait until we've processed the insert oplog entry, so that we are in a
|
||||
// steady state (and we don't see the dropped docs because we are FETCHING).
|
||||
var oplog = MongoInternals.defaultRemoteCollectionDriver().mongo._oplogHandle;
|
||||
oplog && oplog.waitUntilCaughtUp();
|
||||
waitUntilOplogCaughtUp();
|
||||
|
||||
// Drop the collection. Should remove all docs.
|
||||
runInFence(function () {
|
||||
@@ -2664,3 +2667,12 @@ testAsyncMulti("mongo-livedata - oplog - update EJSON", [
|
||||
self.handle.stop();
|
||||
}
|
||||
]);
|
||||
|
||||
|
||||
var waitUntilOplogCaughtUp = function () {
|
||||
var oplogHandle =
|
||||
MongoInternals.defaultRemoteCollectionDriver().mongo._oplogHandle;
|
||||
if (oplogHandle)
|
||||
oplogHandle.waitUntilCaughtUp();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user