Added jsconfig.json, fixed tests for large numbers
This commit is contained in:
parent
9fc55f5386
commit
aa2e7fd917
30
.vscode/launch.json
vendored
Normal file
30
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Launch",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "node_modules/gulp/bin/gulp.js",
|
||||||
|
"stopOnEntry": false,
|
||||||
|
"args": ["test"],
|
||||||
|
"cwd": ".",
|
||||||
|
"runtimeExecutable": null,
|
||||||
|
"runtimeArgs": [
|
||||||
|
"--nolazy"
|
||||||
|
],
|
||||||
|
"env": {
|
||||||
|
"NODE_ENV": "development"
|
||||||
|
},
|
||||||
|
"externalConsole": false,
|
||||||
|
"sourceMaps": false,
|
||||||
|
"outDir": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Attach",
|
||||||
|
"type": "node",
|
||||||
|
"request": "attach",
|
||||||
|
"port": 5858
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
// Place your settings in this file to overwrite default and user settings.
|
||||||
|
{
|
||||||
|
}
|
6
jsconfig.json
Normal file
6
jsconfig.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES6",
|
||||||
|
"module": "commonjs"
|
||||||
|
}
|
||||||
|
}
|
@ -189,26 +189,26 @@ module.exports = function (Y) {
|
|||||||
var broadcastHB = !this.broadcastedHB
|
var broadcastHB = !this.broadcastedHB
|
||||||
this.broadcastedHB = true
|
this.broadcastedHB = true
|
||||||
var db = this.y.db
|
var db = this.y.db
|
||||||
this.syncStep2 = new Promise(function (resolve) {
|
var defer = Promise.defer()
|
||||||
|
this.syncStep2 = defer.promise
|
||||||
|
db.requestTransaction(function * () {
|
||||||
|
yield* this.applyDeleteSet(m.deleteSet)
|
||||||
|
this.store.apply(m.os)
|
||||||
db.requestTransaction(function * () {
|
db.requestTransaction(function * () {
|
||||||
yield* this.applyDeleteSet(m.deleteSet)
|
var ops = yield* this.getOperations(m.stateSet)
|
||||||
this.store.apply(m.os)
|
if (ops.length > 0) {
|
||||||
db.requestTransaction(function * () {
|
m = {
|
||||||
var ops = yield* this.getOperations(m.stateSet)
|
type: 'update',
|
||||||
if (ops.length > 0) {
|
ops: ops
|
||||||
m = {
|
|
||||||
type: 'update',
|
|
||||||
ops: ops
|
|
||||||
}
|
|
||||||
if (!broadcastHB) { // TODO: consider to broadcast here..
|
|
||||||
conn.send(sender, m)
|
|
||||||
} else {
|
|
||||||
// broadcast only once!
|
|
||||||
conn.broadcast(m)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
resolve()
|
if (!broadcastHB) { // TODO: consider to broadcast here..
|
||||||
})
|
conn.send(sender, m)
|
||||||
|
} else {
|
||||||
|
// broadcast only once!
|
||||||
|
conn.broadcast(m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defer.resolve()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else if (m.type === 'sync done') {
|
} else if (m.type === 'sync done') {
|
||||||
|
@ -24,11 +24,16 @@ module.exports = function (Y) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
whenTransactionsFinished: function () {
|
whenTransactionsFinished: function () {
|
||||||
var ps = []
|
var self = this
|
||||||
for (var name in this.users) {
|
return new Promise (function (resolve) {
|
||||||
ps.push(this.users[name].y.db.whenTransactionsFinished())
|
wait().then(function () {
|
||||||
}
|
var ps = []
|
||||||
return Promise.all(ps)
|
for (var name in self.users) {
|
||||||
|
ps.push(self.users[name].y.db.whenTransactionsFinished())
|
||||||
|
}
|
||||||
|
Promise.all(ps).then(resolve)
|
||||||
|
})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
flushOne: function flushOne () {
|
flushOne: function flushOne () {
|
||||||
var bufs = []
|
var bufs = []
|
||||||
@ -46,6 +51,32 @@ module.exports = function (Y) {
|
|||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
flushAll: function () {
|
||||||
|
return new Promise(function (resolve) {
|
||||||
|
// flushes may result in more created operations,
|
||||||
|
// flush until there is nothing more to flush
|
||||||
|
function nextFlush () {
|
||||||
|
var c = globalRoom.flushOne()
|
||||||
|
if (c) {
|
||||||
|
while (c = globalRoom.flushOne()) {
|
||||||
|
}
|
||||||
|
globalRoom.whenTransactionsFinished().then(nextFlush)
|
||||||
|
} else {
|
||||||
|
setTimeout(function () {
|
||||||
|
var c = globalRoom.flushOne()
|
||||||
|
if (c) {
|
||||||
|
c.then(function () {
|
||||||
|
globalRoom.whenTransactionsFinished().then(nextFlush)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
}, 10)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
globalRoom.whenTransactionsFinished().then(nextFlush)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Y.utils.globalRoom = globalRoom
|
Y.utils.globalRoom = globalRoom
|
||||||
@ -88,7 +119,7 @@ module.exports = function (Y) {
|
|||||||
globalRoom.addUser(this)
|
globalRoom.addUser(this)
|
||||||
super.reconnect()
|
super.reconnect()
|
||||||
}
|
}
|
||||||
return this.flushAll()
|
return Y.utils.globalRoom.flushAll()
|
||||||
}
|
}
|
||||||
disconnect () {
|
disconnect () {
|
||||||
if (!this.isDisconnected()) {
|
if (!this.isDisconnected()) {
|
||||||
@ -107,24 +138,6 @@ module.exports = function (Y) {
|
|||||||
yield self.whenTransactionsFinished()
|
yield self.whenTransactionsFinished()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
flushAll () {
|
|
||||||
return new Promise(function (resolve) {
|
|
||||||
// flushes may result in more created operations,
|
|
||||||
// flush until there is nothing more to flush
|
|
||||||
function nextFlush () {
|
|
||||||
var c = globalRoom.flushOne()
|
|
||||||
if (c) {
|
|
||||||
while (globalRoom.flushOne()) {
|
|
||||||
// nop
|
|
||||||
}
|
|
||||||
globalRoom.whenTransactionsFinished().then(nextFlush)
|
|
||||||
} else {
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
globalRoom.whenTransactionsFinished().then(nextFlush)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Y.Test = Test
|
Y.Test = Test
|
||||||
|
@ -343,14 +343,15 @@ module.exports = function (Y) {
|
|||||||
requestTransaction (makeGen, callImmediately) {
|
requestTransaction (makeGen, callImmediately) {
|
||||||
if (callImmediately) {
|
if (callImmediately) {
|
||||||
this.transact(makeGen)
|
this.transact(makeGen)
|
||||||
} else if (!this.transactionInProgress) {
|
|
||||||
this.transactionInProgress = true
|
|
||||||
var self = this
|
|
||||||
setTimeout(function () {
|
|
||||||
self.transact(makeGen)
|
|
||||||
}, 0)
|
|
||||||
} else {
|
} else {
|
||||||
this.waitingTransactions.push(makeGen)
|
this.waitingTransactions.push(makeGen)
|
||||||
|
if (!this.transactionInProgress) {
|
||||||
|
this.transactionInProgress = true
|
||||||
|
var self = this
|
||||||
|
setTimeout(function () {
|
||||||
|
self.transact(self.getNextRequest())
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* global async, databases */
|
/* global async, databases, describe, beforeEach, afterEach */
|
||||||
/* eslint-env browser,jasmine,console */
|
/* eslint-env browser,jasmine,console */
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ g.g = g
|
|||||||
|
|
||||||
g.YConcurrency_TestingMode = true
|
g.YConcurrency_TestingMode = true
|
||||||
|
|
||||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 8000
|
||||||
|
|
||||||
g.describeManyTimes = function describeManyTimes (times, name, f) {
|
g.describeManyTimes = function describeManyTimes (times, name, f) {
|
||||||
for (var i = 0; i < times; i++) {
|
for (var i = 0; i < times; i++) {
|
||||||
@ -36,8 +36,6 @@ g.describeManyTimes = function describeManyTimes (times, name, f) {
|
|||||||
Wait for a specified amount of time (in ms). defaults to 5ms
|
Wait for a specified amount of time (in ms). defaults to 5ms
|
||||||
*/
|
*/
|
||||||
function wait (t) {
|
function wait (t) {
|
||||||
throw new Error("waiting..")
|
|
||||||
console.log("waiting..", t)
|
|
||||||
if (t == null) {
|
if (t == null) {
|
||||||
t = 5
|
t = 5
|
||||||
}
|
}
|
||||||
@ -106,24 +104,24 @@ function * applyTransactions (relAmount, numberOfTransactions, objects, users, t
|
|||||||
|
|
||||||
g.applyRandomTransactionsAllRejoinNoGC = async(function * applyRandomTransactions (users, objects, transactions, numberOfTransactions) {
|
g.applyRandomTransactionsAllRejoinNoGC = async(function * applyRandomTransactions (users, objects, transactions, numberOfTransactions) {
|
||||||
yield* applyTransactions(1, numberOfTransactions, objects, users, transactions)
|
yield* applyTransactions(1, numberOfTransactions, objects, users, transactions)
|
||||||
yield users[0].connector.flushAll()
|
yield Y.utils.globalRoom.flushAll()
|
||||||
for (var u in users) {
|
for (var u in users) {
|
||||||
yield users[u].reconnect()
|
yield users[u].reconnect()
|
||||||
}
|
}
|
||||||
yield users[0].connector.flushAll()
|
yield Y.utils.globalRoom.flushAll()
|
||||||
yield g.garbageCollectAllUsers(users)
|
yield g.garbageCollectAllUsers(users)
|
||||||
})
|
})
|
||||||
|
|
||||||
g.applyRandomTransactionsWithGC = async(function * applyRandomTransactions (users, objects, transactions, numberOfTransactions) {
|
g.applyRandomTransactionsWithGC = async(function * applyRandomTransactions (users, objects, transactions, numberOfTransactions) {
|
||||||
yield* applyTransactions(1, numberOfTransactions, objects, users.slice(1), transactions)
|
yield* applyTransactions(1, numberOfTransactions, objects, users.slice(1), transactions)
|
||||||
yield users[0].connector.flushAll()
|
yield Y.utils.globalRoom.flushAll()
|
||||||
yield g.garbageCollectAllUsers(users)
|
yield g.garbageCollectAllUsers(users)
|
||||||
for (var u in users) {
|
for (var u in users) {
|
||||||
// TODO: here, we enforce that two users never sync at the same time with u[0]
|
// TODO: here, we enforce that two users never sync at the same time with u[0]
|
||||||
// enforce that in the connector itself!
|
// enforce that in the connector itself!
|
||||||
yield users[u].reconnect()
|
yield users[u].reconnect()
|
||||||
}
|
}
|
||||||
yield users[0].connector.flushAll()
|
yield Y.utils.globalRoom.flushAll()
|
||||||
yield g.garbageCollectAllUsers(users)
|
yield g.garbageCollectAllUsers(users)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -158,8 +156,15 @@ g.compareAllUsers = async(function * compareAllUsers (users) {
|
|||||||
allDels2.push(d)
|
allDels2.push(d)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
yield users[0].connector.flushAll()
|
yield Y.utils.globalRoom.flushAll()
|
||||||
yield g.garbageCollectAllUsers(users)
|
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) {
|
||||||
|
debugger // not all ops were transmitted..
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (var uid = 0; uid < users.length; uid++) {
|
for (var uid = 0; uid < users.length; uid++) {
|
||||||
var u = users[uid]
|
var u = users[uid]
|
||||||
@ -219,7 +224,7 @@ g.compareAllUsers = async(function * compareAllUsers (users) {
|
|||||||
|
|
||||||
g.createUsers = async(function * createUsers (self, numberOfUsers, database) {
|
g.createUsers = async(function * createUsers (self, numberOfUsers, database) {
|
||||||
if (Y.utils.globalRoom.users[0] != null) {
|
if (Y.utils.globalRoom.users[0] != null) {
|
||||||
yield Y.utils.globalRoom.users[0].flushAll()
|
yield Y.utils.globalRoom.flushAll()
|
||||||
}
|
}
|
||||||
// destroy old users
|
// destroy old users
|
||||||
for (var u in Y.utils.globalRoom.users) {
|
for (var u in Y.utils.globalRoom.users) {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
var Y = require('../SpecHelper.js')
|
var Y = require('../SpecHelper.js')
|
||||||
var numberOfYMapTests = 10
|
var numberOfYMapTests = 100
|
||||||
var repeatMapTeasts = 1
|
var repeatMapTeasts = 1
|
||||||
|
|
||||||
for (let database of databases) {
|
for (let database of databases) {
|
||||||
@ -16,7 +16,7 @@ for (let database of databases) {
|
|||||||
y2 = this.users[1].root
|
y2 = this.users[1].root
|
||||||
y3 = this.users[2].root
|
y3 = this.users[2].root
|
||||||
y4 = this.users[3].root
|
y4 = this.users[3].root
|
||||||
flushAll = this.users[0].connector.flushAll
|
flushAll = Y.utils.globalRoom.flushAll
|
||||||
done()
|
done()
|
||||||
}))
|
}))
|
||||||
afterEach(async(function * (done) {
|
afterEach(async(function * (done) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user