Skip to content

Commit 9c6c2be

Browse files
CLDSRV-839: Check BATCH.DELETE.OBJECT unordered
1 parent 5b3223b commit 9c6c2be

File tree

1 file changed

+65
-26
lines changed

1 file changed

+65
-26
lines changed

tests/functional/aws-node-sdk/test/serverAccessLogs/testServerAccessLogFile.js

Lines changed: 65 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,29 +1710,35 @@ describe('Server Access Logs - File Output', async () => {
17101710
objectKey: `${objectKey}2`,
17111711
httpMethod: 'PUT',
17121712
},
1713+
// Objects are deleted concurrently, they might get logged in any order
1714+
// for example errors or non-existent objects might get logged first
17131715
{
1714-
...commonProperties,
1715-
operation: 'BATCH.DELETE.OBJECT',
1716-
action: 'DeleteObject',
1717-
objectKey,
1718-
httpCode: 204,
1719-
httpMethod: 'POST',
1720-
},
1721-
{
1722-
...commonProperties,
1723-
operation: 'BATCH.DELETE.OBJECT',
1724-
action: 'DeleteObject',
1725-
objectKey: `${objectKey}2`,
1726-
httpCode: 204,
1727-
httpMethod: 'POST',
1728-
},
1729-
{
1730-
...commonProperties,
1731-
operation: 'BATCH.DELETE.OBJECT',
1732-
action: 'DeleteObject',
1733-
objectKey: `${objectKey}-non-existent`,
1734-
httpCode: 204,
1735-
httpMethod: 'POST',
1716+
unordered: [
1717+
{
1718+
...commonProperties,
1719+
operation: 'BATCH.DELETE.OBJECT',
1720+
action: 'DeleteObjects',
1721+
objectKey,
1722+
httpCode: 204,
1723+
httpMethod: 'POST',
1724+
},
1725+
{
1726+
...commonProperties,
1727+
operation: 'BATCH.DELETE.OBJECT',
1728+
action: 'DeleteObjects',
1729+
objectKey: `${objectKey}2`,
1730+
httpCode: 204,
1731+
httpMethod: 'POST',
1732+
},
1733+
{
1734+
...commonProperties,
1735+
operation: 'BATCH.DELETE.OBJECT',
1736+
action: 'DeleteObjects',
1737+
objectKey: `${objectKey}-non-existent`,
1738+
httpCode: 204,
1739+
httpMethod: 'POST',
1740+
},
1741+
],
17361742
},
17371743
{
17381744
...commonProperties,
@@ -2679,13 +2685,46 @@ describe('Server Access Logs - File Output', async () => {
26792685
for (const operation of operations) {
26802686
it(`should log correct ${operation.methodName} operation with all required fields`, async () => {
26812687
await operation.method();
2682-
const logEntries = await waitForLogs(logFilePath, operation.expected.length,
2688+
// Count total expected logs, including unordered entries
2689+
let totalExpected = 0;
2690+
for (const exp of operation.expected) {
2691+
totalExpected += exp.unordered ? exp.unordered.length : 1;
2692+
}
2693+
const logEntries = await waitForLogs(logFilePath, totalExpected,
26832694
TEST_CONFIG.MAX_LOG_WAIT_RETRIES, TEST_CONFIG.LOG_POLL_DELAY_MS);
2684-
assert.strictEqual(logEntries.length, operation.expected.length,
2685-
`Expected ${operation.expected.length} log entries, got ${logEntries.length}`);
2695+
assert.strictEqual(logEntries.length, totalExpected,
2696+
`Expected ${totalExpected} log entries, got ${logEntries.length}`);
26862697

2698+
let logIdx = 0;
2699+
2700+
// Validate entries (ordered or unordered)
26872701
for (let i = 0; i < operation.expected.length; i++) {
2688-
validateLogEntry(logEntries[i], operation.expected[i]);
2702+
const expected = operation.expected[i];
2703+
2704+
if (expected.unordered) {
2705+
// Handle unordered entries
2706+
const unorderedLogs = logEntries.slice(logIdx, logIdx + expected.unordered.length);
2707+
const remaining = [...expected.unordered];
2708+
2709+
for (const logEntry of unorderedLogs) {
2710+
const matchIdx = remaining.findIndex(exp => exp.objectKey === logEntry.objectKey);
2711+
2712+
assert.notStrictEqual(matchIdx, -1,
2713+
`Unexpected log entry with objectKey: ${logEntry.objectKey}`);
2714+
2715+
validateLogEntry(logEntry, remaining[matchIdx]);
2716+
remaining.splice(matchIdx, 1);
2717+
}
2718+
2719+
assert.strictEqual(remaining.length, 0,
2720+
`Missing expected entries: ${JSON.stringify(remaining)}`);
2721+
2722+
logIdx += expected.unordered.length;
2723+
} else {
2724+
// Handle ordered entry
2725+
validateLogEntry(logEntries[logIdx], expected);
2726+
logIdx++;
2727+
}
26892728
}
26902729
});
26912730
}

0 commit comments

Comments
 (0)