fixed test suite. It stopped working because of previous adoptions on the gc behavior. I failed to notice it..
This commit is contained in:
parent
a126a29876
commit
47d5899058
2
dist
2
dist
@ -1 +1 @@
|
|||||||
Subproject commit 3eafd78710a30cd01bf4c6b3553c141e7ac604a5
|
Subproject commit e30e16c91bfab65b1e9347d21dbda8d23e12ef03
|
@ -76,6 +76,7 @@ module.exports = function (Y/* :any */) {
|
|||||||
}
|
}
|
||||||
reconnect () {
|
reconnect () {
|
||||||
this.log('reconnecting..')
|
this.log('reconnecting..')
|
||||||
|
this.y.db.startGarbageCollector()
|
||||||
}
|
}
|
||||||
disconnect () {
|
disconnect () {
|
||||||
this.log('discronnecting..')
|
this.log('discronnecting..')
|
||||||
|
@ -147,11 +147,15 @@ module.exports = function (Y) {
|
|||||||
return Y.utils.globalRoom.flushAll()
|
return Y.utils.globalRoom.flushAll()
|
||||||
}
|
}
|
||||||
disconnect () {
|
disconnect () {
|
||||||
|
var waitForMe = Promise.resolve()
|
||||||
if (!this.isDisconnected()) {
|
if (!this.isDisconnected()) {
|
||||||
globalRoom.removeUser(this.userId)
|
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 () {
|
flush () {
|
||||||
var self = this
|
var self = this
|
||||||
|
@ -39,6 +39,7 @@ module.exports = function (Y /* :any */) {
|
|||||||
*/
|
*/
|
||||||
constructor (y, opts) {
|
constructor (y, opts) {
|
||||||
this.y = y
|
this.y = y
|
||||||
|
this.dbOpts = opts
|
||||||
var os = this
|
var os = this
|
||||||
this.userId = null
|
this.userId = null
|
||||||
var resolve
|
var resolve
|
||||||
@ -75,12 +76,6 @@ module.exports = function (Y /* :any */) {
|
|||||||
}
|
}
|
||||||
this.gc1 = [] // first stage
|
this.gc1 = [] // first stage
|
||||||
this.gc2 = [] // second stage -> after that, remove the op
|
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 () {
|
function garbageCollect () {
|
||||||
return os.whenTransactionsFinished().then(function () {
|
return os.whenTransactionsFinished().then(function () {
|
||||||
@ -115,13 +110,23 @@ module.exports = function (Y /* :any */) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.garbageCollect = garbageCollect
|
this.garbageCollect = garbageCollect
|
||||||
if (this.gcTimeout > 0) {
|
this.startGarbageCollector()
|
||||||
garbageCollect()
|
|
||||||
}
|
|
||||||
this.repairCheckInterval = !opts.repairCheckInterval ? 6000 : opts.repairCheckInterval
|
this.repairCheckInterval = !opts.repairCheckInterval ? 6000 : opts.repairCheckInterval
|
||||||
this.opsReceivedTimestamp = new Date()
|
this.opsReceivedTimestamp = new Date()
|
||||||
this.startRepairCheck()
|
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 () {
|
startRepairCheck () {
|
||||||
var os = this
|
var os = this
|
||||||
if (this.repairCheckInterval > 0) {
|
if (this.repairCheckInterval > 0) {
|
||||||
|
@ -228,6 +228,20 @@ g.compareAllUsers = async(function * compareAllUsers (users) {
|
|||||||
var allDels1, allDels2 // all deletions
|
var allDels1, allDels2 // all deletions
|
||||||
var db1 = [] // operation store of user1
|
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]
|
// t1 and t2 basically do the same. They define t[1,2], ds[1,2], and allDels[1,2]
|
||||||
function * t1 () {
|
function * t1 () {
|
||||||
s1 = yield* this.getStateSet()
|
s1 = yield* this.getStateSet()
|
||||||
@ -245,9 +259,7 @@ g.compareAllUsers = async(function * compareAllUsers (users) {
|
|||||||
allDels2.push(d)
|
allDels2.push(d)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
yield Y.utils.globalRoom.flushAll()
|
|
||||||
yield g.garbageCollectAllUsers(users)
|
|
||||||
yield Y.utils.globalRoom.flushAll()
|
|
||||||
var buffer = Y.utils.globalRoom.buffers
|
var buffer = Y.utils.globalRoom.buffers
|
||||||
for (var name in buffer) {
|
for (var name in buffer) {
|
||||||
if (buffer[name].length > 0) {
|
if (buffer[name].length > 0) {
|
||||||
@ -338,6 +350,7 @@ g.createUsers = async(function * createUsers (self, numberOfUsers, database, ini
|
|||||||
namespace: 'User ' + i,
|
namespace: 'User ' + i,
|
||||||
cleanStart: true,
|
cleanStart: true,
|
||||||
gcTimeout: -1,
|
gcTimeout: -1,
|
||||||
|
gc: true,
|
||||||
repairCheckInterval: -1
|
repairCheckInterval: -1
|
||||||
},
|
},
|
||||||
connector: {
|
connector: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user