Skip to content

Commit

Permalink
(#5157) - try to repro regression
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson committed May 22, 2016
1 parent ae4d57f commit f289d50
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/integration/test.retry.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,5 +570,57 @@ adapters.forEach(function (adapters) {

});

it('#5157 retry+live replication regression', function () {
var Promise = testUtils.Promise;
var numDocs = 1295; // uneven number
var docs = [];
for (var i = 0; i < numDocs; i++) {
// mix of generation-1 and generation-2 docs
if (i % 2 === 0) {
docs.push({
_id: testUtils.uuid(),
_rev: '1-x',
_revisions: { start: 1, ids: ['x'] }
});
} else {
docs.push({
_id: testUtils.uuid(),
_rev: '2-x',
_revisions: { start: 2, ids: ['x', 'y'] }
});
}
}
var db = new PouchDB(dbs.name);
var remote = new PouchDB(dbs.remote);
return db.bulkDocs({
docs: docs,
new_edits: false
}).then(function () {
function replicatePromise(fromDB, toDB) {
return new Promise(function (resolve, reject) {
var replication = fromDB.replicate.to(toDB, {
live: true,
retry: true,
batches_limit: 10,
batch_size: 200
}).on('paused', function (err) {
if (!err) {
replication.cancel();
}
}).on('complete', resolve)
.on('error', reject);
});
}
return Promise.all([
replicatePromise(db, remote),
replicatePromise(remote, db)
]);
}).then(function () {
return remote.info();
}).then(function (info) {
info.doc_count.should.equal(numDocs);
});
});

});
});

0 comments on commit f289d50

Please sign in to comment.