Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions tests/functional/aws-node-sdk/test/object/multiObjectDelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,27 @@ describe('Multi-Object Delete Success', function success() {
objects.push(`${key}${i}`);
}
const parallel = 20;
const queued = [];
const putObjectWithLimit = async key => {
while (queued.length >= parallel) {
await Promise.race(queued);
queued.splice(0, queued.findIndex(p => p === queued[0]) + 1);
// Fixed pool draining a shared queue. The previous limiter peaked
// at 999 concurrent puts and abandoned the rest on first failure.
const pending = objects.slice();
const putErrors = [];
await Promise.all(Array.from({ length: parallel }, async () => {
while (pending.length > 0) {
const objectKey = pending.shift();
try {
await s3.send(new PutObjectCommand({
Bucket: bucketName,
Key: objectKey,
Body: 'somebody',
}));
} catch (err) {
putErrors.push(err);
}
}
const result = s3.send(new PutObjectCommand({
Bucket: bucketName,
Key: key,
Body: 'somebody',
}));
queued.push(result);
return result;
};
const putPromises = objects.map(key => putObjectWithLimit(key));
await Promise.all(putPromises);
}));
if (putErrors.length > 0) {
throw putErrors[0];
}
} catch (err) {
process.stdout.write(`Error creating objects: ${err}\n`);
throw err;
Expand Down
Loading