fixed test suite. It stopped working because of previous adoptions on the gc behavior. I failed to notice it..

This commit is contained in:
Kevin Jahns 2017-04-27 14:58:08 +02:00
parent a126a29876
commit 47d5899058
5 changed files with 38 additions and 15 deletions

2
dist

@ -1 +1 @@
Subproject commit 3eafd78710a30cd01bf4c6b3553c141e7ac604a5
Subproject commit e30e16c91bfab65b1e9347d21dbda8d23e12ef03

View File

@ -76,6 +76,7 @@ module.exports = function (Y/* :any */) {
}
reconnect () {
this.log('reconnecting..')
this.y.db.startGarbageCollector()
}
disconnect () {
this.log('discronnecting..')

View File

@ -147,11 +147,15 @@ module.exports = function (Y) {
return Y.utils.globalRoom.flushAll()
}
disconnect () {
var waitForMe = Promise.resolve()
if (!this.isDisconnected()) {
globalRoom.removeUser(this.userId)
super.disconnect()
waitForMe = super.disconnect()
}
return this.y.db.whenTransactionsFinished()
var self = this
return waitForMe.then(function () {
return self.y.db.whenTransactionsFinished()
})
}
flush () {
var self = this

View File

@ -39,6 +39,7 @@ module.exports = function (Y /* :any */) {
*/
constructor (y, opts) {
this.y = y
this.dbOpts = opts
var os = this
this.userId = null
var resolve
@ -75,12 +76,6 @@ module.exports = function (Y /* :any */) {
}
this.gc1 = [] // first stage
this.gc2 = [] // second stage -> after that, remove the op
this.gc = opts.gc == null || opts.gc
if (this.gc) {
this.gcTimeout = !opts.gcTimeout ? 50000 : opts.gcTimeout
} else {
this.gcTimeout = -1
}
function garbageCollect () {
return os.whenTransactionsFinished().then(function () {
@ -115,13 +110,23 @@ module.exports = function (Y /* :any */) {
})
}
this.garbageCollect = garbageCollect
if (this.gcTimeout > 0) {
garbageCollect()
}
this.startGarbageCollector()
this.repairCheckInterval = !opts.repairCheckInterval ? 6000 : opts.repairCheckInterval
this.opsReceivedTimestamp = new Date()
this.startRepairCheck()
}
startGarbageCollector () {
this.gc = this.dbOpts.gc == null || this.dbOpts.gc
if (this.gc) {
this.gcTimeout = !this.dbOpts.gcTimeout ? 50000 : this.dbOpts.gcTimeout
} else {
this.gcTimeout = -1
}
if (this.gcTimeout > 0) {
this.garbageCollect()
}
}
startRepairCheck () {
var os = this
if (this.repairCheckInterval > 0) {

View File

@ -228,6 +228,20 @@ g.compareAllUsers = async(function * compareAllUsers (users) {
var allDels1, allDels2 // all deletions
var db1 = [] // operation store of user1
yield Y.utils.globalRoom.flushAll()
yield g.garbageCollectAllUsers(users)
yield Y.utils.globalRoom.flushAll()
// disconnect, then reconnect all users
// We do this to make sure that the gc is updated by everyone
for (var i = 0; i < users.length; i++) {
yield users[i].disconnect()
yield wait()
yield users[i].reconnect()
}
yield wait()
yield Y.utils.globalRoom.flushAll()
// t1 and t2 basically do the same. They define t[1,2], ds[1,2], and allDels[1,2]
function * t1 () {
s1 = yield* this.getStateSet()
@ -245,9 +259,7 @@ g.compareAllUsers = async(function * compareAllUsers (users) {
allDels2.push(d)
})
}
yield Y.utils.globalRoom.flushAll()
yield g.garbageCollectAllUsers(users)
yield Y.utils.globalRoom.flushAll()
var buffer = Y.utils.globalRoom.buffers
for (var name in buffer) {
if (buffer[name].length > 0) {
@ -338,6 +350,7 @@ g.createUsers = async(function * createUsers (self, numberOfUsers, database, ini
namespace: 'User ' + i,
cleanStart: true,
gcTimeout: -1,
gc: true,
repairCheckInterval: -1
},
connector: {