Skip to content

Commit

Permalink
Skip flaky test (#55)
Browse files Browse the repository at this point in the history
* Skip flaky test

* only skip for macos

---------

Co-authored-by: Christophe Diederichs <[email protected]>
  • Loading branch information
HDegroote and chm-diederichs authored Feb 21, 2024
1 parent 4410efe commit fb8273e
Showing 1 changed file with 55 additions and 50 deletions.
105 changes: 55 additions & 50 deletions test/fast-forward.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const os = require('os')
const test = require('brittle')
const tmpDir = require('test-tmp')
const cenc = require('compact-encoding')
Expand All @@ -14,6 +15,8 @@ const {
createBase
} = require('./helpers')

const IS_MAC_OSX = os.platform === 'darwin'

test('fast-forward - simple', async t => {
t.plan(1)

Expand Down Expand Up @@ -245,77 +248,79 @@ test('fast-forward - multiple queues', async t => {
}
})

test('fast-forward - open with no remote io', async t => {
const { bases, stores } = await create(2, t, {
apply: applyOldState,
fastForward: true,
storage: () => tmpDir(t)
})
if (!IS_MAC_OSX) {
test('fast-forward - open with no remote io', async t => {
const { bases, stores } = await create(2, t, {
apply: applyOldState,
fastForward: true,
storage: () => tmpDir(t)
})

const [a, b] = bases
const [a, b] = bases

await b.ready()
await b.ready()

for (let i = 0; i < 1000; i++) {
await a.append('a' + i)
}
for (let i = 0; i < 1000; i++) {
await a.append('a' + i)
}

await addWriterAndSync(a, b)
const unreplicate = replicate([a, b])
await addWriterAndSync(a, b)
const unreplicate = replicate([a, b])

const core = b.view.getBackingCore()
const sparse = await isSparse(core)
const core = b.view.getBackingCore()
const sparse = await isSparse(core)

t.ok(sparse > 0)
t.comment('sparse blocks: ' + sparse)
t.ok(sparse > 0)
t.comment('sparse blocks: ' + sparse)

await b.append('b1')
await b.append('b2')
await b.append('b3')
await b.append('b1')
await b.append('b2')
await b.append('b3')

await unreplicate()
await unreplicate()

await a.append('a1001')
await a.append('a1001')

await b.close()
await b.close()

const local = a.local
const remote = stores[1].get({ key: local.key })
const local = a.local
const remote = stores[1].get({ key: local.key })

const s1 = local.replicate(true)
const s2 = remote.replicate(false)
const s1 = local.replicate(true)
const s2 = remote.replicate(false)

s1.pipe(s2).pipe(s1)
s1.pipe(s2).pipe(s1)

await remote.download({ end: local.length }).downloaded()
await remote.download({ end: local.length }).downloaded()

s1.destroy()
await new Promise(resolve => s2.on('close', resolve))
s1.destroy()
await new Promise(resolve => s2.on('close', resolve))

const b2 = await createBase(stores[1].session(), a.local.key, t, {
apply: applyOldState
})
const b2 = await createBase(stores[1].session(), a.local.key, t, {
apply: applyOldState
})

await b2.ready()
await t.execution(b2.ready())
await b2.ready()
await t.execution(b2.ready())

async function applyOldState (batch, view, base) {
for (const { value } of batch) {
if (value.add) {
const key = Buffer.from(value.add, 'hex')
await base.addWriter(key, { indexer: value.indexer })
continue
}
async function applyOldState (batch, view, base) {
for (const { value } of batch) {
if (value.add) {
const key = Buffer.from(value.add, 'hex')
await base.addWriter(key, { indexer: value.indexer })
continue
}

if (view) await view.append(value)
const core = view._source.core.session
if (view) await view.append(value)
const core = view._source.core.session

// get well distributed unique index
const index = (view.length * 67 + view.length * 89) % core.length
if (core.length) await core.get(index)
// get well distributed unique index
const index = (view.length * 67 + view.length * 89) % core.length
if (core.length) await core.get(index)
}
}
}
})
})
}

test('fast-forward - force reset then ff', async t => {
t.plan(9)
Expand Down

0 comments on commit fb8273e

Please sign in to comment.