Compare commits

...

9 Commits

Author SHA1 Message Date
naren-scality bf04ff141b Merge branch 'w/8.1/3284-test' of github.com:scality/cloudserver into w/8.1/3284-test 2021-03-16 11:41:01 -07:00
naren-scality 3f392677b1 more corrections to package.json and lock file 2021-03-16 11:39:18 -07:00
naren-scality 4243d76d0d corrected package.json and lock file 2021-03-16 11:17:51 -07:00
naren-scality 8a62c44ff0 enable all functional tests 2021-03-16 07:22:07 -07:00
naren-scality 9727f22b78 test 2021-03-16 07:12:18 -07:00
naren-scality aac07c78f4 enable only md search tests 2021-03-15 23:06:10 -07:00
naren-scality 6a1b471888 copy config text 2021-03-10 11:58:34 -08:00
naren-scality 5b9d1e1866 copy config 2021-03-10 11:33:54 -08:00
naren-scality 8f43116b33 disable all tests but mongo 2021-03-10 10:16:06 -08:00
5 changed files with 587 additions and 991 deletions

View File

@ -167,12 +167,7 @@ stages:
stage_names: stage_names:
- docker-build - docker-build
- linting-coverage - linting-coverage
- file-ft-tests
- multiple-backend-test
- mongo-ft-tests - mongo-ft-tests
- ceph-backend-tests
- kmip-ft-tests
- utapi-v2-tests
waitForFinish: true waitForFinish: true
haltOnFailure: true haltOnFailure: true

View File

@ -32,7 +32,7 @@ function findConfigFile(fileName) {
}); });
if (!containingPath) { if (!containingPath) {
throw new Error(`Unable to find the configuration file "${fileName}" ` + throw new Error(`Unable to find the configuration file "${fileName}" ` +
`under the paths: ${JSON.stringify(configSearchPaths)}`); `under the paths: ${JSON.stringify(configSearchPaths)}`);
} }
return path.join(containingPath, fileName); return path.join(containingPath, fileName);
} }
@ -180,7 +180,7 @@ function hdClientLocationConstraintAssert(configHd) {
.every(e => typeof e === 'string'), .every(e => typeof e === 'string'),
'bad config: hdclient.bootstrap must be an array of strings'); 'bad config: hdclient.bootstrap must be an array of strings');
assert(configHd.bootstrap.length > 0, assert(configHd.bootstrap.length > 0,
'bad config: hdclient bootstrap list is empty'); 'bad config: hdclient bootstrap list is empty');
hdclientFields.push('bootstrap'); hdclientFields.push('bootstrap');
} }
return hdclientFields; return hdclientFields;
@ -188,8 +188,8 @@ function hdClientLocationConstraintAssert(configHd) {
function locationConstraintAssert(locationConstraints) { function locationConstraintAssert(locationConstraints) {
const supportedBackends = const supportedBackends =
['mem', 'file', 'scality', ['mem', 'file', 'scality',
'mongodb'].concat(Object.keys(validExternalBackends)); 'mongodb'].concat(Object.keys(validExternalBackends));
assert(typeof locationConstraints === 'object', assert(typeof locationConstraints === 'object',
'bad config: locationConstraints must be an object'); 'bad config: locationConstraints must be an object');
Object.keys(locationConstraints).forEach(l => { Object.keys(locationConstraints).forEach(l => {
@ -202,23 +202,23 @@ function locationConstraintAssert(locationConstraints) {
'bad config: locationConstraints[region].type must ' + 'bad config: locationConstraints[region].type must ' +
`be one of ${supportedBackends}`); `be one of ${supportedBackends}`);
assert(typeof locationConstraints[l].objectId === 'string', assert(typeof locationConstraints[l].objectId === 'string',
'bad config: locationConstraints[region].objectId is ' + 'bad config: locationConstraints[region].objectId is ' +
'mandatory and must be a unique string across locations'); 'mandatory and must be a unique string across locations');
assert(Object.keys(locationConstraints) assert(Object.keys(locationConstraints)
.filter(loc => (locationConstraints[loc].objectId === .filter(loc => (locationConstraints[loc].objectId ===
locationConstraints[l].objectId)) locationConstraints[l].objectId))
.length === 1, .length === 1,
'bad config: location constraint objectId ' + 'bad config: location constraint objectId ' +
`"${locationConstraints[l].objectId}" is not unique across ` + `"${locationConstraints[l].objectId}" is not unique across ` +
'configured locations'); 'configured locations');
assert(typeof locationConstraints[l].legacyAwsBehavior assert(typeof locationConstraints[l].legacyAwsBehavior
=== 'boolean', === 'boolean',
'bad config: locationConstraints[region]' + 'bad config: locationConstraints[region]' +
'.legacyAwsBehavior is mandatory and must be a boolean'); '.legacyAwsBehavior is mandatory and must be a boolean');
assert(['undefined', 'boolean'].includes( assert(['undefined', 'boolean'].includes(
typeof locationConstraints[l].isTransient), typeof locationConstraints[l].isTransient),
'bad config: locationConstraints[region]' + 'bad config: locationConstraints[region]' +
'.isTransient must be a boolean'); '.isTransient must be a boolean');
if (locationConstraints[l].sizeLimitGB !== undefined) { if (locationConstraints[l].sizeLimitGB !== undefined) {
assert(typeof locationConstraints[l].sizeLimitGB === 'number' || assert(typeof locationConstraints[l].sizeLimitGB === 'number' ||
locationConstraints[l].sizeLimitGB === null, locationConstraints[l].sizeLimitGB === null,
@ -232,8 +232,8 @@ function locationConstraintAssert(locationConstraints) {
'mandatory and must be an object'); 'mandatory and must be an object');
if (details.serverSideEncryption !== undefined) { if (details.serverSideEncryption !== undefined) {
assert(typeof details.serverSideEncryption === 'boolean', assert(typeof details.serverSideEncryption === 'boolean',
'bad config: locationConstraints[region]' + 'bad config: locationConstraints[region]' +
'.details.serverSideEncryption must be a boolean'); '.details.serverSideEncryption must be a boolean');
} }
const stringFields = [ const stringFields = [
'awsEndpoint', 'awsEndpoint',
@ -299,7 +299,7 @@ function locationConstraintAssert(locationConstraints) {
} }
if (locationConstraints[l].type === 'pfs') { if (locationConstraints[l].type === 'pfs') {
assert(typeof details.pfsDaemonEndpoint === 'object', assert(typeof details.pfsDaemonEndpoint === 'object',
'bad config: pfsDaemonEndpoint is mandatory and must be an object'); 'bad config: pfsDaemonEndpoint is mandatory and must be an object');
} }
if (locationConstraints[l].type === 'scality' && if (locationConstraints[l].type === 'scality' &&
locationConstraints[l].details.connector !== undefined && locationConstraints[l].details.connector !== undefined &&
@ -310,7 +310,7 @@ function locationConstraintAssert(locationConstraints) {
}); });
assert(Object.keys(locationConstraints) assert(Object.keys(locationConstraints)
.includes('us-east-1'), 'bad locationConfig: must ' + .includes('us-east-1'), 'bad locationConfig: must ' +
'include us-east-1 as a locationConstraint'); 'include us-east-1 as a locationConstraint');
} }
function parseUtapiReindex({ enabled, schedule, sentinel, bucketd }) { function parseUtapiReindex({ enabled, schedule, sentinel, bucketd }) {
@ -340,23 +340,23 @@ function parseUtapiReindex({ enabled, schedule, sentinel, bucketd }) {
function requestsConfigAssert(requestsConfig) { function requestsConfigAssert(requestsConfig) {
if (requestsConfig.viaProxy !== undefined) { if (requestsConfig.viaProxy !== undefined) {
assert(typeof requestsConfig.viaProxy === 'boolean', assert(typeof requestsConfig.viaProxy === 'boolean',
'config: invalid requests configuration. viaProxy must be a ' + 'config: invalid requests configuration. viaProxy must be a ' +
'boolean'); 'boolean');
if (requestsConfig.viaProxy) { if (requestsConfig.viaProxy) {
assert(Array.isArray(requestsConfig.trustedProxyCIDRs) && assert(Array.isArray(requestsConfig.trustedProxyCIDRs) &&
requestsConfig.trustedProxyCIDRs.length > 0 && requestsConfig.trustedProxyCIDRs.length > 0 &&
requestsConfig.trustedProxyCIDRs requestsConfig.trustedProxyCIDRs
.every(ip => typeof ip === 'string'), .every(ip => typeof ip === 'string'),
'config: invalid requests configuration. ' + 'config: invalid requests configuration. ' +
'trustedProxyCIDRs must be set if viaProxy is set to true ' + 'trustedProxyCIDRs must be set if viaProxy is set to true ' +
'and must be an array'); 'and must be an array');
assert(typeof requestsConfig.extractClientIPFromHeader === 'string' assert(typeof requestsConfig.extractClientIPFromHeader === 'string'
&& requestsConfig.extractClientIPFromHeader.length > 0, && requestsConfig.extractClientIPFromHeader.length > 0,
'config: invalid requests configuration. ' + 'config: invalid requests configuration. ' +
'extractClientIPFromHeader must be set if viaProxy is ' + 'extractClientIPFromHeader must be set if viaProxy is ' +
'set to true and must be a string'); 'set to true and must be a string');
} }
} }
} }
@ -405,7 +405,7 @@ class Config extends EventEmitter {
*/ */
this._basePath = path.join(__dirname, '..'); this._basePath = path.join(__dirname, '..');
this.configPath = findConfigFile(process.env.S3_CONFIG_FILE || this.configPath = findConfigFile(process.env.S3_CONFIG_FILE ||
'config.json'); 'config.json');
let locationConfigFileName = 'locationConfig.json'; let locationConfigFileName = 'locationConfig.json';
if (process.env.CI === 'true' && !process.env.S3_END_TO_END) { if (process.env.CI === 'true' && !process.env.S3_END_TO_END) {
@ -413,7 +413,7 @@ class Config extends EventEmitter {
'tests/locationConfig/locationConfigTests.json'; 'tests/locationConfig/locationConfigTests.json';
} }
this.locationConfigPath = findConfigFile(process.env.S3_LOCATION_FILE || this.locationConfigPath = findConfigFile(process.env.S3_LOCATION_FILE ||
locationConfigFileName); locationConfigFileName);
if (process.env.S3_REPLICATION_FILE !== undefined) { if (process.env.S3_REPLICATION_FILE !== undefined) {
this.replicationConfigPath = process.env.S3_REPLICATION_FILE; this.replicationConfigPath = process.env.S3_REPLICATION_FILE;
@ -429,7 +429,10 @@ class Config extends EventEmitter {
let locationConfig; let locationConfig;
try { try {
const data = fs.readFileSync(this.locationConfigPath, const data = fs.readFileSync(this.locationConfigPath,
{ encoding: 'utf-8' }); { encoding: 'utf-8' });
console.log('[LOCATION]');
console.log(data);
console.log('[LOCATION]');
locationConfig = JSON.parse(data); locationConfig = JSON.parse(data);
} catch (err) { } catch (err) {
throw new Error(`could not parse location config file: throw new Error(`could not parse location config file:
@ -443,7 +446,7 @@ class Config extends EventEmitter {
const details = this.locationConstraints[l].details; const details = this.locationConstraints[l].details;
if (locationConfig[l].details.connector !== undefined) { if (locationConfig[l].details.connector !== undefined) {
assert(typeof locationConfig[l].details.connector === assert(typeof locationConfig[l].details.connector ===
'object', 'bad config: connector must be an object'); 'object', 'bad config: connector must be an object');
if (locationConfig[l].details.connector.sproxyd !== if (locationConfig[l].details.connector.sproxyd !==
undefined) { undefined) {
details.connector.sproxyd = parseSproxydConfig( details.connector.sproxyd = parseSproxydConfig(
@ -462,14 +465,14 @@ class Config extends EventEmitter {
'bad config: TLS file specification must be a string'); 'bad config: TLS file specification must be a string');
} }
const tlsFilePath = (tlsFileName[0] === '/') const tlsFilePath = (tlsFileName[0] === '/')
? tlsFileName ? tlsFileName
: path.join(this._basepath, tlsFileName); : path.join(this._basepath, tlsFileName);
let tlsFileContent; let tlsFileContent;
try { try {
tlsFileContent = fs.readFileSync(tlsFilePath); tlsFileContent = fs.readFileSync(tlsFilePath);
} catch (err) { } catch (err) {
throw new Error(`Could not load tls file '${tlsFileName}':` + throw new Error(`Could not load tls file '${tlsFileName}':` +
` ${err.message}`); ` ${err.message}`);
} }
return tlsFileContent; return tlsFileContent;
} }
@ -478,7 +481,10 @@ class Config extends EventEmitter {
let config; let config;
try { try {
const data = fs.readFileSync(this.configPath, const data = fs.readFileSync(this.configPath,
{ encoding: 'utf-8' }); { encoding: 'utf-8' });
console.log('[CONFIG]');
console.log(data);
console.log('[CONFIG]');
config = JSON.parse(data); config = JSON.parse(data);
} catch (err) { } catch (err) {
throw new Error(`could not parse config file: ${err.message}`); throw new Error(`could not parse config file: ${err.message}`);
@ -486,7 +492,7 @@ class Config extends EventEmitter {
if (this.replicationConfigPath) { if (this.replicationConfigPath) {
try { try {
const repData = fs.readFileSync(this.replicationConfigPath, const repData = fs.readFileSync(this.replicationConfigPath,
{ encoding: 'utf-8' }); { encoding: 'utf-8' });
const replicationEndpoints = JSON.parse(repData); const replicationEndpoints = JSON.parse(repData);
config.replicationEndpoints.push(...replicationEndpoints); config.replicationEndpoints.push(...replicationEndpoints);
} catch (err) { } catch (err) {
@ -613,7 +619,7 @@ class Config extends EventEmitter {
this.clusters = false; this.clusters = false;
if (config.clusters !== undefined) { if (config.clusters !== undefined) {
assert(Number.isInteger(config.clusters) && config.clusters > 0, assert(Number.isInteger(config.clusters) && config.clusters > 0,
'bad config: clusters must be a positive integer'); 'bad config: clusters must be a positive integer');
this.clusters = config.clusters; this.clusters = config.clusters;
} }
@ -631,27 +637,27 @@ class Config extends EventEmitter {
if (config.cdmi !== undefined) { if (config.cdmi !== undefined) {
if (config.cdmi.host !== undefined) { if (config.cdmi.host !== undefined) {
assert.strictEqual(typeof config.cdmi.host, 'string', assert.strictEqual(typeof config.cdmi.host, 'string',
'bad config: cdmi host must be a string'); 'bad config: cdmi host must be a string');
this.cdmi.host = config.cdmi.host; this.cdmi.host = config.cdmi.host;
} }
if (config.cdmi.port !== undefined) { if (config.cdmi.port !== undefined) {
assert(Number.isInteger(config.cdmi.port) assert(Number.isInteger(config.cdmi.port)
&& config.cdmi.port > 0, && config.cdmi.port > 0,
'bad config: cdmi port must be a positive integer'); 'bad config: cdmi port must be a positive integer');
this.cdmi.port = config.cdmi.port; this.cdmi.port = config.cdmi.port;
} }
if (config.cdmi.path !== undefined) { if (config.cdmi.path !== undefined) {
assert(typeof config.cdmi.path === 'string', assert(typeof config.cdmi.path === 'string',
'bad config: cdmi.path must be a string'); 'bad config: cdmi.path must be a string');
assert(config.cdmi.path.length > 0, assert(config.cdmi.path.length > 0,
'bad config: cdmi.path is empty'); 'bad config: cdmi.path is empty');
assert(config.cdmi.path.charAt(0) === '/', assert(config.cdmi.path.charAt(0) === '/',
'bad config: cdmi.path should start with a "/"'); 'bad config: cdmi.path should start with a "/"');
this.cdmi.path = config.cdmi.path; this.cdmi.path = config.cdmi.path;
} }
if (config.cdmi.readonly !== undefined) { if (config.cdmi.readonly !== undefined) {
assert(typeof config.cdmi.readonly === 'boolean', assert(typeof config.cdmi.readonly === 'boolean',
'bad config: cdmi.readonly must be a boolean'); 'bad config: cdmi.readonly must be a boolean');
this.cdmi.readonly = config.cdmi.readonly; this.cdmi.readonly = config.cdmi.readonly;
} else { } else {
this.cdmi.readonly = true; this.cdmi.readonly = true;
@ -660,11 +666,11 @@ class Config extends EventEmitter {
this.bucketd = { bootstrap: [] }; this.bucketd = { bootstrap: [] };
if (config.bucketd !== undefined if (config.bucketd !== undefined
&& config.bucketd.bootstrap !== undefined) { && config.bucketd.bootstrap !== undefined) {
assert(config.bucketd.bootstrap instanceof Array assert(config.bucketd.bootstrap instanceof Array
&& config.bucketd.bootstrap.every( && config.bucketd.bootstrap.every(
e => typeof e === 'string'), e => typeof e === 'string'),
'bad config: bucketd.bootstrap must be a list of strings'); 'bad config: bucketd.bootstrap must be a list of strings');
this.bucketd.bootstrap = config.bucketd.bootstrap; this.bucketd.bootstrap = config.bucketd.bootstrap;
} }
@ -672,13 +678,13 @@ class Config extends EventEmitter {
if (config.vaultd) { if (config.vaultd) {
if (config.vaultd.port !== undefined) { if (config.vaultd.port !== undefined) {
assert(Number.isInteger(config.vaultd.port) assert(Number.isInteger(config.vaultd.port)
&& config.vaultd.port > 0, && config.vaultd.port > 0,
'bad config: vaultd port must be a positive integer'); 'bad config: vaultd port must be a positive integer');
this.vaultd.port = config.vaultd.port; this.vaultd.port = config.vaultd.port;
} }
if (config.vaultd.host !== undefined) { if (config.vaultd.host !== undefined) {
assert.strictEqual(typeof config.vaultd.host, 'string', assert.strictEqual(typeof config.vaultd.host, 'string',
'bad config: vaultd host must be a string'); 'bad config: vaultd host must be a string');
this.vaultd.host = config.vaultd.host; this.vaultd.host = config.vaultd.host;
} }
if (process.env.VAULTD_HOST !== undefined) { if (process.env.VAULTD_HOST !== undefined) {
@ -691,14 +697,14 @@ class Config extends EventEmitter {
if (config.dataClient) { if (config.dataClient) {
this.dataClient = {}; this.dataClient = {};
assert.strictEqual(typeof config.dataClient.host, 'string', assert.strictEqual(typeof config.dataClient.host, 'string',
'bad config: data client host must be ' + 'bad config: data client host must be ' +
'a string'); 'a string');
this.dataClient.host = config.dataClient.host; this.dataClient.host = config.dataClient.host;
assert(Number.isInteger(config.dataClient.port) assert(Number.isInteger(config.dataClient.port)
&& config.dataClient.port > 0, && config.dataClient.port > 0,
'bad config: dataClient port must be a positive ' + 'bad config: dataClient port must be a positive ' +
'integer'); 'integer');
this.dataClient.port = config.dataClient.port; this.dataClient.port = config.dataClient.port;
} }
@ -710,9 +716,9 @@ class Config extends EventEmitter {
this.metadataClient.host = config.metadataClient.host; this.metadataClient.host = config.metadataClient.host;
assert(Number.isInteger(config.metadataClient.port) assert(Number.isInteger(config.metadataClient.port)
&& config.metadataClient.port > 0, && config.metadataClient.port > 0,
'bad config: metadata client port must be a ' + 'bad config: metadata client port must be a ' +
'positive integer'); 'positive integer');
this.metadataClient.port = config.metadataClient.port; this.metadataClient.port = config.metadataClient.port;
} }
@ -738,9 +744,9 @@ class Config extends EventEmitter {
this.dataDaemon.bindAddress = config.dataDaemon.bindAddress; this.dataDaemon.bindAddress = config.dataDaemon.bindAddress;
assert(Number.isInteger(config.dataDaemon.port) assert(Number.isInteger(config.dataDaemon.port)
&& config.dataDaemon.port > 0, && config.dataDaemon.port > 0,
'bad config: data daemon port must be a positive ' + 'bad config: data daemon port must be a positive ' +
'integer'); 'integer');
this.dataDaemon.port = config.dataDaemon.port; this.dataDaemon.port = config.dataDaemon.port;
/** /**
@ -750,7 +756,7 @@ class Config extends EventEmitter {
*/ */
this.dataDaemon.dataPath = this.dataDaemon.dataPath =
process.env.S3DATAPATH ? process.env.S3DATAPATH ?
process.env.S3DATAPATH : `${__dirname}/../localData`; process.env.S3DATAPATH : `${__dirname}/../localData`;
this.dataDaemon.noSync = process.env.S3DATA_NOSYNC === 'true'; this.dataDaemon.noSync = process.env.S3DATA_NOSYNC === 'true';
this.dataDaemon.noCache = process.env.S3DATA_NOCACHE === 'true'; this.dataDaemon.noCache = process.env.S3DATA_NOCACHE === 'true';
} }
@ -762,13 +768,13 @@ class Config extends EventEmitter {
'bad config: data daemon bind address must be a string'); 'bad config: data daemon bind address must be a string');
this.pfsDaemon.bindAddress = config.pfsDaemon.bindAddress; this.pfsDaemon.bindAddress = config.pfsDaemon.bindAddress;
assert(Number.isInteger(config.pfsDaemon.port) assert(Number.isInteger(config.pfsDaemon.port)
&& config.pfsDaemon.port > 0, && config.pfsDaemon.port > 0,
'bad config: data daemon port must be a positive ' + 'bad config: data daemon port must be a positive ' +
'integer'); 'integer');
this.pfsDaemon.port = config.pfsDaemon.port; this.pfsDaemon.port = config.pfsDaemon.port;
this.pfsDaemon.dataPath = this.pfsDaemon.dataPath =
process.env.PFSD_MOUNT_PATH ? process.env.PFSD_MOUNT_PATH ?
process.env.PFSD_MOUNT_PATH : `${__dirname}/../localPfs`; process.env.PFSD_MOUNT_PATH : `${__dirname}/../localPfs`;
this.pfsDaemon.noSync = process.env.PFSD_NOSYNC === 'true'; this.pfsDaemon.noSync = process.env.PFSD_NOSYNC === 'true';
this.pfsDaemon.noCache = process.env.PFSD_NOCACHE === 'true'; this.pfsDaemon.noCache = process.env.PFSD_NOCACHE === 'true';
this.pfsDaemon.isReadOnly = this.pfsDaemon.isReadOnly =
@ -784,9 +790,9 @@ class Config extends EventEmitter {
config.metadataDaemon.bindAddress; config.metadataDaemon.bindAddress;
assert(Number.isInteger(config.metadataDaemon.port) assert(Number.isInteger(config.metadataDaemon.port)
&& config.metadataDaemon.port > 0, && config.metadataDaemon.port > 0,
'bad config: metadata daemon port must be a ' + 'bad config: metadata daemon port must be a ' +
'positive integer'); 'positive integer');
this.metadataDaemon.port = config.metadataDaemon.port; this.metadataDaemon.port = config.metadataDaemon.port;
/** /**
@ -796,7 +802,7 @@ class Config extends EventEmitter {
*/ */
this.metadataDaemon.metadataPath = this.metadataDaemon.metadataPath =
process.env.S3METADATAPATH ? process.env.S3METADATAPATH ?
process.env.S3METADATAPATH : `${__dirname}/../localMetadata`; process.env.S3METADATAPATH : `${__dirname}/../localMetadata`;
this.metadataDaemon.restEnabled = this.metadataDaemon.restEnabled =
config.metadataDaemon.restEnabled; config.metadataDaemon.restEnabled;
@ -831,8 +837,10 @@ class Config extends EventEmitter {
if (typeof config.localCache.sentinels === 'string') { if (typeof config.localCache.sentinels === 'string') {
config.localCache.sentinels.split(',').forEach(item => { config.localCache.sentinels.split(',').forEach(item => {
const [host, port] = item.split(':'); const [host, port] = item.split(':');
this.localCache.sentinels.push({ host, this.localCache.sentinels.push({
port: Number.parseInt(port, 10) }); host,
port: Number.parseInt(port, 10)
});
}); });
} else if (Array.isArray(config.localCache.sentinels)) { } else if (Array.isArray(config.localCache.sentinels)) {
config.localCache.sentinels.forEach(item => { config.localCache.sentinels.forEach(item => {
@ -848,14 +856,14 @@ class Config extends EventEmitter {
} }
} else { } else {
assert(typeof config.localCache.host === 'string', assert(typeof config.localCache.host === 'string',
'config: bad host for localCache. host must be a string'); 'config: bad host for localCache. host must be a string');
assert(typeof config.localCache.port === 'number', assert(typeof config.localCache.port === 'number',
'config: bad port for localCache. port must be a number'); 'config: bad port for localCache. port must be a number');
if (config.localCache.password !== undefined) { if (config.localCache.password !== undefined) {
assert( assert(
this._verifyRedisPassword(config.localCache.password), this._verifyRedisPassword(config.localCache.password),
'config: vad password for localCache. password must' + 'config: vad password for localCache. password must' +
' be a string'); ' be a string');
} }
this.localCache = { this.localCache = {
host: config.localCache.host, host: config.localCache.host,
@ -870,8 +878,8 @@ class Config extends EventEmitter {
if (process.env.MONGODB_AUTH_USERNAME && if (process.env.MONGODB_AUTH_USERNAME &&
process.env.MONGODB_AUTH_PASSWORD) { process.env.MONGODB_AUTH_PASSWORD) {
this.mongodb.authCredentials = { this.mongodb.authCredentials = {
username: process.env.MONGODB_AUTH_USERNAME, username: process.env.MONGODB_AUTH_USERNAME,
password: process.env.MONGODB_AUTH_PASSWORD, password: process.env.MONGODB_AUTH_PASSWORD,
}; };
} }
} else { } else {
@ -892,8 +900,10 @@ class Config extends EventEmitter {
if (typeof config.redis.sentinels === 'string') { if (typeof config.redis.sentinels === 'string') {
config.redis.sentinels.split(',').forEach(item => { config.redis.sentinels.split(',').forEach(item => {
const [host, port] = item.split(':'); const [host, port] = item.split(':');
this.redis.sentinels.push({ host, this.redis.sentinels.push({
port: Number.parseInt(port, 10) }); host,
port: Number.parseInt(port, 10)
});
}); });
} else if (Array.isArray(config.redis.sentinels)) { } else if (Array.isArray(config.redis.sentinels)) {
config.redis.sentinels.forEach(item => { config.redis.sentinels.forEach(item => {
@ -908,7 +918,7 @@ class Config extends EventEmitter {
if (config.redis.sentinelPassword !== undefined) { if (config.redis.sentinelPassword !== undefined) {
assert( assert(
this._verifyRedisPassword(config.redis.sentinelPassword)); this._verifyRedisPassword(config.redis.sentinelPassword));
this.redis.sentinelPassword = config.redis.sentinelPassword; this.redis.sentinelPassword = config.redis.sentinelPassword;
} }
} else { } else {
@ -991,10 +1001,10 @@ class Config extends EventEmitter {
' must be a string'); ' must be a string');
this.utapi.redis.password = config.utapi.redis.password; this.utapi.redis.password = config.utapi.redis.password;
} }
if (config.utapi.redis.sentinelPassword !== undefined) { if (config.utapi.redis.sentinelPassword !== undefined) {
assert( assert(
this._verifyRedisPassword( this._verifyRedisPassword(
config.utapi.redis.sentinelPassword), config.utapi.redis.sentinelPassword),
'config: invalid password for utapi redis. password' + 'config: invalid password for utapi redis. password' +
' must be a string'); ' must be a string');
this.utapi.redis.sentinelPassword = this.utapi.redis.sentinelPassword =
@ -1075,7 +1085,7 @@ class Config extends EventEmitter {
} }
} }
if (Object.keys(this.locationConstraints).some( if (Object.keys(this.locationConstraints).some(
loc => this.locationConstraints[loc].sizeLimitGB)) { loc => this.locationConstraints[loc].sizeLimitGB)) {
assert(this.utapi && this.utapi.metrics && assert(this.utapi && this.utapi.metrics &&
this.utapi.metrics.includes('location'), this.utapi.metrics.includes('location'),
'bad config: if storage size limit set on a location ' + 'bad config: if storage size limit set on a location ' +
@ -1086,12 +1096,12 @@ class Config extends EventEmitter {
if (config.log !== undefined) { if (config.log !== undefined) {
if (config.log.logLevel !== undefined) { if (config.log.logLevel !== undefined) {
assert(typeof config.log.logLevel === 'string', assert(typeof config.log.logLevel === 'string',
'bad config: log.logLevel must be a string'); 'bad config: log.logLevel must be a string');
this.log.logLevel = config.log.logLevel; this.log.logLevel = config.log.logLevel;
} }
if (config.log.dumpLevel !== undefined) { if (config.log.dumpLevel !== undefined) {
assert(typeof config.log.dumpLevel === 'string', assert(typeof config.log.dumpLevel === 'string',
'bad config: log.dumpLevel must be a string'); 'bad config: log.dumpLevel must be a string');
this.log.dumpLevel = config.log.dumpLevel; this.log.dumpLevel = config.log.dumpLevel;
} }
} }
@ -1126,13 +1136,13 @@ class Config extends EventEmitter {
* which also targets the present instant. * which also targets the present instant.
*/ */
compoundCreateActivate: compoundCreateActivate:
(process.env.S3KMIP_COMPOUND_CREATE === 'true') || false, (process.env.S3KMIP_COMPOUND_CREATE === 'true') || false,
/* Set the bucket name attribute name here if the KMIP /* Set the bucket name attribute name here if the KMIP
* server supports storing custom attributes along * server supports storing custom attributes along
* with the keys. * with the keys.
*/ */
bucketNameAttributeName: bucketNameAttributeName:
process.env.S3KMIP_BUCKET_ATTRIBUTE_NAME || '', process.env.S3KMIP_BUCKET_ATTRIBUTE_NAME || '',
}, },
transport: { transport: {
/* Specify the request pipeline depth here. /* Specify the request pipeline depth here.
@ -1158,10 +1168,10 @@ class Config extends EventEmitter {
host: process.env.S3KMIP_HOSTS, host: process.env.S3KMIP_HOSTS,
key: this._loadTlsFile(process.env.S3KMIP_KEY || undefined), key: this._loadTlsFile(process.env.S3KMIP_KEY || undefined),
cert: this._loadTlsFile(process.env.S3KMIP_CERT || cert: this._loadTlsFile(process.env.S3KMIP_CERT ||
undefined), undefined),
ca: (process.env.S3KMIP_CA ca: (process.env.S3KMIP_CA
? process.env.S3KMIP_CA.split(',') ? process.env.S3KMIP_CA.split(',')
: []).map(this._loadTlsFile), : []).map(this._loadTlsFile),
}, },
}, },
}; };
@ -1169,13 +1179,13 @@ class Config extends EventEmitter {
if (config.kmip.client) { if (config.kmip.client) {
if (config.kmip.client.compoundCreateActivate) { if (config.kmip.client.compoundCreateActivate) {
assert(typeof config.kmip.client.compoundCreateActivate === assert(typeof config.kmip.client.compoundCreateActivate ===
'boolean'); 'boolean');
this.kmip.client.compoundCreateActivate = this.kmip.client.compoundCreateActivate =
config.kmip.client.compoundCreateActivate; config.kmip.client.compoundCreateActivate;
} }
if (config.kmip.client.bucketNameAttributeName) { if (config.kmip.client.bucketNameAttributeName) {
assert(typeof config.kmip.client.bucketNameAttributeName === assert(typeof config.kmip.client.bucketNameAttributeName ===
'string'); 'string');
this.kmip.client.bucketNameAttributeName = this.kmip.client.bucketNameAttributeName =
config.kmip.client.bucketNameAttributeName; config.kmip.client.bucketNameAttributeName;
} }
@ -1183,25 +1193,25 @@ class Config extends EventEmitter {
if (config.kmip.transport) { if (config.kmip.transport) {
if (config.kmip.transport.pipelineDepth) { if (config.kmip.transport.pipelineDepth) {
assert(typeof config.kmip.transport.pipelineDepth === assert(typeof config.kmip.transport.pipelineDepth ===
'number'); 'number');
this.kmip.transport.pipelineDepth = this.kmip.transport.pipelineDepth =
config.kmip.transport.pipelineDepth; config.kmip.transport.pipelineDepth;
} }
if (config.kmip.transport.tls) { if (config.kmip.transport.tls) {
const { host, port, key, cert, ca } = const { host, port, key, cert, ca } =
config.kmip.transport.tls; config.kmip.transport.tls;
if (!!key !== !!cert) { if (!!key !== !!cert) {
throw new Error('bad config: KMIP TLS certificate ' + throw new Error('bad config: KMIP TLS certificate ' +
'and key must come along'); 'and key must come along');
} }
if (port) { if (port) {
assert(typeof port === 'number', assert(typeof port === 'number',
'bad config: KMIP TLS Port must be a number'); 'bad config: KMIP TLS Port must be a number');
this.kmip.transport.tls.port = port; this.kmip.transport.tls.port = port;
} }
if (host) { if (host) {
assert(typeof host === 'string', assert(typeof host === 'string',
'bad config: KMIP TLS Host must be a string'); 'bad config: KMIP TLS Host must be a string');
this.kmip.transport.tls.host = host; this.kmip.transport.tls.host = host;
} }
@ -1227,8 +1237,8 @@ class Config extends EventEmitter {
'be an array'); 'be an array');
config.healthChecks.allowFrom.forEach(item => { config.healthChecks.allowFrom.forEach(item => {
assert(typeof item === 'string', assert(typeof item === 'string',
'config: invalid healthcheck configuration. allowFrom IP ' + 'config: invalid healthcheck configuration. allowFrom IP ' +
'address must be a string'); 'address must be a string');
}); });
this.healthChecks.allowFrom = defaultHealthChecks.allowFrom this.healthChecks.allowFrom = defaultHealthChecks.allowFrom
.concat(config.healthChecks.allowFrom); .concat(config.healthChecks.allowFrom);
@ -1241,7 +1251,7 @@ class Config extends EventEmitter {
config.certFilePaths.ca && config.certFilePaths.ca &&
typeof config.certFilePaths.ca === 'string') || typeof config.certFilePaths.ca === 'string') ||
!config.certFilePaths.ca) !config.certFilePaths.ca)
); );
} }
const { key, cert, ca } = config.certFilePaths ? const { key, cert, ca } = config.certFilePaths ?
@ -1286,7 +1296,7 @@ class Config extends EventEmitter {
const authArray = auth.split(':'); const authArray = auth.split(':');
assert(authArray.length === 2 && authArray[0].length > 0 assert(authArray.length === 2 && authArray[0].length > 0
&& authArray[1].length > 0, 'bad proxy config: ' + && authArray[1].length > 0, 'bad proxy config: ' +
'auth must be of format username:password'); 'auth must be of format username:password');
} }
this.outboundProxy.url = proxyUrl; this.outboundProxy.url = proxyUrl;
this.outboundProxy.certs = {}; this.outboundProxy.certs = {};
@ -1321,15 +1331,15 @@ class Config extends EventEmitter {
if (config.managementAgent !== undefined) { if (config.managementAgent !== undefined) {
if (config.managementAgent.port !== undefined) { if (config.managementAgent.port !== undefined) {
assert(Number.isInteger(config.managementAgent.port) assert(Number.isInteger(config.managementAgent.port)
&& config.managementAgent.port > 0, && config.managementAgent.port > 0,
'bad config: managementAgent port must be a positive ' + 'bad config: managementAgent port must be a positive ' +
'integer'); 'integer');
this.managementAgent.port = config.managementAgent.port; this.managementAgent.port = config.managementAgent.port;
} }
if (config.managementAgent.host !== undefined) { if (config.managementAgent.host !== undefined) {
assert.strictEqual(typeof config.managementAgent.host, 'string', assert.strictEqual(typeof config.managementAgent.host, 'string',
'bad config: management agent host must ' + 'bad config: management agent host must ' +
'be a string'); 'be a string');
this.managementAgent.host = config.managementAgent.host; this.managementAgent.host = config.managementAgent.host;
} }
} }
@ -1417,13 +1427,13 @@ class Config extends EventEmitter {
// Auth only checks for 'mem' since mem === file // Auth only checks for 'mem' since mem === file
auth = 'mem'; auth = 'mem';
const authfile = findConfigFile(process.env.S3AUTH_CONFIG || const authfile = findConfigFile(process.env.S3AUTH_CONFIG ||
'authdata.json'); 'authdata.json');
let authData; let authData;
if (process.env.SCALITY_ACCESS_KEY_ID && if (process.env.SCALITY_ACCESS_KEY_ID &&
process.env.SCALITY_SECRET_ACCESS_KEY) { process.env.SCALITY_SECRET_ACCESS_KEY) {
authData = buildAuthDataAccount( authData = buildAuthDataAccount(
process.env.SCALITY_ACCESS_KEY_ID, process.env.SCALITY_ACCESS_KEY_ID,
process.env.SCALITY_SECRET_ACCESS_KEY); process.env.SCALITY_SECRET_ACCESS_KEY);
} else { } else {
authData = require(authfile); authData = require(authfile);
} }
@ -1506,15 +1516,15 @@ class Config extends EventEmitter {
setReplicationEndpoints(locationConstraints) { setReplicationEndpoints(locationConstraints) {
this.replicationEndpoints = this.replicationEndpoints =
Object.keys(locationConstraints) Object.keys(locationConstraints)
.map(key => ({ site: key, type: locationConstraints[key].type })); .map(key => ({ site: key, type: locationConstraints[key].type }));
} }
getAzureEndpoint(locationConstraint) { getAzureEndpoint(locationConstraint) {
let azureStorageEndpoint = let azureStorageEndpoint =
process.env[`${locationConstraint}_AZURE_STORAGE_ENDPOINT`] || process.env[`${locationConstraint}_AZURE_STORAGE_ENDPOINT`] ||
this.locationConstraints[locationConstraint] this.locationConstraints[locationConstraint]
.details.azureStorageEndpoint; .details.azureStorageEndpoint;
if (!azureStorageEndpoint.endsWith('/')) { if (!azureStorageEndpoint.endsWith('/')) {
// append the trailing slash // append the trailing slash
azureStorageEndpoint = `${azureStorageEndpoint}/`; azureStorageEndpoint = `${azureStorageEndpoint}/`;
@ -1544,7 +1554,7 @@ class Config extends EventEmitter {
getPfsDaemonEndpoint(locationConstraint) { getPfsDaemonEndpoint(locationConstraint) {
return process.env[`${locationConstraint}_PFSD_ENDPOINT`] || return process.env[`${locationConstraint}_PFSD_ENDPOINT`] ||
this.locationConstraints[locationConstraint].details.pfsDaemonEndpoint; this.locationConstraints[locationConstraint].details.pfsDaemonEndpoint;
} }
isSameAzureAccount(locationConstraintSrc, locationConstraintDest) { isSameAzureAccount(locationConstraintSrc, locationConstraintDest) {
@ -1560,7 +1570,7 @@ class Config extends EventEmitter {
isAWSServerSideEncrytion(locationConstraint) { isAWSServerSideEncrytion(locationConstraint) {
return this.locationConstraints[locationConstraint].details return this.locationConstraints[locationConstraint].details
.serverSideEncryption === true; .serverSideEncryption === true;
} }
getPublicInstanceId() { getPublicInstanceId() {
@ -1569,8 +1579,8 @@ class Config extends EventEmitter {
setPublicInstanceId(instanceId) { setPublicInstanceId(instanceId) {
this.publicInstanceId = crypto.createHash('sha256') this.publicInstanceId = crypto.createHash('sha256')
.update(instanceId) .update(instanceId)
.digest('hex'); .digest('hex');
} }
} }

View File

@ -30,11 +30,10 @@
"commander": "^2.9.0", "commander": "^2.9.0",
"cron-parser": "^2.11.0", "cron-parser": "^2.11.0",
"diskusage": "1.1.3", "diskusage": "1.1.3",
"express": "^4.17.1",
"google-auto-auth": "^0.9.1", "google-auto-auth": "^0.9.1",
"http-proxy": "^1.17.0", "http-proxy": "^1.17.0",
"level-mem": "^5.0.1",
"https-proxy-agent": "^2.2.0", "https-proxy-agent": "^2.2.0",
"level-mem": "^5.0.1",
"moment": "^2.26.0", "moment": "^2.26.0",
"mongodb": "^2.2.31", "mongodb": "^2.2.31",
"node-forge": "^0.7.1", "node-forge": "^0.7.1",
@ -42,7 +41,6 @@
"npm-run-all": "~4.1.5", "npm-run-all": "~4.1.5",
"prom-client": "^10.2.3", "prom-client": "^10.2.3",
"request": "^2.81.0", "request": "^2.81.0",
"sinon": "^9.0.2",
"sql-where-parser": "~2.2.1", "sql-where-parser": "~2.2.1",
"utapi": "scality/utapi#357f8fe", "utapi": "scality/utapi#357f8fe",
"utf-8-validate": "^4.0.2", "utf-8-validate": "^4.0.2",
@ -59,6 +57,7 @@
"eslint-config-airbnb-base": "^13.1.0", "eslint-config-airbnb-base": "^13.1.0",
"eslint-config-scality": "scality/Guidelines#28e73a2", "eslint-config-scality": "scality/Guidelines#28e73a2",
"eslint-plugin-import": "^2.14.0", "eslint-plugin-import": "^2.14.0",
"express": "^4.17.1",
"ioredis": "4.9.5", "ioredis": "4.9.5",
"istanbul": "1.0.0-alpha.2", "istanbul": "1.0.0-alpha.2",
"istanbul-api": "1.0.0-alpha.13", "istanbul-api": "1.0.0-alpha.13",
@ -67,6 +66,7 @@
"mocha-junit-reporter": "^1.23.1", "mocha-junit-reporter": "^1.23.1",
"mocha-multi-reporters": "^1.1.7", "mocha-multi-reporters": "^1.1.7",
"node-mocks-http": "1.5.2", "node-mocks-http": "1.5.2",
"sinon": "^9.2.4",
"tv4": "^1.2.7" "tv4": "^1.2.7"
}, },
"scripts": { "scripts": {
@ -85,7 +85,7 @@
"ft_s3cmd": "cd tests/functional/s3cmd && mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json -t 40000 *.js", "ft_s3cmd": "cd tests/functional/s3cmd && mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json -t 40000 *.js",
"ft_s3curl": "cd tests/functional/s3curl && mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json -t 40000 *.js", "ft_s3curl": "cd tests/functional/s3curl && mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json -t 40000 *.js",
"ft_util": "cd tests/functional/utilities && mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json -t 40000 *.js", "ft_util": "cd tests/functional/utilities && mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json -t 40000 *.js",
"ft_test": "npm-run-all -s ft_awssdk ft_s3cmd ft_s3curl ft_node ft_healthchecks ft_management ft_util", "ft_test": "npm-run-all -s ft_awssdk",
"ft_search": "cd tests/functional/aws-node-sdk && mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json -t 90000 test/mdSearch", "ft_search": "cd tests/functional/aws-node-sdk && mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json -t 90000 test/mdSearch",
"ft_kmip": "cd tests/functional/kmip && mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json -t 40000 *.js", "ft_kmip": "cd tests/functional/kmip && mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json -t 40000 *.js",
"install_ft_deps": "yarn install aws-sdk@2.28.0 bluebird@3.3.1 mocha@2.3.4 mocha-junit-reporter@1.23.1 tv4@1.2.7", "install_ft_deps": "yarn install aws-sdk@2.28.0 bluebird@3.3.1 mocha@2.3.4 mocha-junit-reporter@1.23.1 tv4@1.2.7",
@ -110,4 +110,4 @@
"unit_coverage": "CI=true mkdir -p coverage/unit/ && S3BACKEND=mem istanbul cover --dir coverage/unit _mocha -- --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json --recursive tests/unit", "unit_coverage": "CI=true mkdir -p coverage/unit/ && S3BACKEND=mem istanbul cover --dir coverage/unit _mocha -- --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json --recursive tests/unit",
"unit_coverage_legacy_location": "CI=true mkdir -p coverage/unitlegacylocation/ && S3_LOCATION_FILE=tests/locationConfig/locationConfigLegacy.json S3BACKEND=mem istanbul cover --dir coverage/unitlegacylocation _mocha -- --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json --reporter mocha-junit-reporter --recursive tests/unit" "unit_coverage_legacy_location": "CI=true mkdir -p coverage/unitlegacylocation/ && S3_LOCATION_FILE=tests/locationConfig/locationConfigLegacy.json S3BACKEND=mem istanbul cover --dir coverage/unitlegacylocation _mocha -- --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json --reporter mocha-junit-reporter --recursive tests/unit"
} }
} }

View File

@ -6,7 +6,9 @@ const userMetadata = { food: 'pizza' };
const updatedMetadata = { food: 'salad' }; const updatedMetadata = { food: 'salad' };
const masterKey = 'master'; const masterKey = 'master';
runIfMongo('Search in version enabled bucket', () => { console.log('process.env.CI_CEPH', process.env.CI_CEPH);
describe('Search in version enabled bucket', () => {
const bucketName = `versionedbucket${Date.now()}`; const bucketName = `versionedbucket${Date.now()}`;
const VersioningConfiguration = { const VersioningConfiguration = {
MFADelete: 'Disabled', MFADelete: 'Disabled',

1299
yarn.lock

File diff suppressed because it is too large Load Diff