Compare commits

...

1 Commits

Author SHA1 Message Date
KillianG 7fae232296
Remove userMD counting restore retries and add tests
Issue: CLDSRV-403
2023-06-09 13:43:56 +00:00
6 changed files with 84 additions and 56 deletions

View File

@ -182,6 +182,9 @@ const services = {
'ongoing-request': false,
'expiry-date': archive.restoreWillExpireAt,
});
md.setUserMetadata({
'x-amz-meta-scal-s3-restore-attempt': undefined,
});
}
if (oldReplayId) {

View File

@ -718,7 +718,7 @@ describe('Object Part Copy', () => {
archiveVersion: 5577006791947779
},
};
fakeMetadataArchive(sourceBucketName, sourceObjName, undefined, archive, err => {
fakeMetadataArchive(sourceBucketName, sourceObjName, undefined, archive, undefined, err => {
assert.ifError(err);
s3.uploadPartCopy({
Bucket: destBucketName,
@ -760,7 +760,7 @@ describe('Object Part Copy', () => {
restoreCompletedAt: new Date(10),
restoreWillExpireAt: new Date(10 + (5 * 24 * 60 * 60 * 1000)),
};
fakeMetadataArchive(sourceBucketName, sourceObjName, undefined, archiveCompleted, err => {
fakeMetadataArchive(sourceBucketName, sourceObjName, undefined, archiveCompleted, undefined, err => {
assert.ifError(err);
s3.uploadPartCopy({
Bucket: destBucketName,

View File

@ -18,6 +18,8 @@ const archive = {
restoreRequestedAt: new Date(0).toString(),
restoreRequestedDays: 5,
};
const userMD = { 'x-amz-meta-scal-s3-restore-attempt': 3 };
function putMPUVersion(s3, bucketName, objectName, vId, cb) {
async.waterfall([
@ -91,8 +93,13 @@ function checkVersionsAndUpdate(versionsBefore, versionsAfter, indexes) {
function checkObjMdAndUpdate(objMDBefore, objMDAfter, props) {
props.forEach(p => {
assert.notStrictEqual(objMDAfter[p], objMDBefore[p]);
// eslint-disable-next-line no-param-reassign
objMDBefore[p] = objMDAfter[p];
if (objMDAfter[p] === undefined) {
// eslint-disable-next-line no-param-reassign
delete objMDBefore[p];
} else {
// eslint-disable-next-line no-param-reassign
objMDBefore[p] = objMDAfter[p];
}
});
}
@ -135,7 +142,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
async.series([
next => putMPU(s3, bucketName, objectName, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archive, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archive, userMD, next),
next => getMetadata(bucketName, objectName, undefined, (err, objMD) => {
objMDBefore = objMD;
return next(err);
@ -160,7 +167,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
checkObjMdAndUpdate(objMDBefore, objMDAfter,
['location', 'uploadId', 'microVersionId', 'x-amz-restore',
'archive', 'dataStoreName', 'originOp']);
'archive', 'dataStoreName', 'originOp', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
@ -176,7 +183,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
async.series([
next => s3.putObject(params, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archive, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archive, userMD, next),
next => getMetadata(bucketName, objectName, undefined, (err, objMD) => {
objMDBefore = objMD;
return next(err);
@ -202,7 +209,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
checkObjMdAndUpdate(objMDBefore, objMDAfter,
['location', 'content-length', 'content-md5', 'originOp', 'uploadId', 'microVersionId',
'x-amz-restore', 'archive', 'dataStoreName']);
'x-amz-restore', 'archive', 'dataStoreName', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
@ -229,7 +236,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
vId = res.VersionId;
return next(err);
}),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, next),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, userMD, next),
next => metadata.listObject(bucketName, mdListingParams, log, (err, res) => {
versionsBefore = res.Versions;
return next(err);
@ -255,7 +262,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
checkObjMdAndUpdate(objMDBefore, objMDAfter,
['location', 'content-length', 'content-md5', 'originOp', 'uploadId', 'microVersionId',
'x-amz-restore', 'archive', 'dataStoreName']);
'x-amz-restore', 'archive', 'dataStoreName', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
});
@ -281,7 +288,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
vId = res.VersionId;
return next(err);
}),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, next),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, userMD, next),
next => metadata.listObject(bucketName, mdListingParams, log, (err, res) => {
versionsBefore = res.Versions;
return next(err);
@ -307,7 +314,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
checkObjMdAndUpdate(objMDBefore, objMDAfter,
['location', 'content-length', 'content-md5', 'originOp', 'uploadId', 'microVersionId',
'x-amz-restore', 'archive', 'dataStoreName']);
'x-amz-restore', 'archive', 'dataStoreName', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
});
@ -388,7 +395,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
next => s3.putObject(params, next),
next => s3.putBucketVersioning(vParams, next),
next => s3.putObject(params, next),
next => fakeMetadataArchive(bucketName, objectName, 'null', archive, next),
next => fakeMetadataArchive(bucketName, objectName, 'null', archive, userMD, next),
next => getMetadata(bucketName, objectName, 'null', (err, objMD) => {
objMDBefore = objMD;
return next(err);
@ -414,7 +421,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
checkObjMdAndUpdate(objMDBefore, objMDAfter,
['location', 'content-length', 'content-md5', 'originOp', 'uploadId', 'microVersionId',
'x-amz-restore', 'archive', 'dataStoreName']);
'x-amz-restore', 'archive', 'dataStoreName', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
});
@ -441,7 +448,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
vId = res.VersionId;
return next(err);
}),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, next),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, userMD, next),
next => getMetadata(bucketName, objectName, vId, (err, objMD) => {
objMDBefore = objMD;
return next(err);
@ -467,7 +474,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
checkObjMdAndUpdate(objMDBefore, objMDAfter,
['location', 'content-length', 'content-md5', 'originOp', 'uploadId', 'microVersionId',
'x-amz-restore', 'archive', 'dataStoreName']);
'x-amz-restore', 'archive', 'dataStoreName', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
});
@ -497,7 +504,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
next => s3.putObject(params, next),
next => s3.putBucketVersioning(sParams, next),
next => s3.putObject(params, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archive, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archive, userMD, next),
next => getMetadata(bucketName, objectName, undefined, (err, objMD) => {
objMDBefore = objMD;
return next(err);
@ -523,7 +530,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
checkObjMdAndUpdate(objMDBefore, objMDAfter,
['location', 'content-length', 'content-md5', 'originOp', 'uploadId', 'microVersionId',
'x-amz-restore', 'archive', 'dataStoreName']);
'x-amz-restore', 'archive', 'dataStoreName', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
});
@ -555,7 +562,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
versionsBefore = res.Versions;
return next(err);
}),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, next),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, userMD, next),
next => getMetadata(bucketName, objectName, vId, (err, objMD) => {
objMDBefore = objMD;
return next(err);
@ -577,7 +584,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
checkObjMdAndUpdate(objMDBefore, objMDAfter,
['location', 'content-length', 'content-md5', 'originOp', 'uploadId', 'microVersionId',
'x-amz-restore', 'archive', 'dataStoreName']);
'x-amz-restore', 'archive', 'dataStoreName', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
});
@ -604,7 +611,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
vId = res.VersionId;
return next(err);
}),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, next),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, userMD, next),
next => metadata.listObject(bucketName, mdListingParams, log, (err, res) => {
versionsBefore = res.Versions;
return next(err);
@ -630,7 +637,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
checkObjMdAndUpdate(objMDBefore, objMDAfter,
['location', 'content-length', 'content-md5', 'originOp', 'uploadId', 'microVersionId',
'x-amz-restore', 'archive', 'dataStoreName']);
'x-amz-restore', 'archive', 'dataStoreName', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
});
@ -663,7 +670,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
vId = res.VersionId;
return next(err);
}),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, next),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, userMD, next),
next => metadata.listObject(bucketName, mdListingParams, log, (err, res) => {
versionsBefore = res.Versions;
return next(err);
@ -690,7 +697,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
checkObjMdAndUpdate(objMDBefore, objMDAfter,
['location', 'content-length', 'content-md5', 'originOp', 'uploadId', 'microVersionId',
'x-amz-restore', 'archive', 'dataStoreName']);
'x-amz-restore', 'archive', 'dataStoreName', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
});
@ -715,7 +722,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
versionsBefore = res.Versions;
return next(err);
}),
next => fakeMetadataArchive(bucketName, objectName, undefined, archive, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archive, userMD, next),
next => getMetadata(bucketName, objectName, undefined, (err, objMD) => {
objMDBefore = objMD;
return next(err);
@ -738,7 +745,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
checkObjMdAndUpdate(objMDBefore, objMDAfter,
['location', 'content-length', 'content-md5', 'originOp', 'uploadId', 'microVersionId',
'x-amz-restore', 'archive', 'dataStoreName']);
'x-amz-restore', 'archive', 'dataStoreName', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
@ -799,7 +806,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
async.series([
next => s3.putObject(params, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archiveCompleted, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archiveCompleted, userMD, next),
next => putMPUVersion(s3, bucketName, objectName, '', err => {
checkError(err, 'InvalidObjectState', 403);
return next();
@ -817,7 +824,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
async.series([
next => s3.putObject(params, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archive, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archive, userMD, next),
next => getMetadata(bucketName, objectName, undefined, (err, objMD) => {
objMDBefore = objMD;
return next(err);

View File

@ -1243,7 +1243,7 @@ describe('Object Copy', () => {
archiveVersion: 5577006791947779
},
};
fakeMetadataArchive(sourceBucketName, sourceObjName, undefined, archive, err => {
fakeMetadataArchive(sourceBucketName, sourceObjName, undefined, archive, undefined, err => {
assert.ifError(err);
s3.copyObject({
Bucket: destBucketName,
@ -1279,7 +1279,7 @@ describe('Object Copy', () => {
restoreCompletedAt: new Date(10),
restoreWillExpireAt: new Date(10 + (5 * 24 * 60 * 60 * 1000)),
};
fakeMetadataArchive(sourceBucketName, sourceObjName, undefined, archiveCompleted, err => {
fakeMetadataArchive(sourceBucketName, sourceObjName, undefined, archiveCompleted, undefined, err => {
assert.ifError(err);
s3.copyObject({
Bucket: destBucketName,

View File

@ -18,6 +18,7 @@ const archive = {
restoreRequestedAt: new Date(0).toString(),
restoreRequestedDays: 5,
};
const userMD = { 'x-amz-meta-scal-s3-restore-attempt': 3 };
function putObjectVersion(s3, params, vid, next) {
const paramsWithBody = { ...params, Body: '123' };
@ -42,8 +43,13 @@ function checkVersionsAndUpdate(versionsBefore, versionsAfter, indexes) {
function checkObjMdAndUpdate(objMDBefore, objMDAfter, props) {
props.forEach(p => {
assert.notStrictEqual(objMDAfter[p], objMDBefore[p]);
// eslint-disable-next-line no-param-reassign
objMDBefore[p] = objMDAfter[p];
if (objMDAfter[p] === undefined) {
// eslint-disable-next-line no-param-reassign
delete objMDBefore[p];
} else {
// eslint-disable-next-line no-param-reassign
objMDBefore[p] = objMDAfter[p];
}
});
}
@ -87,7 +93,7 @@ describe('PUT object with x-scal-s3-version-id header', () => {
async.series([
next => s3.putObject(params, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archive, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archive, userMD, next),
next => getMetadata(bucketName, objectName, undefined, (err, objMD) => {
objMDBefore = objMD;
return next(err);
@ -112,7 +118,8 @@ describe('PUT object with x-scal-s3-version-id header', () => {
assert.deepStrictEqual(versionsAfter, versionsBefore);
checkObjMdAndUpdate(objMDBefore, objMDAfter, ['location', 'content-length', 'content-md5',
'microVersionId', 'x-amz-restore', 'archive', 'dataStoreName', 'originOp']);
'microVersionId', 'x-amz-restore', 'archive',
'dataStoreName', 'originOp', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
});
@ -138,7 +145,7 @@ describe('PUT object with x-scal-s3-version-id header', () => {
vId = res.VersionId;
return next(err);
}),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, next),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, userMD, next),
next => metadata.listObject(bucketName, mdListingParams, log, (err, res) => {
versionsBefore = res.Versions;
return next(err);
@ -163,7 +170,8 @@ describe('PUT object with x-scal-s3-version-id header', () => {
assert.deepStrictEqual(versionsAfter, versionsBefore);
checkObjMdAndUpdate(objMDBefore, objMDAfter, ['location', 'content-length', 'originOp',
'content-md5', 'microVersionId', 'x-amz-restore', 'archive', 'dataStoreName']);
'content-md5', 'microVersionId',
'x-amz-restore', 'archive', 'dataStoreName', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
});
@ -189,7 +197,7 @@ describe('PUT object with x-scal-s3-version-id header', () => {
vId = res.VersionId;
return next(err);
}),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, next),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, userMD, next),
next => metadata.listObject(bucketName, mdListingParams, log, (err, res) => {
versionsBefore = res.Versions;
return next(err);
@ -214,7 +222,8 @@ describe('PUT object with x-scal-s3-version-id header', () => {
assert.deepStrictEqual(versionsAfter, versionsBefore);
checkObjMdAndUpdate(objMDBefore, objMDAfter, ['location', 'content-length', 'originOp',
'content-md5', 'microVersionId', 'x-amz-restore', 'archive', 'dataStoreName']);
'content-md5', 'microVersionId', 'x-amz-restore',
'archive', 'dataStoreName', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
});
@ -237,7 +246,7 @@ describe('PUT object with x-scal-s3-version-id header', () => {
vId = res.VersionId;
return next(err);
}),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, next),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, userMD, next),
next => putObjectVersion(s3, params, 'aJLWKz4Ko9IjBBgXKj5KQT.G9UHv0g7P', err => {
checkError(err, 'InvalidArgument', 400);
return next();
@ -302,7 +311,7 @@ describe('PUT object with x-scal-s3-version-id header', () => {
next => s3.putObject(params, next),
next => s3.putBucketVersioning(vParams, next),
next => s3.putObject(params, next),
next => fakeMetadataArchive(bucketName, objectName, 'null', archive, next),
next => fakeMetadataArchive(bucketName, objectName, 'null', archive, userMD, next),
next => getMetadata(bucketName, objectName, 'null', (err, objMD) => {
objMDBefore = objMD;
return next(err);
@ -327,7 +336,8 @@ describe('PUT object with x-scal-s3-version-id header', () => {
assert.deepStrictEqual(versionsAfter, versionsBefore);
checkObjMdAndUpdate(objMDBefore, objMDAfter, ['location', 'content-length', 'originOp',
'content-md5', 'microVersionId', 'x-amz-restore', 'archive', 'dataStoreName']);
'content-md5', 'microVersionId', 'x-amz-restore',
'archive', 'dataStoreName', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
});
@ -354,7 +364,7 @@ describe('PUT object with x-scal-s3-version-id header', () => {
vId = res.VersionId;
return next(err);
}),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, next),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, userMD, next),
next => getMetadata(bucketName, objectName, vId, (err, objMD) => {
objMDBefore = objMD;
return next(err);
@ -379,7 +389,8 @@ describe('PUT object with x-scal-s3-version-id header', () => {
assert.deepStrictEqual(versionsAfter, versionsBefore);
checkObjMdAndUpdate(objMDBefore, objMDAfter, ['location', 'content-length', 'originOp',
'content-md5', 'microVersionId', 'x-amz-restore', 'archive', 'dataStoreName']);
'content-md5', 'microVersionId', 'x-amz-restore',
'archive', 'dataStoreName', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
});
@ -409,7 +420,7 @@ describe('PUT object with x-scal-s3-version-id header', () => {
next => s3.putObject(params, next),
next => s3.putBucketVersioning(sParams, next),
next => s3.putObject(params, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archive, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archive, userMD, next),
next => getMetadata(bucketName, objectName, undefined, (err, objMD) => {
objMDBefore = objMD;
return next(err);
@ -434,7 +445,8 @@ describe('PUT object with x-scal-s3-version-id header', () => {
assert.deepStrictEqual(versionsAfter, versionsBefore);
checkObjMdAndUpdate(objMDBefore, objMDAfter, ['location', 'content-length', 'originOp',
'content-md5', 'microVersionId', 'x-amz-restore', 'archive', 'dataStoreName']);
'content-md5', 'microVersionId', 'x-amz-restore',
'archive', 'dataStoreName', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
});
@ -461,7 +473,7 @@ describe('PUT object with x-scal-s3-version-id header', () => {
vId = res.VersionId;
return next(err);
}),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, next),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, userMD, next),
next => s3.putObject(params, next),
next => metadata.listObject(bucketName, mdListingParams, log, (err, res) => {
versionsBefore = res.Versions;
@ -487,7 +499,8 @@ describe('PUT object with x-scal-s3-version-id header', () => {
assert.deepStrictEqual(versionsAfter, versionsBefore);
checkObjMdAndUpdate(objMDBefore, objMDAfter, ['location', 'content-length', 'originOp',
'content-md5', 'microVersionId', 'x-amz-restore', 'archive', 'dataStoreName']);
'content-md5', 'microVersionId', 'x-amz-restore',
'archive', 'dataStoreName', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
});
@ -514,7 +527,7 @@ describe('PUT object with x-scal-s3-version-id header', () => {
vId = res.VersionId;
return next(err);
}),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, next),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, userMD, next),
next => metadata.listObject(bucketName, mdListingParams, log, (err, res) => {
versionsBefore = res.Versions;
return next(err);
@ -539,7 +552,8 @@ describe('PUT object with x-scal-s3-version-id header', () => {
assert.deepStrictEqual(versionsAfter, versionsBefore);
checkObjMdAndUpdate(objMDBefore, objMDAfter, ['location', 'content-length', 'originOp',
'content-md5', 'microVersionId', 'x-amz-restore', 'archive', 'dataStoreName']);
'content-md5', 'microVersionId', 'x-amz-restore',
'archive', 'dataStoreName', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
});
@ -572,7 +586,7 @@ describe('PUT object with x-scal-s3-version-id header', () => {
vId = res.VersionId;
return next(err);
}),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, next),
next => fakeMetadataArchive(bucketName, objectName, vId, archive, userMD, next),
next => metadata.listObject(bucketName, mdListingParams, log, (err, res) => {
versionsBefore = res.Versions;
return next(err);
@ -598,7 +612,8 @@ describe('PUT object with x-scal-s3-version-id header', () => {
assert.deepStrictEqual(versionsAfter, versionsBefore);
checkObjMdAndUpdate(objMDBefore, objMDAfter, ['location', 'content-length', 'originOp',
'content-md5', 'microVersionId', 'x-amz-restore', 'archive', 'dataStoreName']);
'content-md5', 'microVersionId', 'x-amz-restore',
'archive', 'dataStoreName', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
});
@ -619,7 +634,7 @@ describe('PUT object with x-scal-s3-version-id header', () => {
async.series([
next => s3.putObject(params, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archive, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archive, userMD, next),
next => metadata.listObject(bucketName, mdListingParams, log, (err, res) => {
versionsBefore = res.Versions;
return next(err);
@ -645,7 +660,8 @@ describe('PUT object with x-scal-s3-version-id header', () => {
assert.deepStrictEqual(versionsAfter, versionsBefore);
checkObjMdAndUpdate(objMDBefore, objMDAfter, ['location', 'content-length', 'originOp',
'content-md5', 'microVersionId', 'x-amz-restore', 'archive', 'dataStoreName']);
'content-md5', 'microVersionId', 'x-amz-restore',
'archive', 'dataStoreName', 'x-amz-meta-scal-s3-restore-attempt']);
assert.deepStrictEqual(objMDAfter, objMDBefore);
return done();
});
@ -705,7 +721,7 @@ describe('PUT object with x-scal-s3-version-id header', () => {
async.series([
next => s3.putObject(params, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archiveCompleted, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archiveCompleted, userMD, next),
next => putObjectVersion(s3, params, '', err => {
checkError(err, 'InvalidObjectState', 403);
return next();
@ -723,7 +739,7 @@ describe('PUT object with x-scal-s3-version-id header', () => {
async.series([
next => s3.putObject(params, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archive, next),
next => fakeMetadataArchive(bucketName, objectName, undefined, archive, userMD, next),
next => getMetadata(bucketName, objectName, undefined, (err, objMD) => {
objMDBefore = objMD;
return next(err);

View File

@ -68,10 +68,11 @@ function fakeMetadataTransition(bucketName, objectName, versionId, cb) {
* @param {string} objectName obejct name
* @param {string} versionId encoded object version id
* @param {Object} archive archive info object
* @param {Object} userMD user metadata
* @param {Function} cb callback
* @returns {undefined}
*/
function fakeMetadataArchive(bucketName, objectName, versionId, archive, cb) {
function fakeMetadataArchive(bucketName, objectName, versionId, archive, userMD, cb) {
return getMetadata(bucketName, objectName, versionId, (err, objMD) => {
if (err) {
return cb(err);
@ -79,6 +80,7 @@ function fakeMetadataArchive(bucketName, objectName, versionId, archive, cb) {
/* eslint-disable no-param-reassign */
objMD.dataStoreName = 'location-dmf-v1';
objMD.archive = archive;
Object.assign(objMD, userMD);
/* eslint-enable no-param-reassign */
return metadata.putObjectMD(bucketName, objectName, objMD, { versionId: decodeVersionId(versionId) },
log, err => cb(err));