Skip to content

Commit

Permalink
add missing overhead field used in S3C
Browse files Browse the repository at this point in the history
This field is used in bucket notification in case
of delete events as we don't have metadata for that
type of event

Issue: BB-535
  • Loading branch information
Kerkesni committed Oct 2, 2024
1 parent a1e9895 commit ffeb595
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/queuePopulator/LogReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ class LogReader {
const overheadFields = {
commitTimestamp: record.timestamp,
opTimestamp: entry.timestamp,
versionId: entry.overhead?.versionId,
};
const entryToFilter = {
type: entry.type,
Expand Down
52 changes: 52 additions & 0 deletions tests/unit/lib/queuePopulator/LogReader.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ describe('LogReader', () => {
overheadFields: {
commitTimestamp: record.timestamp,
opTimestamp: '2023-11-29T15:05:57.065Z',
versionId: undefined,
},
};
assert(mockExtension.filter.firstCall.calledWith(expectedArgs));
Expand Down Expand Up @@ -155,6 +156,7 @@ describe('LogReader', () => {
overheadFields: {
commitTimestamp: record.timestamp,
opTimestamp: '2023-11-29T15:05:57.065Z',
versionId: undefined,
},
};
assert(mockExtension.filter.firstCall.calledWith(expectedArgs));
Expand Down Expand Up @@ -244,4 +246,54 @@ describe('LogReader', () => {
});
});
});

describe('_processLogEntry', () => {
[
{
description: 'with overhead fields',
overhead: null,
}, {
description: 'without overhead fields',
overhead: {
versionId: '1234',
},
}
].forEach(params => {
it(`should pass the proper fields to the filter method (${params.description})`, done => {
const date = Date.now();
const record = {
db: 'example-bucket',
timestamp: date,
};
const entry = {
type: 'put',
key: 'example-key',
timestamp: date,
value: null,
overhead: params.overhead,
};
logReader._extensions = [
{
filter: sinon.stub().returns(),
},
];
logReader._processLogEntry({}, record, entry, err => {
assert.ifError(err);
assert(logReader._extensions[0].filter.calledWithMatch({
type: 'put',
bucket: 'example-bucket',
key: 'example-key',
value: null,
logReader,
overheadFields: {
commitTimestamp: date,
opTimestamp: date,
...params.overhead,
},
}));
done();
});
});
});
});
});

0 comments on commit ffeb595

Please sign in to comment.