Compare commits

...

2 Commits

Author SHA1 Message Date
Rahul Padigela 71055d87ed refactor: move network tests to functional 2020-08-18 15:42:06 -07:00
Rahul Padigela 83687de542 improvement: ZENKO-1781 add tests for processMpuParts 2020-08-18 15:42:06 -07:00
11 changed files with 145 additions and 1 deletions

View File

@ -0,0 +1,39 @@
{
"$": {
"xmlns": "http://s3.amazonaws.com/doc/2006-03-01/"
},
"Part": [
{
"ETag": [
"\"d41d8cd98f00b204e9800998ecf8427e\""
],
"PartNumber": [
"1"
]
},
{
"ETag": [
"\"d41d8cd98f00b204e9800998ecf8427e\""
],
"PartNumber": [
"2"
]
},
{
"ETag": [
"\"d41d8cd98f00b204e9800998ecf8427e\""
],
"PartNumber": [
"3"
]
},
{
"ETag": [
"\"d41d8cd98f00b204e9800998ecf8427e\""
],
"PartNumber": [
"4"
]
}
]
}

View File

@ -0,0 +1,62 @@
[
{
"key": "7dffb33c7a734b0f89ed09f74b0b8d74..|..00001",
"value": {
"Size": 6000000,
"ETag": "d41d8cd98f00b204e9800998ecf8427e",
"LastModified": "2019-04-30T20:53:23.620Z",
"Owner": {},
"partLocations": [
{
"key": "1a1ff57af576995bdf229471fcc34ecd939175f0",
"dataStoreName": "file"
}
]
}
},
{
"key": "7dffb33c7a734b0f89ed09f74b0b8d74..|..00002",
"value": {
"Size": 6000000,
"ETag": "d41d8cd98f00b204e9800998ecf8427e",
"LastModified": "2019-04-30T20:53:26.719Z",
"Owner": {},
"partLocations": [
{
"key": "8bfef6c626c922948ded4be63dd7c4a0f1c8ba2a",
"dataStoreName": "file"
}
]
}
},
{
"key": "7dffb33c7a734b0f89ed09f74b0b8d74..|..00003",
"value": {
"Size": 6000000,
"ETag": "d41d8cd98f00b204e9800998ecf8427e",
"LastModified": "2019-04-30T20:53:29.303Z",
"Owner": {},
"partLocations": [
{
"key": "a431c768950aa5cccbd2d8a0b914bf6160ab3cd0",
"dataStoreName": "file"
}
]
}
},
{
"key": "7dffb33c7a734b0f89ed09f74b0b8d74..|..00004",
"value": {
"Size": 6000000,
"ETag": "d41d8cd98f00b204e9800998ecf8427e",
"LastModified": "2019-04-30T20:53:31.182Z",
"Owner": {},
"partLocations": [
{
"key": "43b8c90e4af62333f246843b15ca263a179d86cb",
"dataStoreName": "file"
}
]
}
}
]

View File

@ -1,7 +1,9 @@
const assert = require('assert'); const assert = require('assert');
const crypto = require('crypto'); const crypto = require('crypto');
const { Logger } = require('werelogs');
const log = new Logger('S3').newRequestLogger();
const { createAggregateETag } = const { createAggregateETag, validateAndFilterMpuParts } =
require('../../../lib/s3middleware/processMpuParts'); require('../../../lib/s3middleware/processMpuParts');
describe('createAggregateETag', () => { describe('createAggregateETag', () => {
@ -54,3 +56,44 @@ describe('createAggregateETag', () => {
aggregateETag, 'bff290751e485f06dcc0203c77ed2fd9-10000'); aggregateETag, 'bff290751e485f06dcc0203c77ed2fd9-10000');
}); });
}); });
let storedParts;
let jsonList;
// r - number of parts to remove
function _buildExpectedResult(r) {
const result = [];
for (let i = 0; i < r; i++) {
jsonList.Part.shift();
result.push(...storedParts[i].value.partLocations);
}
return result;
}
describe('processMpuParts::validateAndFilterMpuParts', () => {
let mpuOverviewKey;
let splitter;
beforeEach(() => {
mpuOverviewKey =
'"overview..|..fred..|..8e51eecb51ca4caa96dc4ebd51514f2a"';
splitter = '..|..';
storedParts = require('./helpers/storedParts');
jsonList = require('./helpers/jsonList');
});
afterEach(() => {
mpuOverviewKey = null;
splitter = null;
});
[0, 2, 4].forEach(n => {
it(`should filter ${n} parts that are not used in complete mpu`,
() => {
const expected = _buildExpectedResult(n);
const result = validateAndFilterMpuParts(storedParts, jsonList,
mpuOverviewKey, splitter, log);
assert.deepStrictEqual(expected, result.extraPartLocations);
});
});
});