Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions tests/functional/backbeat/bucketIndexing.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ const { runIfMongo } = require('./utils');

const ipAddress = process.env.IP ? process.env.IP : '127.0.0.1';

const bucketUtil = new BucketUtility('default', { signatureVersion: 'v4' });
const s3 = bucketUtil.s3;
const backbeatAuthCredentials = {
accessKey: 'accessKey1',
secretKey: 'verySecretKey1',
accessKey: s3.config.credentials.accessKeyId,
secretKey: s3.config.credentials.secretAccessKey,
};

const TEST_BUCKET = 'backbeatbucket';
Expand Down Expand Up @@ -101,18 +103,12 @@ const indexRespObject = [
];

runIfMongo('Indexing Routes', () => {
let bucketUtil;
let s3;

before(done => {
bucketUtil = new BucketUtility(
'default', { signatureVersion: 'v4' });
s3 = bucketUtil.s3;
s3.createBucket({ Bucket: TEST_BUCKET }).promise()
.then(() => done())
.catch(err => {
process.stdout.write(`Error creating bucket: ${err}\n`);
throw err;
done(err);
});
});

Expand Down
25 changes: 12 additions & 13 deletions tests/functional/backbeat/excludedDataStoreName.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ const async = require('async');
const BucketUtility = require('../aws-node-sdk/lib/utility/bucket-util');
const { removeAllVersions } = require('../aws-node-sdk/lib/utility/versioning-util');
const { makeBackbeatRequest, updateMetadata } = require('./utils');
const { config } = require('../../../lib/Config');

const testBucket = 'bucket-for-list-lifecycle-current-tests';
const location1 = 'us-east-1';
const location2 = 'us-east-2';

const bucketUtil = new BucketUtility('default', { signatureVersion: 'v4' });
const s3 = bucketUtil.s3;
const credentials = {
accessKey: 'accessKey1',
secretKey: 'verySecretKey1',
accessKey: s3.config.credentials.accessKeyId,
secretKey: s3.config.credentials.secretAccessKey,
};

// for S3C it is dc-1, in Integration it's node1.scality.com, otherwise us-east-1
const s3Hostname = s3.endpoint.hostname;
const location1 = config.restEndpoints[s3Hostname] || config.restEndpoints.localhost;
const location2 = 'us-east-2';

describe('excludedDataStoreName', () => {
let bucketUtil;
let s3;
const expectedVersions = [];

before(done => {
bucketUtil = new BucketUtility('account1', { signatureVersion: 'v4' });
s3 = bucketUtil.s3;

return async.series([
before(done => async.series([
next => s3.createBucket({ Bucket: testBucket }, next),
next => s3.putBucketVersioning({
Bucket: testBucket,
Expand Down Expand Up @@ -58,8 +58,7 @@ describe('excludedDataStoreName', () => {
next);
}),
next => s3.putObject({ Bucket: testBucket, Key: 'key2' }, next),
], done);
});
], done));

after(done => async.series([
next => removeAllVersions({ Bucket: testBucket }, next),
Expand Down
28 changes: 8 additions & 20 deletions tests/functional/backbeat/listDeleteMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,20 @@ const BucketUtility = require('../aws-node-sdk/lib/utility/bucket-util');
const { removeAllVersions } = require('../aws-node-sdk/lib/utility/versioning-util');
const { makeBackbeatRequest } = require('./utils');

const bucketUtil = new BucketUtility('default', { signatureVersion: 'v4' });
const s3 = bucketUtil.s3;
const credentials = {
accessKey: 'accessKey1',
secretKey: 'verySecretKey1',
accessKey: s3.config.credentials.accessKeyId,
secretKey: s3.config.credentials.secretAccessKey,
};

describe('listLifecycle with non-current delete marker', () => {
let bucketUtil;
let s3;
let expectedVersionId;
let expectedDMVersionId;
const testBucket = 'bucket-for-list-lifecycle-noncurrent-dm-tests';
const keyName = 'key0';

before(done => {
bucketUtil = new BucketUtility('account1', { signatureVersion: 'v4' });
s3 = bucketUtil.s3;

return async.series([
before(done => async.series([
next => s3.createBucket({ Bucket: testBucket }, next),
next => s3.putBucketVersioning({
Bucket: testBucket,
Expand All @@ -41,8 +37,7 @@ describe('listLifecycle with non-current delete marker', () => {
expectedVersionId = data.VersionId;
return next();
}),
], done);
});
], done));

after(done => async.series([
next => removeAllVersions({ Bucket: testBucket }, next),
Expand Down Expand Up @@ -114,17 +109,11 @@ describe('listLifecycle with non-current delete marker', () => {
});

describe('listLifecycle with current delete marker version', () => {
let bucketUtil;
let s3;
let expectedVersionId;
const testBucket = 'bucket-for-list-lifecycle-current-dm-tests';
const keyName = 'key0';

before(done => {
bucketUtil = new BucketUtility('account1', { signatureVersion: 'v4' });
s3 = bucketUtil.s3;

return async.series([
before(done => async.series([
next => s3.createBucket({ Bucket: testBucket }, next),
next => s3.putBucketVersioning({
Bucket: testBucket,
Expand All @@ -138,8 +127,7 @@ describe('listLifecycle with current delete marker version', () => {
return next();
}),
next => s3.deleteObject({ Bucket: testBucket, Key: keyName }, next),
], done);
});
], done));

after(done => async.series([
next => removeAllVersions({ Bucket: testBucket }, next),
Expand Down
45 changes: 15 additions & 30 deletions tests/functional/backbeat/listLifecycleCurrents.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ const { removeAllVersions } = require('../aws-node-sdk/lib/utility/versioning-ut
const { makeBackbeatRequest } = require('./utils');
const { config } = require('../../../lib/Config');

const bucketUtil = new BucketUtility('default', { signatureVersion: 'v4' });
const s3 = bucketUtil.s3;
const credentials = {
accessKey: 'accessKey1',
secretKey: 'verySecretKey1',
accessKey: s3.config.credentials.accessKeyId,
secretKey: s3.config.credentials.secretAccessKey,
};

// for S3C it is dc-1, in Integration it's node1.scality.com, otherwise us-east-1
const s3Hostname = s3.endpoint.hostname;
const location = config.restEndpoints[s3Hostname] || config.restEndpoints.localhost;

function checkContents(contents, expectedKeyVersions) {
contents.forEach(d => {
assert(d.Key);
Expand All @@ -30,7 +36,7 @@ function checkContents(contents, expectedKeyVersions) {
Value: 'myvalue',
}]);
assert.strictEqual(d.IsLatest, true);
assert.strictEqual(d.DataStoreName, 'us-east-1');
assert.strictEqual(d.DataStoreName, location);
assert.strictEqual(d.ListType, 'current');
assert.strictEqual(d.Size, 3);
});
Expand All @@ -41,16 +47,10 @@ function checkContents(contents, expectedKeyVersions) {
const testBucket = `bucket-for-list-lifecycle-current-tests-${versioning.toLowerCase()}`;
const emptyBucket = `empty-bucket-for-list-lifecycle-current-tests-${versioning.toLowerCase()}`;

let bucketUtil;
let s3;
let date;
const expectedKeyVersions = {};

before(done => {
bucketUtil = new BucketUtility('account1', { signatureVersion: 'v4' });
s3 = bucketUtil.s3;

return async.series([
before(done => async.series([
next => s3.createBucket({ Bucket: testBucket }, next),
next => s3.createBucket({ Bucket: emptyBucket }, next),
next => {
Expand Down Expand Up @@ -96,8 +96,7 @@ function checkContents(contents, expectedKeyVersions) {
});
}, next);
},
], done);
});
], done));

after(done => async.series([
next => removeAllVersions({ Bucket: testBucket }, next),
Expand Down Expand Up @@ -409,15 +408,9 @@ function checkContents(contents, expectedKeyVersions) {

describe('listLifecycleCurrents with bucket versioning enabled and maxKeys', () => {
const testBucket = 'bucket-for-list-lifecycle-current-tests-truncated';
let bucketUtil;
let s3;
const expectedKeyVersions = {};

before(done => {
bucketUtil = new BucketUtility('account1', { signatureVersion: 'v4' });
s3 = bucketUtil.s3;

return async.series([
before(done => async.series([
next => s3.createBucket({ Bucket: testBucket }, next),
next => s3.putBucketVersioning({
Bucket: testBucket,
Expand Down Expand Up @@ -456,8 +449,7 @@ describe('listLifecycleCurrents with bucket versioning enabled and maxKeys', ()
return cb();
});
}, next),
], done);
});
], done));

after(done => async.series([
next => removeAllVersions({ Bucket: testBucket }, next),
Expand Down Expand Up @@ -556,15 +548,9 @@ describe('listLifecycleCurrents with bucket versioning enabled and delete object
const keyName0 = 'key0';
const keyName1 = 'key1';
const keyName2 = 'key2';
let bucketUtil;
let s3;
const expectedKeyVersions = {};

before(done => {
bucketUtil = new BucketUtility('account1', { signatureVersion: 'v4' });
s3 = bucketUtil.s3;

return async.series([
before(done => async.series([
next => s3.createBucket({ Bucket: testBucket }, next),
next => s3.putBucketVersioning({
Bucket: testBucket,
Expand Down Expand Up @@ -597,8 +583,7 @@ describe('listLifecycleCurrents with bucket versioning enabled and delete object
}
return s3.deleteObject({ Bucket: testBucket, Key: keyName2, VersionId: data.VersionId }, next);
}),
], done);
});
], done));

after(done => async.series([
next => removeAllVersions({ Bucket: testBucket }, next),
Expand Down
23 changes: 11 additions & 12 deletions tests/functional/backbeat/listLifecycleNonCurrents.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ const testBucket = 'bucket-for-list-lifecycle-noncurrent-tests';
const emptyBucket = 'empty-bucket-for-list-lifecycle-noncurrent-tests';
const nonVersionedBucket = 'non-versioned-bucket-for-list-lifecycle-noncurrent-tests';

const bucketUtil = new BucketUtility('default', { signatureVersion: 'v4' });
const s3 = bucketUtil.s3;
const credentials = {
accessKey: 'accessKey1',
secretKey: 'verySecretKey1',
accessKey: s3.config.credentials.accessKeyId,
secretKey: s3.config.credentials.secretAccessKey,
};

// for S3C it is dc-1, in Integration it's node1.scality.com, otherwise us-east-1
const s3Hostname = s3.endpoint.hostname;
const location = config.restEndpoints[s3Hostname] || config.restEndpoints.localhost;

function checkContents(contents) {
contents.forEach(d => {
assert(d.Key);
Expand All @@ -30,24 +36,18 @@ function checkContents(contents) {
Key: 'mykey',
Value: 'myvalue',
}]);
assert.strictEqual(d.DataStoreName, 'us-east-1');
assert.strictEqual(d.DataStoreName, location);
assert.strictEqual(d.ListType, 'noncurrent');
assert.strictEqual(d.Size, 3);
});
}

describe('listLifecycleNonCurrents', () => {
let bucketUtil;
let s3;
let date;
let expectedKey1VersionIds = [];
let expectedKey2VersionIds = [];

before(done => {
bucketUtil = new BucketUtility('account1', { signatureVersion: 'v4' });
s3 = bucketUtil.s3;

return async.series([
before(done => async.series([
next => s3.createBucket({ Bucket: testBucket }, next),
next => s3.createBucket({ Bucket: emptyBucket }, next),
next => s3.createBucket({ Bucket: nonVersionedBucket }, next),
Expand Down Expand Up @@ -88,8 +88,7 @@ describe('listLifecycleNonCurrents', () => {
next => async.times(5, (n, cb) => {
s3.putObject({ Bucket: testBucket, Key: 'key2', Body: '123', Tagging: 'mykey=myvalue' }, cb);
}, next),
], done);
});
], done));

after(done => async.series([
next => removeAllVersions({ Bucket: testBucket }, next),
Expand Down
17 changes: 6 additions & 11 deletions tests/functional/backbeat/listLifecycleOrphanDeleteMarkers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ const testBucket = 'bucket-for-list-lifecycle-orphans-tests';
const emptyBucket = 'empty-bucket-for-list-lifecycle-orphans-tests';
const nonVersionedBucket = 'non-versioned-bucket-for-list-lifecycle-orphans-tests';

const bucketUtil = new BucketUtility('default', { signatureVersion: 'v4' });
const s3 = bucketUtil.s3;
const credentials = {
accessKey: 'accessKey1',
secretKey: 'verySecretKey1',
accessKey: s3.config.credentials.accessKeyId,
secretKey: s3.config.credentials.secretAccessKey,
};

function checkContents(contents) {
Expand Down Expand Up @@ -55,15 +57,9 @@ function createOrphanDeleteMarker(s3, bucketName, keyName, cb) {
}

describe('listLifecycleOrphanDeleteMarkers', () => {
let bucketUtil;
let s3;
let date;

before(done => {
bucketUtil = new BucketUtility('account1', { signatureVersion: 'v4' });
s3 = bucketUtil.s3;

return async.series([
before(done => async.series([
next => s3.createBucket({ Bucket: testBucket }, next),
next => s3.createBucket({ Bucket: emptyBucket }, next),
next => s3.createBucket({ Bucket: nonVersionedBucket }, next),
Expand All @@ -85,8 +81,7 @@ describe('listLifecycleOrphanDeleteMarkers', () => {
createOrphanDeleteMarker(s3, testBucket, `key${n}`, cb);
}, next);
},
], done);
});
], done));

after(done => async.series([
next => removeAllVersions({ Bucket: testBucket }, next),
Expand Down
Loading
Loading