Skip to content

Commit 18b5231

Browse files
committed
tests: Separate fake (atomic) and fake-nc-bookmarks (non-atomic) tests
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
1 parent 6e3a0c3 commit 18b5231

2 files changed

Lines changed: 37 additions & 19 deletions

File tree

.github/workflows/nodejs-fake-test.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
npm run test:node:fake
8080
8181
nodejs-benchmark:
82-
name: Node.js Benchmark ${{ matrix.seed != github.sha && '🌱' || ''}}${{ matrix.seed != github.sha && matrix.seed || ''}}
82+
name: Node.js Benchmark ${{ matrix.adapter }} ${{ matrix.seed != github.sha && '🌱' || ''}}${{ matrix.seed != github.sha && matrix.seed || ''}}
8383

8484
runs-on: ubuntu-latest
8585

@@ -89,6 +89,9 @@ jobs:
8989
matrix:
9090
node-version: [ 20.x ]
9191
npm-version: [ 10.x ]
92+
adapter:
93+
- fake
94+
- fake-nc-bookmarks
9295
seed:
9396
- ${{ github.sha }}
9497
- "3"
@@ -132,5 +135,6 @@ jobs:
132135
working-directory: floccus
133136
env:
134137
FLOCCUS_TEST_SEED: ${{ matrix.seed }}
138+
FLOCCUS_TEST_ACCOUNTS: ${{ matrix.adapter }}
135139
run: |
136140
npm run test:node:fake:benchmark

src/test/benchmark.test.js

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe('Floccus', function() {
8080
account1.onSyncProcessCreated = armInterrupt
8181
account2.onSyncProcessCreated = armInterrupt
8282

83-
if (ACCOUNT_DATA.type.startsWith('fake')) {
83+
if (ACCOUNT_DATA.type === 'fake') {
8484
// Wire both accounts to the same fake db
8585
// We do not set the cache properties to the same object, because we want to only write onSynComplete
8686
let fakeServerDb = new Folder(
@@ -109,6 +109,36 @@ describe('Floccus', function() {
109109
})
110110
account2.server.__defineGetter__('highestId', () => account1.server.highestId)
111111
}
112+
if (ACCOUNT_DATA.type === 'fake-nc-bookmarks') {
113+
// Wire both accounts to the same fake db
114+
// We do not set the cache properties to the same object, because we want to only write onSynComplete
115+
let fakeServerDb = new Folder({
116+
id: '',
117+
title: 'root',
118+
location: 'Server',
119+
})
120+
account1.server.__defineSetter__('bookmarksCache', (db) => {
121+
fakeServerDb = db
122+
})
123+
account2.server.__defineSetter__('bookmarksCache', (db) => {
124+
fakeServerDb = db
125+
})
126+
account1.server.__defineGetter__(
127+
'bookmarksCache',
128+
() => fakeServerDb
129+
)
130+
account2.server.__defineGetter__(
131+
'bookmarksCache',
132+
() => fakeServerDb
133+
)
134+
account2.server.__defineSetter__('highestId', (id) => {
135+
account1.server.highestId = id
136+
})
137+
account2.server.__defineGetter__(
138+
'highestId',
139+
() => account1.server.highestId
140+
)
141+
}
112142
if (ACCOUNT_DATA.noCache) {
113143
account1.storage.setCache = () => {
114144
// noop
@@ -1098,8 +1128,7 @@ describe('Floccus', function() {
10981128
serverTreeAfterInit = null
10991129
}
11001130
})
1101-
let interruptBenchmark
1102-
it('should handle fuzzed changes with deletions from two clients with interrupts' + (ACCOUNT_DATA.type === 'fake' ? ' (with caching)' : ''), interruptBenchmark = async function() {
1131+
it('should handle fuzzed changes with deletions from two clients with interrupts', async function() {
11031132
const localResource1 = await account1.getResource()
11041133
const localRoot1 = (await localResource1.getBookmarksTree()).id
11051134
let bookmarks1 = []
@@ -1355,21 +1384,6 @@ describe('Floccus', function() {
13551384
}
13561385
})
13571386

1358-
if (ACCOUNT_DATA.type === 'fake') {
1359-
it('should handle fuzzed changes with deletions from two clients with interrupts (no caching adapter)', async function() {
1360-
// Wire both accounts to the same fake db
1361-
// We set the cache properties to the same object, because we want to simulate nextcloud-bookmarks
1362-
const bmDb = account1.server.bookmarksCache = account2.server.bookmarksCache = new Folder(
1363-
{ id: '', title: 'root', location: 'Server' }
1364-
)
1365-
account1.server.onSyncStart = function() { this.bookmarksCache = bmDb }
1366-
account1.server.isAtomic = () => false
1367-
account2.server.onSyncStart = function() { this.bookmarksCache = bmDb }
1368-
account2.server.isAtomic = () => false
1369-
await interruptBenchmark()
1370-
})
1371-
}
1372-
13731387
it('unidirectional should handle fuzzed changes from two clients', async function() {
13741388
await account2.setData({ strategy: 'slave'})
13751389

0 commit comments

Comments
 (0)