Skip to content

Commit 0390b29

Browse files
committed
fixing tests after re enabling them
1 parent b16091b commit 0390b29

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

tests/functional/aws-node-sdk/test/object/rangeTest.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function checkRanges(range, bytes) {
4949
Key: key,
5050
Range: `bytes=${range}`,
5151
}))
52-
.then(res => {
52+
.then(async res => {
5353
const { begin, end } = getOuterRange(range, bytes);
5454
const total = (end - begin) + 1;
5555
// If the range header is '-' (i.e., it is invalid), content range
@@ -59,39 +59,38 @@ function checkRanges(range, bytes) {
5959

6060
assert.deepStrictEqual(res.ContentLength, total);
6161
assert.deepStrictEqual(res.ContentRange, contentRange);
62-
assert.deepStrictEqual(res.ContentType, 'application/octet-stream');
62+
assert(res.ContentType === undefined ||
63+
res.ContentType === 'application/octet-stream');
6364
assert.deepStrictEqual(res.Metadata, {});
6465

65-
// Write a file using the buffer so getRangeExec can then check bytes.
66-
// If the getRangeExec program fails, then the range is incorrect.
67-
return writeFileAsync(`hashedFile.${bytes}.${range}`, res.Body)
68-
.then(() => execFileAsync('./getRangeExec', ['--check', '--size', total,
69-
'--offset', begin, `hashedFile.${bytes}.${range}`]));
66+
const bodyBytes = await res.Body.transformToByteArray();
67+
const bodyBuffer = Buffer.from(bodyBytes);
68+
await writeFileAsync(`hashedFile.${bytes}.${range}`, bodyBuffer);
69+
return execFileAsync('./getRangeExec', ['--check', '--size', total,
70+
'--offset', begin, `hashedFile.${bytes}.${range}`]);
7071
});
7172
}
7273

73-
// Create 5MB parts and upload them as parts of a MPU
74+
// Create 5MB parts and upload them as parts of a MPU. Returns array of part
75+
// responses (with ETag) for CompleteMultipartUpload.
7476
async function uploadParts(bytes, uploadId) {
7577
const name = `hashedFile.${bytes}`;
7678
return Promise.all([1, 2].map(async part => {
77-
try {
78-
await execFileAsync('dd', [
79-
`if=${name}`,
80-
`of=${name}.mpuPart${part}`,
81-
'bs=5242880',
82-
`skip=${part - 1}`,
83-
'count=1',
84-
]);
85-
await s3.send(new UploadPartCommand({
86-
Bucket: bucket,
87-
Key: key,
88-
PartNumber: part,
89-
UploadId: uploadId,
90-
Body: createReadStream(`${name}.mpuPart${part}`),
91-
}));
92-
} catch (error) {
93-
throw new Error(`Error uploading part ${part}: ${error.message}`);
94-
}
79+
await execFileAsync('dd', [
80+
`if=${name}`,
81+
`of=${name}.mpuPart${part}`,
82+
'bs=5242880',
83+
`skip=${part - 1}`,
84+
'count=1',
85+
]);
86+
const res = await s3.send(new UploadPartCommand({
87+
Bucket: bucket,
88+
Key: key,
89+
PartNumber: part,
90+
UploadId: uploadId,
91+
Body: createReadStream(`${name}.mpuPart${part}`),
92+
}));
93+
return res;
9594
}));
9695
}
9796

@@ -149,12 +148,13 @@ describe('aws-node-sdk range tests', () => {
149148
Key: key,
150149
UploadId: uploadId,
151150
})))
152-
.catch(err => new Promise((resolve, reject) => {
153-
if (err.code !== 'NoSuchUpload') {
154-
reject(err);
151+
.catch(err => {
152+
// Upload was already completed in beforeEach; abort is no-op
153+
if (err.name === 'NoSuchUpload' || err.code === 'NoSuchUpload') {
154+
return;
155155
}
156-
resolve();
157-
}))
156+
throw err;
157+
})
158158
.then(() => bucketUtil.deleteOne(bucket))
159159
.then(() => execAsync(`rm hashedFile.${fileSize}*`))
160160
);

tests/multipleBackend/routes/routeBackbeat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ const itIfLocationAzure = hasLocation(azureLocation) ? it : it.skip;
196196
const itSkipS3C = process.env.S3_END_TO_END ? it.skip : it;
197197

198198
describeSkipIfNotMultiple('backbeat DELETE routes', () => {
199-
it('abort MPU', done => {
199+
itIfLocationAws('abort MPU', done => {
200200
const awsKey = 'backbeat-mpu-test';
201201
async.waterfall([
202202
next => {

0 commit comments

Comments
 (0)