-
Notifications
You must be signed in to change notification settings - Fork 253
Improvement/cldsrv 561 add tests for create and store object #6082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development/9.3
Are you sure you want to change the base?
Changes from all commits
d5fdd77
1ec4d6f
57227d6
3d5ca31
ac53023
cebeb28
1ac13d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| const assert = require('assert'); | ||
| const async = require('async'); | ||
| const { promisify } = require('util'); | ||
|
|
||
| const withV4 = require('../support/withV4'); | ||
| const BucketUtility = require('../../lib/utility/bucket-util'); | ||
|
|
@@ -956,6 +957,71 @@ describe('PUT object with x-scal-s3-version-id header', () => { | |
| }, | ||
| ], done); | ||
| }); | ||
|
|
||
| it('should set restore originOp and drop restore-attempt metadata', done => { | ||
| const params = { Bucket: bucketName, Key: objectName }; | ||
|
|
||
| async.series([ | ||
| next => s3.send(new PutObjectCommand({ | ||
| ...params, | ||
| Metadata: { | ||
| 'custom-md': 'preserved-value', | ||
| }, | ||
| })).then(() => next()).catch(next), | ||
| next => fakeMetadataArchive(bucketName, objectName, undefined, archive, next), | ||
| next => getMetadata(bucketName, objectName, undefined, (err, objMD) => { | ||
| if (err) { | ||
| return next(err); | ||
| } | ||
| /* eslint-disable no-param-reassign */ | ||
| objMD['x-amz-meta-scal-s3-restore-attempt'] = '3'; | ||
| /* eslint-enable no-param-reassign */ | ||
| return metadata.putObjectMD(bucketName, objectName, objMD, undefined, log, next); | ||
| }), | ||
| next => putObjectVersion(s3, params, '', next), | ||
| next => getMetadata(bucketName, objectName, undefined, (err, objMD) => { | ||
| if (err) { | ||
| return next(err); | ||
| } | ||
| assert.strictEqual(objMD.originOp, 's3:ObjectRestore:Completed'); | ||
| assert.strictEqual(objMD['x-amz-meta-custom-md'], 'preserved-value'); | ||
| assert.strictEqual(objMD['x-amz-meta-scal-s3-restore-attempt'], undefined); | ||
| return next(); | ||
| }), | ||
| ], done); | ||
| }); | ||
|
|
||
| it('should keep x-amz-meta-scal-version-id when restoring on ingestion bucket', async () => { | ||
| const ingestionBucketName = `ingestion-restore-${Date.now()}`; | ||
| const params = { Bucket: ingestionBucketName, Key: objectName }; | ||
| let putVersionId; | ||
| const fakeMetadataArchivePromise = promisify(fakeMetadataArchive); | ||
| const putObjectVersionPromise = promisify(putObjectVersion); | ||
| const getMetadataPromise = promisify(getMetadata); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| try { | ||
| await s3.send(new CreateBucketCommand({ | ||
| Bucket: ingestionBucketName, | ||
| CreateBucketConfiguration: { | ||
| LocationConstraint: 'us-east-2:ingest', | ||
| }, | ||
| })); | ||
|
|
||
| const putRes = await s3.send(new PutObjectCommand(params)); | ||
| putVersionId = putRes.VersionId; | ||
|
|
||
| await fakeMetadataArchivePromise(ingestionBucketName, objectName, putVersionId, archive); | ||
|
|
||
| await putObjectVersionPromise(s3, params, putVersionId); | ||
|
|
||
| const restoredObjMD = await getMetadataPromise( | ||
| ingestionBucketName, objectName, putVersionId); | ||
|
|
||
| assert.strictEqual(restoredObjMD['x-amz-meta-scal-version-id'], putVersionId); | ||
| } finally { | ||
| await bucketUtil.emptyMany([ingestionBucketName]).catch(() => {}); | ||
| await bucketUtil.deleteMany([ingestionBucketName]).catch(() => {}); | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.