Skip to content

Commit 76c80d4

Browse files
CLDSRV-839: Check BATCH.DELETE.OBJECT unordered
1 parent 9e88ae6 commit 76c80d4

File tree

1 file changed

+71
-26
lines changed

1 file changed

+71
-26
lines changed

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

Lines changed: 71 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,29 +1710,41 @@ 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+
referer: null,
1725+
userAgent: null,
1726+
},
1727+
{
1728+
...commonProperties,
1729+
operation: 'BATCH.DELETE.OBJECT',
1730+
action: 'DeleteObjects',
1731+
objectKey: `${objectKey}2`,
1732+
httpCode: 204,
1733+
httpMethod: 'POST',
1734+
referer: null,
1735+
userAgent: null,
1736+
},
1737+
{
1738+
...commonProperties,
1739+
operation: 'BATCH.DELETE.OBJECT',
1740+
action: 'DeleteObjects',
1741+
objectKey: `${objectKey}-non-existent`,
1742+
httpCode: 204,
1743+
httpMethod: 'POST',
1744+
referer: null,
1745+
userAgent: null,
1746+
},
1747+
],
17361748
},
17371749
{
17381750
...commonProperties,
@@ -2679,13 +2691,46 @@ describe('Server Access Logs - File Output', async () => {
26792691
for (const operation of operations) {
26802692
it(`should log correct ${operation.methodName} operation with all required fields`, async () => {
26812693
await operation.method();
2682-
const logEntries = await waitForLogs(logFilePath, operation.expected.length,
2694+
// Count total expected logs, including unordered entries
2695+
let totalExpected = 0;
2696+
for (const exp of operation.expected) {
2697+
totalExpected += exp.unordered ? exp.unordered.length : 1;
2698+
}
2699+
const logEntries = await waitForLogs(logFilePath, totalExpected,
26832700
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}`);
2701+
assert.strictEqual(logEntries.length, totalExpected,
2702+
`Expected ${totalExpected} log entries, got ${logEntries.length}`);
26862703

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

0 commit comments

Comments
 (0)