MCPcopy
hub / github.com/scality/cloudserver / createMPU

Function createMPU

tests/unit/api/bucketDelete.js:34–84  ·  view source on GitHub ↗
(testRequest, initiateRequest, deleteOverviewMPUObj, cb)

Source from the content-addressed store, hash-verified

32const mpuBucket = `${constants.mpuBucketPrefix}${bucketName}`;
33
34function createMPU(testRequest, initiateRequest, deleteOverviewMPUObj, cb) {
35 async.waterfall([
36 next => bucketPut(authInfo, testRequest, log, next),
37 (corsHeaders, next) => initiateMultipartUpload(authInfo,
38 initiateRequest, log, next),
39 (result, corsHeaders, next) => {
40 parseString(result, next);
41 },
42 (json, next) => {
43 const testUploadId = json.InitiateMultipartUploadResult.UploadId[0];
44 const md5Hash = crypto.createHash('md5');
45 const bufferBody = Buffer.from(postBody);
46 md5Hash.update(bufferBody);
47 const calculatedHash = md5Hash.digest('hex');
48 const partRequest = new DummyRequest({
49 bucketName,
50 objectKey: objectName,
51 namespace,
52 url: `/${objectName}?partNumber=1&uploadId=${testUploadId}`,
53 headers: { host: `${bucketName}.s3.amazonaws.com` },
54 query: {
55 partNumber: '1',
56 uploadId: testUploadId,
57 },
58 calculatedHash,
59 }, postBody);
60 objectPutPart(authInfo, partRequest, undefined, log, err => {
61 if (err) {
62 return next(err);
63 }
64 return next(null, testUploadId);
65 });
66 },
67 ], (err, testUploadId) => {
68 assert.strictEqual(err, null);
69 const mpuBucketKeyMap =
70 metadataMem.metadata.keyMaps.get(mpuBucket);
71 assert.strictEqual(mpuBucketKeyMap.size, 2);
72 if (deleteOverviewMPUObj) {
73 const overviewKey = `overview${constants.splitter}` +
74 `${objectName}${constants.splitter}${testUploadId}`;
75 // remove overview key from in mem mpu bucket
76 mpuBucketKeyMap.delete(overviewKey);
77 assert.strictEqual(mpuBucketKeyMap.size, 1);
78 }
79 bucketDelete(authInfo, testRequest, log, err => {
80 assert.strictEqual(err, null);
81 cb();
82 });
83 });
84}
85
86describe('bucketDelete API', () => {
87 beforeEach(() => {

Callers 1

bucketDelete.jsFile · 0.70

Calls 4

bucketPutFunction · 0.85
objectPutPartFunction · 0.85
bucketDeleteFunction · 0.85
initiateMultipartUploadFunction · 0.50

Tested by

no test coverage detected