Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide compaction complete/update callback #355

Merged
merged 3 commits into from Nov 2, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Add test for compactionUpdateCallback

  • Loading branch information
darkdh committed Nov 1, 2019
commit 695f6265860f93015cc082a7b262c1b5c3c38afe
@@ -404,7 +404,7 @@ test('client RequestUtil', (t) => {

const testCanDoCompaction = (t) => {
t.test('#compact bookmarks', (t) => {
t.plan(3)
t.plan(7)
const recordObjectId = testHelper.newUuid()
const record2ObjectId = testHelper.newUuid()
const record = {
@@ -452,12 +452,25 @@ test('client RequestUtil', (t) => {
requestUtil.put(proto.categories.BOOKMARKS, record2_update)
}
const consoleLogBak = console.log
let counter = 0
let compactedRecord = []
const compactionUpdate = (records) => {
compactedRecord = compactedRecord.concat(records)
counter = counter + 1
}
// limit batch size to 10 to test cross batch compaction for around 40
// objects
requestUtil.list(proto.categories.BOOKMARKS, 0, 10, '', {compaction: true,
compactionUpdateCb: compactionUpdate,
compactionDoneCb: () => {
console.log = consoleLogBak
console.log('compaction is done')
t.equals(counter, 5)
t.equals(compactedRecord.length, 9)
t.equals(
compactedRecord.filter(record => record.objectId.toString() === record_update.objectId.toString()).length, 4)
t.equals(
compactedRecord.filter(record => record.objectId.toString() === record2_update.objectId.toString()).length, 5)
// we already have 15 second timeout for each batch so no need to
// do another wait after compaction is done
requestUtil.list(proto.categories.BOOKMARKS, 0, 0)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.