Compare commits

...

11 Commits

Author SHA1 Message Date
Guillaume Hivert a14037f518 Fix all lint rules 2022-02-17 16:16:47 +01:00
Guillaume Hivert 9d7f041508 Fix all hooks for jest tests (before to beforeAll, after to afterAll) 2022-02-17 16:11:58 +01:00
Jordi Bertran de Balanda 61da23c8d2 fixup! fix ft_test 2022-02-17 15:22:07 +01:00
Jordi Bertran de Balanda 65c94012c6 update ioredis, fix babel peer dependency 2022-02-17 15:22:05 +01:00
Jordi Bertran de Balanda cb87471cc8 kill 2022-02-17 15:20:21 +01:00
Jordi Bertran de Balanda 57e4ecc0ee fix ft_test 2022-02-17 15:20:21 +01:00
Jordi Bertran de Balanda 7a390e684d fix lint after eslint upgrade 2022-02-17 15:20:20 +01:00
Jordi Bertran de Balanda bbcd33a14d upgrade eslint for jest plugin 2022-02-17 15:17:03 +01:00
Jordi Bertran de Balanda 88311ffbd9 add babel-plugin-add-module-exports 2022-02-17 15:15:23 +01:00
Jordi Bertran de Balanda be1e0fc56f switch to jest as a test runner 2022-02-17 15:13:12 +01:00
Jordi Bertran de Balanda 9a1a56e7b9 add typescript compiler script 2022-02-17 15:11:45 +01:00
183 changed files with 6835 additions and 4798 deletions

View File

@ -1 +0,0 @@
{ "extends": "scality" }

7
.eslintrc.json Normal file
View File

@ -0,0 +1,7 @@
{
"extends": ["scality"],
"plugins": ["jest"],
"env": {
"jest/globals": true
}
}

8
babel.config.js Normal file
View File

@ -0,0 +1,8 @@
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
],
plugins: ['add-module-exports'],
};

View File

@ -1,7 +1,6 @@
const ArrayUtils = require('./ArrayUtils'); const ArrayUtils = require('./ArrayUtils');
class SortedSet { class SortedSet {
constructor(obj) { constructor(obj) {
if (obj) { if (obj) {
this.keys = obj.keys; this.keys = obj.keys;

View File

@ -91,7 +91,7 @@ class Vault {
requestContext: serializedRCsArr, requestContext: serializedRCsArr,
}, },
(err, userInfo) => vaultSignatureCb(err, userInfo, (err, userInfo) => vaultSignatureCb(err, userInfo,
params.log, callback) params.log, callback),
); );
} }
@ -146,7 +146,7 @@ class Vault {
requestContext: serializedRCs, requestContext: serializedRCs,
}, },
(err, userInfo) => vaultSignatureCb(err, userInfo, (err, userInfo) => vaultSignatureCb(err, userInfo,
params.log, callback, streamingV4Params) params.log, callback, streamingV4Params),
); );
} }

View File

@ -194,7 +194,7 @@ function generateV4Headers(request, data, accessKey, secretKeyValue,
.filter(headerName => .filter(headerName =>
headerName.startsWith('x-amz-') headerName.startsWith('x-amz-')
|| headerName.startsWith('x-scal-') || headerName.startsWith('x-scal-')
|| headerName === 'host' || headerName === 'host',
).sort().join(';'); ).sort().join(';');
const params = { request, signedHeaders, payloadChecksum, const params = { request, signedHeaders, payloadChecksum,
credentialScope, timestamp, query: data, credentialScope, timestamp, query: data,

View File

@ -29,7 +29,7 @@ class ChainBackend extends BaseBackend {
typeof client.getCanonicalIds === 'function' && typeof client.getCanonicalIds === 'function' &&
typeof client.getEmailAddresses === 'function' && typeof client.getEmailAddresses === 'function' &&
typeof client.checkPolicies === 'function' && typeof client.checkPolicies === 'function' &&
typeof client.healthcheck === 'function' typeof client.healthcheck === 'function',
), 'invalid client: missing required auth backend methods'); ), 'invalid client: missing required auth backend methods');
this._clients = clients; this._clients = clients;
} }
@ -55,7 +55,7 @@ class ChainBackend extends BaseBackend {
signatureFromRequest, signatureFromRequest,
accessKey, accessKey,
options, options,
done done,
), callback); ), callback);
} }
@ -67,7 +67,7 @@ class ChainBackend extends BaseBackend {
region, region,
scopeDate, scopeDate,
options, options,
done done,
), callback); ), callback);
} }
@ -153,7 +153,7 @@ class ChainBackend extends BaseBackend {
requestContextParams, requestContextParams,
userArn, userArn,
options, options,
done done,
), (err, res) => { ), (err, res) => {
if (err) { if (err) {
return callback(err); return callback(err);
@ -171,7 +171,7 @@ class ChainBackend extends BaseBackend {
client.healthcheck(reqUid, (err, res) => done(null, { client.healthcheck(reqUid, (err, res) => done(null, {
error: !!err ? err : null, error: !!err ? err : null,
status: res, status: res,
}) }),
), (err, res) => { ), (err, res) => {
if (err) { if (err) {
return callback(err); return callback(err);

View File

@ -273,7 +273,7 @@ class V4Transform extends Transform {
} }
// get next chunk // get next chunk
return callback(); return callback();
} },
); );
} }
} }

View File

@ -17,7 +17,7 @@ class RedisClient {
method: 'RedisClient.constructor', method: 'RedisClient.constructor',
redisHost: config.host, redisHost: config.host,
redisPort: config.port, redisPort: config.port,
}) }),
); );
return this; return this;
} }

View File

@ -9,7 +9,6 @@ const StatsClient = require('./StatsClient');
* rather than by seconds * rather than by seconds
*/ */
class StatsModel extends StatsClient { class StatsModel extends StatsClient {
/** /**
* Utility method to convert 2d array rows to columns, and vice versa * Utility method to convert 2d array rows to columns, and vice versa
* See also: https://docs.ruby-lang.org/en/2.0.0/Array.html#method-i-zip * See also: https://docs.ruby-lang.org/en/2.0.0/Array.html#method-i-zip

View File

@ -1128,7 +1128,7 @@ class LifecycleConfiguration {
`<NoncurrentDays>${noncurrentDays}` + `<NoncurrentDays>${noncurrentDays}` +
'</NoncurrentDays>', '</NoncurrentDays>',
`<StorageClass>${storageClass}</StorageClass>`, `<StorageClass>${storageClass}</StorageClass>`,
`</${actionName}>` `</${actionName}>`,
); );
}); });
Action = xml.join(''); Action = xml.join('');
@ -1148,7 +1148,7 @@ class LifecycleConfiguration {
`<${actionName}>`, `<${actionName}>`,
element, element,
`<StorageClass>${storageClass}</StorageClass>`, `<StorageClass>${storageClass}</StorageClass>`,
`</${actionName}>` `</${actionName}>`,
); );
}); });
Action = xml.join(''); Action = xml.join('');

View File

@ -10,7 +10,6 @@ const ObjectMDLocation = require('./ObjectMDLocation');
* mpuPart metadata for example) * mpuPart metadata for example)
*/ */
class ObjectMD { class ObjectMD {
/** /**
* Create a new instance of ObjectMD. Parameter <tt>objMd</tt> is * Create a new instance of ObjectMD. Parameter <tt>objMd</tt> is
* reserved for internal use, users should call * reserved for internal use, users should call

View File

@ -3,7 +3,6 @@
* 'location' array * 'location' array
*/ */
class ObjectMDLocation { class ObjectMDLocation {
/** /**
* @constructor * @constructor
* @param {object} locationObj - single data location info * @param {object} locationObj - single data location info

View File

@ -10,7 +10,6 @@ const { checkSupportIPv6 } = require('./utils');
class Server { class Server {
/** /**
* @constructor * @constructor
* *

View File

@ -342,8 +342,6 @@ class KMIP {
return cb(null, response); return cb(null, response);
}); });
} }
} }

View File

@ -26,7 +26,7 @@ function sendError(res, log, error, optMessage) {
httpCode: error.code, httpCode: error.code,
errorType: error.message, errorType: error.message,
error: message, error: message,
} },
); );
res.writeHead(error.code); res.writeHead(error.code);
res.end(JSON.stringify({ res.end(JSON.stringify({

View File

@ -45,7 +45,6 @@ function sendError(res, log, error, optMessage) {
* start() to start listening to the configured port. * start() to start listening to the configured port.
*/ */
class RESTServer extends httpServer { class RESTServer extends httpServer {
/** /**
* @constructor * @constructor
* @param {Object} params - constructor params * @param {Object} params - constructor params

View File

@ -17,7 +17,6 @@ const rpc = require('./rpc.js');
* RPC client object accessing the sub-level transparently. * RPC client object accessing the sub-level transparently.
*/ */
class LevelDbClient extends rpc.BaseClient { class LevelDbClient extends rpc.BaseClient {
/** /**
* @constructor * @constructor
* *
@ -78,7 +77,6 @@ class LevelDbClient extends rpc.BaseClient {
* env.subDb (env is passed as first parameter of received RPC calls). * env.subDb (env is passed as first parameter of received RPC calls).
*/ */
class LevelDbService extends rpc.BaseService { class LevelDbService extends rpc.BaseService {
/** /**
* @constructor * @constructor
* *

View File

@ -37,7 +37,6 @@ let streamRPCJSONObj;
* an error occurred). * an error occurred).
*/ */
class BaseClient extends EventEmitter { class BaseClient extends EventEmitter {
/** /**
* @constructor * @constructor
* *
@ -251,7 +250,6 @@ class BaseClient extends EventEmitter {
* *
*/ */
class BaseService { class BaseService {
/** /**
* @constructor * @constructor
* *

View File

@ -6,7 +6,6 @@ const crypto = require('crypto');
* data through a stream * data through a stream
*/ */
class MD5Sum extends Transform { class MD5Sum extends Transform {
/** /**
* @constructor * @constructor
*/ */
@ -40,7 +39,6 @@ class MD5Sum extends Transform {
this.emit('hashed'); this.emit('hashed');
callback(null); callback(null);
} }
} }
module.exports = MD5Sum; module.exports = MD5Sum;

View File

@ -121,7 +121,7 @@ log, cb) => {
return cb(errors.BadDigest); return cb(errors.BadDigest);
} }
return cb(errors.InternalError.customizeDescription( return cb(errors.InternalError.customizeDescription(
`Error returned from Azure: ${err.message}`) `Error returned from Azure: ${err.message}`),
); );
} }
const md5 = result.headers['content-md5'] || ''; const md5 = result.headers['content-md5'] || '';

View File

@ -33,7 +33,7 @@ convertMethods.listMultipartUploads = xmlParams => {
xml.push('<?xml version="1.0" encoding="UTF-8"?>', xml.push('<?xml version="1.0" encoding="UTF-8"?>',
'<ListMultipartUploadsResult ' + '<ListMultipartUploadsResult ' +
'xmlns="http://s3.amazonaws.com/doc/2006-03-01/">', 'xmlns="http://s3.amazonaws.com/doc/2006-03-01/">',
`<Bucket>${escapeForXml(xmlParams.bucketName)}</Bucket>` `<Bucket>${escapeForXml(xmlParams.bucketName)}</Bucket>`,
); );
// For certain XML elements, if it is `undefined`, AWS returns either an // For certain XML elements, if it is `undefined`, AWS returns either an
@ -58,7 +58,7 @@ convertMethods.listMultipartUploads = xmlParams => {
}); });
xml.push(`<MaxUploads>${escapeForXml(l.MaxKeys)}</MaxUploads>`, xml.push(`<MaxUploads>${escapeForXml(l.MaxKeys)}</MaxUploads>`,
`<IsTruncated>${escapeForXml(l.IsTruncated)}</IsTruncated>` `<IsTruncated>${escapeForXml(l.IsTruncated)}</IsTruncated>`,
); );
l.Uploads.forEach(upload => { l.Uploads.forEach(upload => {
@ -84,14 +84,14 @@ convertMethods.listMultipartUploads = xmlParams => {
`<StorageClass>${escapeForXml(val.StorageClass)}` + `<StorageClass>${escapeForXml(val.StorageClass)}` +
'</StorageClass>', '</StorageClass>',
`<Initiated>${escapeForXml(val.Initiated)}</Initiated>`, `<Initiated>${escapeForXml(val.Initiated)}</Initiated>`,
'</Upload>' '</Upload>',
); );
}); });
l.CommonPrefixes.forEach(prefix => { l.CommonPrefixes.forEach(prefix => {
xml.push('<CommonPrefixes>', xml.push('<CommonPrefixes>',
`<Prefix>${escapeForXml(prefix)}</Prefix>`, `<Prefix>${escapeForXml(prefix)}</Prefix>`,
'</CommonPrefixes>' '</CommonPrefixes>',
); );
}); });

View File

@ -5,7 +5,6 @@ const Readable = require('stream').Readable;
* This class is used to produce zeros filled buffers for a reader consumption * This class is used to produce zeros filled buffers for a reader consumption
*/ */
class NullStream extends Readable { class NullStream extends Readable {
/** /**
* Construct a new zeros filled buffers producer that will * Construct a new zeros filled buffers producer that will
* produce as much bytes as specified by the range parameter, or the size * produce as much bytes as specified by the range parameter, or the size

View File

@ -118,7 +118,7 @@ const XMLResponseBackend = {
`<Message>${errCode.description}</Message>`, `<Message>${errCode.description}</Message>`,
'<Resource></Resource>', '<Resource></Resource>',
`<RequestId>${log.getSerializedUids()}</RequestId>`, `<RequestId>${log.getSerializedUids()}</RequestId>`,
'</Error>' '</Error>',
); );
const xmlStr = xml.join(''); const xmlStr = xml.join('');
const bytesSent = Buffer.byteLength(xmlStr); const bytesSent = Buffer.byteLength(xmlStr);
@ -376,7 +376,7 @@ function retrieveData(locations, retrieveDataParams, response, log) {
// call end for all cases (error/success) per node.js docs // call end for all cases (error/success) per node.js docs
// recommendation // recommendation
response.end(); response.end();
} },
); );
} }
@ -591,7 +591,7 @@ const routesUtils = {
`<h1>${err.code} ${response.statusMessage}</h1>`, `<h1>${err.code} ${response.statusMessage}</h1>`,
'<ul>', '<ul>',
`<li>Code: ${err.message}</li>`, `<li>Code: ${err.message}</li>`,
`<li>Message: ${err.description}</li>` `<li>Message: ${err.description}</li>`,
); );
if (!userErrorPageFailure && bucketName) { if (!userErrorPageFailure && bucketName) {
@ -601,7 +601,7 @@ const routesUtils = {
`<li>RequestId: ${log.getSerializedUids()}</li>`, `<li>RequestId: ${log.getSerializedUids()}</li>`,
// AWS response contains HostId here. // AWS response contains HostId here.
// TODO: consider adding // TODO: consider adding
'</ul>' '</ul>',
); );
if (userErrorPageFailure) { if (userErrorPageFailure) {
html.push( html.push(
@ -611,13 +611,13 @@ const routesUtils = {
'<ul>', '<ul>',
`<li>Code: ${err.message}</li>`, `<li>Code: ${err.message}</li>`,
`<li>Message: ${err.description}</li>`, `<li>Message: ${err.description}</li>`,
'</ul>' '</ul>',
); );
} }
html.push( html.push(
'<hr/>', '<hr/>',
'</body>', '</body>',
'</html>' '</html>',
); );
return response.end(html.join(''), 'utf8', () => { return response.end(html.join(''), 'utf8', () => {
@ -847,7 +847,7 @@ const routesUtils = {
return bucketName; return bucketName;
} }
throw new Error( throw new Error(
`bad request: hostname ${host} is not in valid endpoints` `bad request: hostname ${host} is not in valid endpoints`,
); );
}, },

View File

@ -11,7 +11,7 @@ const { createLogger, logHelper, removeQuotes, trimXMetaPrefix } =
const missingVerIdInternalError = errors.InternalError.customizeDescription( const missingVerIdInternalError = errors.InternalError.customizeDescription(
'Invalid state. Please ensure versioning is enabled ' + 'Invalid state. Please ensure versioning is enabled ' +
'in AWS for the location constraint and try again.' 'in AWS for the location constraint and try again.',
); );
class AwsClient { class AwsClient {
@ -94,7 +94,7 @@ class AwsClient {
err, this._dataStoreName, this.clientType); err, this._dataStoreName, this.clientType);
return callback(errors.ServiceUnavailable return callback(errors.ServiceUnavailable
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`${this.type}: ${err.message}`) `${this.type}: ${err.message}`),
); );
} }
if (!data.VersionId && this._supportsVersioning) { if (!data.VersionId && this._supportsVersioning) {
@ -233,7 +233,7 @@ class AwsClient {
} }
return callback(errors.ServiceUnavailable return callback(errors.ServiceUnavailable
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`${this.type}: ${err.message}`) `${this.type}: ${err.message}`),
); );
} }
return callback(); return callback();
@ -307,7 +307,7 @@ class AwsClient {
err, this._dataStoreName, this.clientType); err, this._dataStoreName, this.clientType);
return callback(errors.ServiceUnavailable return callback(errors.ServiceUnavailable
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`${this.type}: ${err.message}`) `${this.type}: ${err.message}`),
); );
} }
return callback(null, mpuResObj); return callback(null, mpuResObj);
@ -335,7 +335,7 @@ class AwsClient {
'on uploadPart', err, this._dataStoreName, this.clientType); 'on uploadPart', err, this._dataStoreName, this.clientType);
return callback(errors.ServiceUnavailable return callback(errors.ServiceUnavailable
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`${this.type}: ${err.message}`) `${this.type}: ${err.message}`),
); );
} }
// Because we manually add quotes to ETag later, remove quotes here // Because we manually add quotes to ETag later, remove quotes here
@ -363,7 +363,7 @@ class AwsClient {
err, this._dataStoreName, this.clientType); err, this._dataStoreName, this.clientType);
return callback(errors.ServiceUnavailable return callback(errors.ServiceUnavailable
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`${this.type}: ${err.message}`) `${this.type}: ${err.message}`),
); );
} }
// build storedParts object to mimic Scality S3 backend returns // build storedParts object to mimic Scality S3 backend returns
@ -435,7 +435,7 @@ class AwsClient {
'completeMPU', err, this._dataStoreName, this.clientType); 'completeMPU', err, this._dataStoreName, this.clientType);
return callback(errors.ServiceUnavailable return callback(errors.ServiceUnavailable
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`${this.type}: ${err.message}`) `${this.type}: ${err.message}`),
); );
} }
if (!completeMpuRes.VersionId && this._supportsVersioning) { if (!completeMpuRes.VersionId && this._supportsVersioning) {
@ -453,7 +453,7 @@ class AwsClient {
'headObject', err, this._dataStoreName, this.clientType); 'headObject', err, this._dataStoreName, this.clientType);
return callback(errors.ServiceUnavailable return callback(errors.ServiceUnavailable
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`${this.type}: ${err.message}`) `${this.type}: ${err.message}`),
); );
} }
// remove quotes from eTag because they're added later // remove quotes from eTag because they're added later
@ -481,7 +481,7 @@ class AwsClient {
this.clientType); this.clientType);
return callback(errors.ServiceUnavailable return callback(errors.ServiceUnavailable
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`${this.type}: ${err.message}`) `${this.type}: ${err.message}`),
); );
} }
return callback(); return callback();
@ -510,7 +510,7 @@ class AwsClient {
this._dataStoreName, this.clientType); this._dataStoreName, this.clientType);
return callback(errors.ServiceUnavailable return callback(errors.ServiceUnavailable
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`${this.type}: ${err.message}`) `${this.type}: ${err.message}`),
); );
} }
return callback(); return callback();
@ -533,7 +533,7 @@ class AwsClient {
this._dataStoreName, this.clientType); this._dataStoreName, this.clientType);
return callback(errors.ServiceUnavailable return callback(errors.ServiceUnavailable
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`${this.type}: ${err.message}`) `${this.type}: ${err.message}`),
); );
} }
return callback(); return callback();
@ -570,14 +570,14 @@ class AwsClient {
this._dataStoreName, this.clientType); this._dataStoreName, this.clientType);
return callback(errors.AccessDenied return callback(errors.AccessDenied
.customizeDescription('Error: Unable to access ' + .customizeDescription('Error: Unable to access ' +
`${sourceAwsBucketName} ${this.type} bucket`) `${sourceAwsBucketName} ${this.type} bucket`),
); );
} }
logHelper(log, 'error', 'error from data backend on ' + logHelper(log, 'error', 'error from data backend on ' +
'copyObject', err, this._dataStoreName, this.clientType); 'copyObject', err, this._dataStoreName, this.clientType);
return callback(errors.ServiceUnavailable return callback(errors.ServiceUnavailable
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`${this.type}: ${err.message}`) `${this.type}: ${err.message}`),
); );
} }
if (!copyResult.VersionId && this._supportsVersioning) { if (!copyResult.VersionId && this._supportsVersioning) {
@ -629,14 +629,14 @@ class AwsClient {
this._dataStoreName, this.clientType); this._dataStoreName, this.clientType);
return callback(errors.AccessDenied return callback(errors.AccessDenied
.customizeDescription('Error: Unable to access ' + .customizeDescription('Error: Unable to access ' +
`${sourceAwsBucketName} AWS bucket`) `${sourceAwsBucketName} AWS bucket`),
); );
} }
logHelper(log, 'error', 'error from data backend on ' + logHelper(log, 'error', 'error from data backend on ' +
'uploadPartCopy', err, this._dataStoreName, this.clientType); 'uploadPartCopy', err, this._dataStoreName, this.clientType);
return callback(errors.ServiceUnavailable return callback(errors.ServiceUnavailable
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`${this.type}: ${err.message}`) `${this.type}: ${err.message}`),
); );
} }
const eTag = removeQuotes(res.CopyPartResult.ETag); const eTag = removeQuotes(res.CopyPartResult.ETag);

View File

@ -422,14 +422,14 @@ class AzureClient {
this._dataStoreName); this._dataStoreName);
return callback(errors.AccessDenied return callback(errors.AccessDenied
.customizeDescription('Error: Unable to access ' + .customizeDescription('Error: Unable to access ' +
`${sourceContainerName} Azure Container`) `${sourceContainerName} Azure Container`),
); );
} }
logHelper(log, 'error', 'error from data backend on ' + logHelper(log, 'error', 'error from data backend on ' +
'copyObject', err, this._dataStoreName); 'copyObject', err, this._dataStoreName);
return callback(errors.ServiceUnavailable return callback(errors.ServiceUnavailable
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`AWS: ${err.message}`) `AWS: ${err.message}`),
); );
} }
if (res.copy.status === 'pending') { if (res.copy.status === 'pending') {
@ -443,12 +443,12 @@ class AzureClient {
'on abortCopyBlob', err, this._dataStoreName); 'on abortCopyBlob', err, this._dataStoreName);
return callback(errors.ServiceUnavailable return callback(errors.ServiceUnavailable
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`AWS on abortCopyBlob: ${err.message}`) `AWS on abortCopyBlob: ${err.message}`),
); );
} }
return callback(errors.InvalidObjectState return callback(errors.InvalidObjectState
.customizeDescription('Error: Azure copy status was ' + .customizeDescription('Error: Azure copy status was ' +
'pending. It has been aborted successfully') 'pending. It has been aborted successfully'),
); );
}); });
} }

View File

@ -123,7 +123,7 @@ class GcpClient extends AwsClient {
err, this._dataStoreName, this.clientType); err, this._dataStoreName, this.clientType);
return callback(errors.ServiceUnavailable return callback(errors.ServiceUnavailable
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`GCP: ${err.message}`) `GCP: ${err.message}`),
); );
} }
return callback(null, mpuResObj); return callback(null, mpuResObj);
@ -168,7 +168,7 @@ class GcpClient extends AwsClient {
'completeMPU', err, this._dataStoreName, this.clientType); 'completeMPU', err, this._dataStoreName, this.clientType);
return callback(errors.ServiceUnavailable return callback(errors.ServiceUnavailable
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`GCP: ${err.message}`) `GCP: ${err.message}`),
); );
} }
if (!completeMpuRes.VersionId) { if (!completeMpuRes.VersionId) {
@ -210,7 +210,7 @@ class GcpClient extends AwsClient {
'on uploadPart', err, this._dataStoreName, this.clientType); 'on uploadPart', err, this._dataStoreName, this.clientType);
return callback(errors.ServiceUnavailable return callback(errors.ServiceUnavailable
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`GCP: ${err.message}`) `GCP: ${err.message}`),
); );
} }
// remove quotes from eTag because they're added later // remove quotes from eTag because they're added later
@ -242,7 +242,7 @@ class GcpClient extends AwsClient {
if (copySourceRange) { if (copySourceRange) {
return callback(errors.NotImplemented return callback(errors.NotImplemented
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`${this.clientType}: copySourceRange not implemented`) `${this.clientType}: copySourceRange not implemented`),
); );
} }
@ -261,14 +261,14 @@ class GcpClient extends AwsClient {
this._dataStoreName, this.clientType); this._dataStoreName, this.clientType);
return callback(errors.AccessDenied return callback(errors.AccessDenied
.customizeDescription('Error: Unable to access ' + .customizeDescription('Error: Unable to access ' +
`${sourceGcpBucketName} GCP bucket`) `${sourceGcpBucketName} GCP bucket`),
); );
} }
logHelper(log, 'error', 'error from data backend on ' + logHelper(log, 'error', 'error from data backend on ' +
'uploadPartCopy', err, this._dataStoreName); 'uploadPartCopy', err, this._dataStoreName);
return callback(errors.ServiceUnavailable return callback(errors.ServiceUnavailable
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`GCP: ${err.message}`) `GCP: ${err.message}`),
); );
} }
// remove quotes from eTag because they're added later // remove quotes from eTag because they're added later
@ -291,7 +291,7 @@ class GcpClient extends AwsClient {
'on abortMPU', err, this._dataStoreName, this.clientType); 'on abortMPU', err, this._dataStoreName, this.clientType);
return callback(errors.ServiceUnavailable return callback(errors.ServiceUnavailable
.customizeDescription('Error returned from ' + .customizeDescription('Error returned from ' +
`GCP: ${err.message}`) `GCP: ${err.message}`),
); );
} }
return callback(); return callback();

View File

@ -45,7 +45,7 @@ class PfsClient {
} }
return callback(null, keyContext.objectKey, '', return callback(null, keyContext.objectKey, '',
keyContext.metaHeaders['x-amz-meta-size'], keyContext.metaHeaders['x-amz-meta-size'],
md5 md5,
); );
} }
logHelper(log, 'error', 'Not implemented', errors.NotImplemented, logHelper(log, 'error', 'Not implemented', errors.NotImplemented,

View File

@ -35,7 +35,6 @@ const FOLDER_HASH = 3511;
* directory hash structure under the configured dataPath. * directory hash structure under the configured dataPath.
*/ */
class DataFileStore { class DataFileStore {
/** /**
* @constructor * @constructor
* @param {Object} dataConfig - configuration of the file backend * @param {Object} dataConfig - configuration of the file backend

View File

@ -30,7 +30,6 @@ class ListRecordStream extends stream.Transform {
* @classdesc Proxy object to access raft log API * @classdesc Proxy object to access raft log API
*/ */
class LogConsumer { class LogConsumer {
/** /**
* @constructor * @constructor
* *

View File

@ -14,13 +14,13 @@ const _operatorType1 = joi.string().valid(
'$gt', '$gt',
'$gte', '$gte',
'$lt', '$lt',
'$lte' '$lte',
); );
// supports strings, numbers, and boolean // supports strings, numbers, and boolean
const _operatorType2 = joi.string().valid( const _operatorType2 = joi.string().valid(
'$eq', '$eq',
'$ne' '$ne',
); );
const _valueType1 = joi.alternatives([ const _valueType1 = joi.alternatives([

View File

@ -17,7 +17,6 @@ const METASTORE = '__metastore';
const itemScanRefreshDelay = 1000 * 30 * 60; // 30 minutes const itemScanRefreshDelay = 1000 * 30 * 60; // 30 minutes
class BucketFileInterface { class BucketFileInterface {
/** /**
* @constructor * @constructor
* @param {object} [params] - constructor params * @param {object} [params] - constructor params

View File

@ -8,7 +8,6 @@ const { RecordLogProxy } = require('./RecordLog.js');
const werelogs = require('werelogs'); const werelogs = require('werelogs');
class MetadataFileClient { class MetadataFileClient {
/** /**
* Construct a metadata client * Construct a metadata client
* *

View File

@ -25,7 +25,6 @@ const SYNC_OPTIONS = { sync: true };
const SUBLEVEL_SEP = '::'; const SUBLEVEL_SEP = '::';
class MetadataFileServer { class MetadataFileServer {
/** /**
* Construct a metadata server * Construct a metadata server
* *

View File

@ -18,7 +18,6 @@ const DEFAULT_RECORD_LOG_NAME = 's3-recordlog';
* object. * object.
*/ */
class RecordLogProxy extends rpc.BaseClient { class RecordLogProxy extends rpc.BaseClient {
constructor(params) { constructor(params) {
super(params); super(params);
@ -102,7 +101,6 @@ class ListRecordStream extends stream.Transform {
* updates can be transactional with each other. * updates can be transactional with each other.
*/ */
class RecordLogService extends rpc.BaseService { class RecordLogService extends rpc.BaseService {
/** /**
* @constructor * @constructor
* *

View File

@ -9,7 +9,6 @@ const MongoUtils = require('./utils');
* @classdesc Class to consume mongo oplog * @classdesc Class to consume mongo oplog
*/ */
class LogConsumer { class LogConsumer {
/** /**
* @constructor * @constructor
* *

View File

@ -538,7 +538,7 @@ class MongoClientInterface {
updateOne: { updateOne: {
// eslint-disable-next-line // eslint-disable-next-line
filter: { filter: {
_id: objName, '_id': objName,
'value.versionId': params.versionId, 'value.versionId': params.versionId,
}, },
update: { update: {
@ -607,7 +607,7 @@ class MongoClientInterface {
MongoUtils.serialize(mstObjVal); MongoUtils.serialize(mstObjVal);
// eslint-disable-next-line // eslint-disable-next-line
c.update({ c.update({
_id: objName, '_id': objName,
'value.versionId': { 'value.versionId': {
// We break the semantic correctness here with // We break the semantic correctness here with
// $gte instead of $gt because we do not have // $gte instead of $gt because we do not have
@ -760,7 +760,7 @@ class MongoClientInterface {
MongoUtils.serialize(objVal); MongoUtils.serialize(objVal);
// eslint-disable-next-line // eslint-disable-next-line
c.findOneAndReplace({ c.findOneAndReplace({
_id: objName, '_id': objName,
'value.isPHD': true, 'value.isPHD': true,
'value.versionId': mst.versionId, 'value.versionId': mst.versionId,
}, { }, {
@ -822,7 +822,7 @@ class MongoClientInterface {
// version: // version:
// eslint-disable-next-line // eslint-disable-next-line
c.findOneAndDelete({ c.findOneAndDelete({
_id: objName, '_id': objName,
'value.isPHD': true, 'value.isPHD': true,
'value.versionId': mst.versionId, 'value.versionId': mst.versionId,
}, {}, err => { }, {}, err => {
@ -1616,7 +1616,7 @@ class MongoClientInterface {
const retResult = this._handleResults(collRes, isVer); const retResult = this._handleResults(collRes, isVer);
retResult.stalled = stalledCount; retResult.stalled = stalledCount;
return callback(null, retResult); return callback(null, retResult);
} },
); );
} }

View File

@ -11,7 +11,6 @@ const requiresOneWorker = {
}; };
class Server { class Server {
/** /**
* Create a new Metadata Proxy Server instance * Create a new Metadata Proxy Server instance
* *

View File

@ -160,7 +160,7 @@ class TestMatrix {
const result = Object.keys(matrixChild.params) const result = Object.keys(matrixChild.params)
.every(currentKey => .every(currentKey =>
Object.prototype.toString.call( Object.prototype.toString.call(
matrixChild.params[currentKey] matrixChild.params[currentKey],
).indexOf('Array') === -1); ).indexOf('Array') === -1);
if (result === true) { if (result === true) {

View File

@ -33,7 +33,7 @@
"fcntl": "github:scality/node-fcntl#0.2.0", "fcntl": "github:scality/node-fcntl#0.2.0",
"hdclient": "scality/hdclient#1.1.0", "hdclient": "scality/hdclient#1.1.0",
"https-proxy-agent": "^2.2.0", "https-proxy-agent": "^2.2.0",
"ioredis": "4.9.5", "ioredis": "~4.28.3",
"ipaddr.js": "1.9.1", "ipaddr.js": "1.9.1",
"level": "~5.0.1", "level": "~5.0.1",
"level-sublevel": "~6.6.5", "level-sublevel": "~6.6.5",
@ -53,26 +53,56 @@
"ioctl": "^2.0.2" "ioctl": "^2.0.2"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.0.0-0",
"@babel/preset-env": "^7.16.5",
"@babel/preset-typescript": "^7.16.5",
"@sinonjs/fake-timers": "^6.0.1", "@sinonjs/fake-timers": "^6.0.1",
"eslint": "2.13.1", "@types/jest": "^27.0.3",
"@types/node": "^16.11.7",
"babel-plugin-add-module-exports": "^1.0.4",
"eslint": "^7.32.0",
"eslint-config-airbnb": "6.2.0", "eslint-config-airbnb": "6.2.0",
"eslint-config-scality": "scality/Guidelines#ec33dfb", "eslint-config-scality": "scality/Guidelines#ec33dfb",
"eslint-plugin-jest": "^24.7.0",
"eslint-plugin-react": "^4.3.0", "eslint-plugin-react": "^4.3.0",
"jest": "^27.4.5",
"mocha": "8.0.1", "mocha": "8.0.1",
"mongodb-memory-server": "^6.0.2", "mongodb-memory-server": "^6.0.2",
"nyc": "^15.1.0", "nyc": "^15.1.0",
"sinon": "^9.0.2", "sinon": "^9.0.2",
"temp": "0.9.1" "temp": "0.9.1",
"typescript": "^4.4.4"
}, },
"scripts": { "scripts": {
"lint": "eslint $(git ls-files '*.js')", "lint": "eslint $(git ls-files '*.js')",
"lint_md": "mdlint $(git ls-files '*.md')", "lint_md": "mdlint $(git ls-files '*.md')",
"lint_yml": "yamllint $(git ls-files '*.yml')", "lint_yml": "yamllint $(git ls-files '*.yml')",
"test": "mocha --recursive --exit tests/unit", "test": "jest tests/unit",
"ft_test": "find tests/functional -name \"*.js\" | grep -v \"utils/\" | xargs mocha --timeout 120000 --exit", "ft_test": "jest tests/functional --forceExit",
"coverage": "yarn coverage_unit && yarn coverage_ft && yarn coverage_report", "coverage": "yarn coverage_unit && yarn coverage_ft && yarn coverage_report",
"coverage_unit": "nyc --silent yarn test", "coverage_unit": "yarn test --coverage",
"coverage_ft": "nyc --silent --no-clean yarn ft_test", "coverage_ft": "yarn ft_test --coverage",
"coverage_report": "nyc report --all --reporter=text-summary --reporter=lcov" "coverage_report": "nyc report --all --reporter=text-summary --reporter=lcov",
"compile": "tsc"
},
"jest": {
"collectCoverage": true,
"maxWorkers": 1,
"roots": [
".",
"lib",
"errors"
],
"testPathIgnorePatterns": [
"/node_modules/",
"helpers?\\.js",
"Mock.*\\.js",
"Dummy.*\\.js",
"tests/functional/.*/utils\\.js",
"tests/functional/.*/utils/.*\\.js"
],
"testMatch": [
"**/*.js"
]
} }
} }

View File

@ -41,7 +41,7 @@ describe('KMIP Low Level Driver', () => {
return done(err); return done(err);
} }
const responsePayload = response.lookup( const responsePayload = response.lookup(
'Response Message/Batch Item/Response Payload' 'Response Message/Batch Item/Response Payload',
)[0]; )[0];
assert.deepStrictEqual(responsePayload, assert.deepStrictEqual(responsePayload,
requestPayload); requestPayload);

View File

@ -7,7 +7,7 @@ const { logger } = require('../../utils/kmip/ersatz.js');
describe('KMIP Connection Management', () => { describe('KMIP Connection Management', () => {
let server; let server;
before(done => { beforeAll(done => {
server = net.createServer(conn => { server = net.createServer(conn => {
// abort the connection as soon as it is accepted // abort the connection as soon as it is accepted
conn.destroy(); conn.destroy();
@ -15,7 +15,7 @@ describe('KMIP Connection Management', () => {
server.listen(5696); server.listen(5696);
server.on('listening', done); server.on('listening', done);
}); });
after(done => { afterAll(done => {
server.close(done); server.close(done);
}); });

View File

@ -28,7 +28,7 @@ const mongoserver = new MongoMemoryReplSet({
describe('MongoClientInterface', () => { describe('MongoClientInterface', () => {
let metadata; let metadata;
before(done => { beforeAll(done => {
mongoserver.waitUntilRunning().then(() => { mongoserver.waitUntilRunning().then(() => {
const opts = { const opts = {
mongodb: { mongodb: {
@ -44,7 +44,7 @@ describe('MongoClientInterface', () => {
}); });
}); });
after(done => { afterAll(done => {
async.series([ async.series([
next => metadata.close(next), next => metadata.close(next),
next => mongoserver.stop() next => mongoserver.stop()

View File

@ -152,8 +152,8 @@ function _deleteObjects(objects, cb) {
} }
describe('Basic Metadata Proxy Server test', describe('Basic Metadata Proxy Server test',
function bindToThis() { () => {
this.timeout(10000); jest.setTimeout(10000);
it('Shoud get the metadataInformation', done => { it('Shoud get the metadataInformation', done => {
dispatcher.get('/default/metadataInformation', dispatcher.get('/default/metadataInformation',
(err, response, body) => { (err, response, body) => {
@ -167,8 +167,8 @@ describe('Basic Metadata Proxy Server test',
}); });
}); });
describe('Basic Metadata Proxy Server CRUD test', function bindToThis() { describe('Basic Metadata Proxy Server CRUD test', () => {
this.timeout(10000); jest.setTimeout(10000);
beforeEach(done => { beforeEach(done => {
dispatcher.post(`/default/bucket/${Bucket}`, bucketInfo, dispatcher.post(`/default/bucket/${Bucket}`, bucketInfo,

View File

@ -28,7 +28,7 @@ describe('StatsClient class', () => {
afterEach(() => redisClient.clear(() => {})); afterEach(() => redisClient.clear(() => {}));
after(() => redisClient.disconnect()); afterAll(() => redisClient.disconnect());
it('should correctly record a new request by default one increment', it('should correctly record a new request by default one increment',
done => { done => {

View File

@ -85,11 +85,11 @@ describe('LRUCache', () => {
assert.strictEqual(lru.get(100), undefined); assert.strictEqual(lru.get(100), undefined);
}); });
it('max 1000000 entries', function lru1M() { it('max 1000000 entries', () => {
// this test takes ~1-2 seconds on a laptop, nevertheless set a // this test takes ~1-2 seconds on a laptop, nevertheless set a
// large timeout to reduce the potential of flakiness on possibly // large timeout to reduce the potential of flakiness on possibly
// slower CI environment. // slower CI environment.
this.timeout(30000); jest.setTimeout(30000);
const lru = new LRUCache(1000000); const lru = new LRUCache(1000000);

View File

@ -85,7 +85,7 @@ const nonAlphabeticalData = [
const receivedData = data.map(item => ({ key: item.key, value: item.value })); const receivedData = data.map(item => ({ key: item.key, value: item.value }));
const receivedNonAlphaData = nonAlphabeticalData.map( const receivedNonAlphaData = nonAlphabeticalData.map(
item => ({ key: item.key, value: item.value }) item => ({ key: item.key, value: item.value }),
); );
const tests = [ const tests = [

View File

@ -189,8 +189,8 @@ describe('MergeStream', () => {
`${usePauseResume ? ' with pause/resume' : ''}` + `${usePauseResume ? ' with pause/resume' : ''}` +
`${errorAtEnd ? ' with error' : ''}`; `${errorAtEnd ? ' with error' : ''}`;
it(`${nbEntries} sequential entries${fixtureDesc}`, it(`${nbEntries} sequential entries${fixtureDesc}`,
function bigMergeSequential(done) { (done) => {
this.timeout(10000); jest.setTimeout(10000);
const stream1 = []; const stream1 = [];
const stream2 = []; const stream2 = [];
for (let i = 0; i < nbEntries; ++i) { for (let i = 0; i < nbEntries; ++i) {
@ -204,8 +204,8 @@ describe('MergeStream', () => {
stream1, stream2, usePauseResume, errorAtEnd, done); stream1, stream2, usePauseResume, errorAtEnd, done);
}); });
it(`${nbEntries} randomly mingled entries${fixtureDesc}`, it(`${nbEntries} randomly mingled entries${fixtureDesc}`,
function bigMergeRandom(done) { (done) => {
this.timeout(10000); jest.setTimeout(10000);
const stream1 = []; const stream1 = [];
const stream2 = []; const stream2 = [];
let accu = nbEntries; let accu = nbEntries;

View File

@ -257,7 +257,7 @@ describe('Auth Backend: Chain Backend', () => {
id3: 'email3@test.com', id3: 'email3@test.com',
// id4 should be overwritten // id4 should be overwritten
id4: 'email5@test.com', id4: 'email5@test.com',
} },
); );
}); });
}); });

View File

@ -35,11 +35,11 @@ describe('convertUTCtoISO8601 function', () => {
describe('checkTimeSkew function', () => { describe('checkTimeSkew function', () => {
let clock; let clock;
before(() => { beforeAll(() => {
// Time is 2016-03-17T18:22:01.033Z // Time is 2016-03-17T18:22:01.033Z
clock = fakeTimers.install({ now: 1458238921033 }); clock = fakeTimers.install({ now: 1458238921033 });
}); });
after(() => { afterAll(() => {
clock.uninstall(); clock.uninstall();
}); });

View File

@ -57,7 +57,6 @@ function zpad(key, length = 15) {
} }
class DummyRequestLogger { class DummyRequestLogger {
constructor() { constructor() {
this.ops = []; this.ops = [];
this.counts = { this.counts = {

View File

@ -69,7 +69,7 @@ describe('Check IP matches a list of CIDR ranges', () => {
[['192.168.1.1'], '192.168.1.1'], [['192.168.1.1'], '192.168.1.1'],
].forEach(item => ].forEach(item =>
it(`should match IP ${item[0][0]} without CIDR range`, it(`should match IP ${item[0][0]} without CIDR range`,
() => cidrListMatchCheck(item[0], item[1], true)) () => cidrListMatchCheck(item[0], item[1], true)),
); );
it('should not range match if CIDR range is not provided', it('should not range match if CIDR range is not provided',

View File

@ -9,7 +9,7 @@ describe('ZenkoMetrics', () => {
let summary; let summary;
let petCounter; let petCounter;
before(() => { beforeAll(() => {
counter = ZenkoMetrics.createCounter({ counter = ZenkoMetrics.createCounter({
name: 'gizmo_counter', name: 'gizmo_counter',
help: 'Count gizmos', help: 'Count gizmos',

View File

@ -631,7 +631,7 @@ Object.keys(acl).forEach(
dummyBucket.getUid(), testUid); dummyBucket.getUid(), testUid);
}); });
}); });
}) }),
); );
describe('uid default', () => { describe('uid default', () => {

View File

@ -1207,7 +1207,7 @@ describe('LifecycleConfiguration::getConfigJson', () => {
`should return correct configuration: ${msg}`, () => { `should return correct configuration: ${msg}`, () => {
assert.deepStrictEqual( assert.deepStrictEqual(
LifecycleConfiguration.getConfigJson(input), LifecycleConfiguration.getConfigJson(input),
expected expected,
); );
})); }));
}); });

View File

@ -34,11 +34,11 @@ describe('network.probe.HealthProbeServer', () => {
server.start(); server.start();
} }
before(done => { beforeAll(done => {
setup(done); setup(done);
}); });
after(done => { afterAll(done => {
server.stop(); server.stop();
done(); done();
}); });
@ -73,11 +73,11 @@ describe('network.probe.HealthProbeServer', () => {
done(); done();
} }
before(done => { beforeAll(done => {
setup(done); setup(done);
}); });
after(done => { afterAll(done => {
server.stop(); server.stop();
done(); done();
}); });
@ -108,11 +108,11 @@ describe('network.probe.HealthProbeServer', () => {
done(); done();
} }
before(done => { beforeAll(done => {
setup(done); setup(done);
}); });
after(done => { afterAll(done => {
server.stop(); server.stop();
done(); done();
}); });
@ -143,11 +143,11 @@ describe('network.probe.HealthProbeServer', () => {
done(); done();
} }
before(done => { beforeAll(done => {
setup(done); setup(done);
}); });
after(done => { afterAll(done => {
server.stop(); server.stop();
done(); done();
}); });
@ -176,11 +176,11 @@ describe('network.probe.HealthProbeServer', () => {
server.start(); server.start();
} }
before(done => { beforeAll(done => {
setup(done); setup(done);
}); });
after(done => { afterAll(done => {
server.stop(); server.stop();
done(); done();
}); });

View File

@ -47,7 +47,7 @@ describe('network.probe.Utils', () => {
{ {
errorType: 'MethodNotAllowed', errorType: 'MethodNotAllowed',
errorMessage: errors.MethodNotAllowed.description, errorMessage: errors.MethodNotAllowed.description,
} },
); );
done(); done();
}), }),
@ -64,7 +64,7 @@ describe('network.probe.Utils', () => {
{ {
errorType: 'MethodNotAllowed', errorType: 'MethodNotAllowed',
errorMessage: 'Very much not allowed', errorMessage: 'Very much not allowed',
} },
); );
done(); done();
}), }),

View File

@ -53,11 +53,11 @@ describe('REST interface for blob data storage', () => {
}); });
} }
before(done => { beforeAll(done => {
setup(done); setup(done);
}); });
after(done => { afterAll(done => {
server.stop(); server.stop();
client.destroy(); client.destroy();
done(); done();
@ -135,7 +135,7 @@ describe('REST interface for blob data storage', () => {
`bytes ${expectedStart}-${expectedEnd}/${contents.length}`); `bytes ${expectedStart}-${expectedEnd}/${contents.length}`);
} }
before(done => { beforeAll(done => {
const rs = createReadStream(contents); const rs = createReadStream(contents);
client.put(rs, contents.length, '1', (err, key) => { client.put(rs, contents.length, '1', (err, key) => {
assert.ifError(err); assert.ifError(err);

View File

@ -161,7 +161,7 @@ describe('level-net - LevelDB over network', () => {
async.series(opList, cb); async.series(opList, cb);
} }
before(done => { beforeAll(done => {
temp.mkdir('level-net-testdb-', (err, dbDir) => { temp.mkdir('level-net-testdb-', (err, dbDir) => {
const rootDb = level(dbDir); const rootDb = level(dbDir);
db = sublevel(rootDb); db = sublevel(rootDb);
@ -169,7 +169,7 @@ describe('level-net - LevelDB over network', () => {
}); });
}); });
after(done => { afterAll(done => {
client.once('disconnect', () => { client.once('disconnect', () => {
server.close(); server.close();
done(); done();
@ -249,7 +249,7 @@ describe('level-net - LevelDB over network', () => {
.put(keyOfIter(i), valueOfIter(i), params, putCb); .put(keyOfIter(i), valueOfIter(i), params, putCb);
} }
} }
before(done => { beforeAll(done => {
prefillKeys(done); prefillKeys(done);
}); });
it('should be able to read keys back at random', done => { it('should be able to read keys back at random', done => {

View File

@ -53,11 +53,11 @@ describe('rpc - generic client/server RPC system', () => {
miscClient.connect(done); miscClient.connect(done);
} }
before(done => { beforeAll(done => {
setupRPC(done); setupRPC(done);
}); });
after(done => { afterAll(done => {
miscClient.once('disconnect', () => { miscClient.once('disconnect', () => {
server.close(); server.close();
done(); done();

View File

@ -317,9 +317,9 @@ describe('patch location constriants', () => {
patchLocations( patchLocations(
{ [locationName]: locations }, { [locationName]: locations },
{ privateKey }, { privateKey },
mockLog mockLog,
), ),
{ [locationName]: expected } { [locationName]: expected },
); );
}); });
}); });
@ -330,9 +330,9 @@ describe('patch location constriants', () => {
patchLocations( patchLocations(
undefined, undefined,
{ privateKey }, { privateKey },
mockLog mockLog,
), ),
{} {},
); );
}); });
@ -345,9 +345,9 @@ describe('patch location constriants', () => {
}, },
}, },
{ privateKey }, { privateKey },
mockLog mockLog,
), ),
{} {},
); );
}); });
}); });

View File

@ -34,7 +34,7 @@ function getRuleIDs(rules) {
describe('LifecycleUtils::getApplicableRules', () => { describe('LifecycleUtils::getApplicableRules', () => {
let lutils; let lutils;
before(() => { beforeAll(() => {
lutils = new LifecycleUtils([ lutils = new LifecycleUtils([
'expiration', 'expiration',
'noncurrentVersionExpiration', 'noncurrentVersionExpiration',
@ -434,7 +434,7 @@ describe('LifecycleUtils::getApplicableRules', () => {
describe('LifecycleUtils::filterRules', () => { describe('LifecycleUtils::filterRules', () => {
let lutils; let lutils;
before(() => { beforeAll(() => {
lutils = new LifecycleUtils(); lutils = new LifecycleUtils();
}); });
@ -522,7 +522,7 @@ describe('LifecycleUtils::filterRules', () => {
const expRes1 = getRuleIDs(mBucketRules.filter(rule => const expRes1 = getRuleIDs(mBucketRules.filter(rule =>
(rule.Filter && rule.Filter.Tag && (rule.Filter && rule.Filter.Tag &&
rule.Filter.Tag.Key === 'tag1' && rule.Filter.Tag.Key === 'tag1' &&
rule.Filter.Tag.Value === 'val1') rule.Filter.Tag.Value === 'val1'),
)); ));
assert.deepStrictEqual(expRes1, getRuleIDs(res1)); assert.deepStrictEqual(expRes1, getRuleIDs(res1));
@ -532,7 +532,7 @@ describe('LifecycleUtils::filterRules', () => {
const expRes2 = getRuleIDs(mBucketRules.filter(rule => const expRes2 = getRuleIDs(mBucketRules.filter(rule =>
rule.Filter && rule.Filter.Tag && rule.Filter && rule.Filter.Tag &&
rule.Filter.Tag.Key === 'tag3-1' && rule.Filter.Tag.Key === 'tag3-1' &&
rule.Filter.Tag.Value === 'val3' rule.Filter.Tag.Value === 'val3',
)); ));
assert.deepStrictEqual(expRes2, getRuleIDs(res2)); assert.deepStrictEqual(expRes2, getRuleIDs(res2));
}); });
@ -619,7 +619,7 @@ describe('LifecycleUtils::filterRules', () => {
describe('LifecycleUtils::getApplicableTransition', () => { describe('LifecycleUtils::getApplicableTransition', () => {
let lutils; let lutils;
before(() => { beforeAll(() => {
lutils = new LifecycleUtils(); lutils = new LifecycleUtils();
}); });
@ -792,7 +792,7 @@ describe('LifecycleUtils::getApplicableTransition', () => {
describe('LifecycleUtils::compareTransitions', () => { describe('LifecycleUtils::compareTransitions', () => {
let lutils; let lutils;
before(() => { beforeAll(() => {
lutils = new LifecycleUtils(); lutils = new LifecycleUtils();
}); });

View File

@ -36,7 +36,7 @@ describe('routesUtils.responseStreamData', () => {
let httpServer; let httpServer;
let awsClient; let awsClient;
before(done => { beforeAll(done => {
awsClient = new AwsClient(awsConfig); awsClient = new AwsClient(awsConfig);
httpServer = http.createServer((req, res) => { httpServer = http.createServer((req, res) => {
const objStream = new DummyObjectStream(0, 10000000); const objStream = new DummyObjectStream(0, 10000000);
@ -47,7 +47,7 @@ describe('routesUtils.responseStreamData', () => {
httpServer.on('error', err => assert.ifError(err)); httpServer.on('error', err => assert.ifError(err));
}); });
after(() => { afterAll(() => {
httpServer.close(); httpServer.close();
}); });

View File

@ -20,6 +20,7 @@ describe('DummyObjectStream', () => {
it('should return a stream of 8-byte hex-encoded blocks', async () => { it('should return a stream of 8-byte hex-encoded blocks', async () => {
// FIXME we likely need an eslint update // FIXME we likely need an eslint update
/* eslint-disable no-unused-expressions */ /* eslint-disable no-unused-expressions */
jest.setTimeout(30000);
await testStream(0, 0, ''); await testStream(0, 0, '');
await testStream(50, 0, ''); await testStream(50, 0, '');
await testStream(0, 1, ' '); await testStream(0, 1, ' ');
@ -53,5 +54,5 @@ describe('DummyObjectStream', () => {
.join(''); .join('');
await testStream(567890123, 5 + 8 * 1024 * 1024 + 3, expectedLarge2); await testStream(567890123, 5 + 8 * 1024 * 1024 + 3, expectedLarge2);
/* eslint-enable no-unused-expressions */ /* eslint-enable no-unused-expressions */
}).timeout(30000); });
}); });

View File

@ -54,7 +54,7 @@ describe('external backend clients', () => {
backendClients.forEach(backend => { backendClients.forEach(backend => {
let testClient; let testClient;
before(() => { beforeAll(() => {
testClient = new backend.Class(backend.config); testClient = new backend.Class(backend.config);
testClient._client = new DummyService({ versioning: true }); testClient._client = new DummyService({ versioning: true });
}); });

View File

@ -87,12 +87,12 @@ const operations = [
}, },
]; ];
describe('GcpService request behavior', function testSuite() { describe('GcpService request behavior', () => {
this.timeout(120000); jest.setTimeout(120000);
let httpServer; let httpServer;
let client; let client;
before(done => { beforeAll(done => {
client = new GCP({ client = new GCP({
endpoint: `http://${host}`, endpoint: `http://${host}`,
maxRetries: 0, maxRetries: 0,
@ -109,7 +109,7 @@ describe('GcpService request behavior', function testSuite() {
}); });
}); });
after('Terminating Server', () => { afterAll(() => {
httpServer.close(); httpServer.close();
}); });
@ -125,12 +125,12 @@ describe('GcpService request behavior', function testSuite() {
}); });
}); });
describe('GcpService pathStyle tests', function testSuite() { describe('GcpService pathStyle tests', () => {
this.timeout(120000); jest.setTimeout(120000);
let httpServer; let httpServer;
let client; let client;
before(done => { beforeAll(done => {
client = new GCP({ client = new GCP({
endpoint: `http://${host}`, endpoint: `http://${host}`,
maxRetries: 0, maxRetries: 0,
@ -147,7 +147,7 @@ describe('GcpService pathStyle tests', function testSuite() {
}); });
}); });
after('Terminating Server', () => { afterAll(() => {
httpServer.close(); httpServer.close();
}); });
@ -159,12 +159,12 @@ describe('GcpService pathStyle tests', function testSuite() {
})); }));
}); });
describe('GcpService dnsStyle tests', function testSuite() { describe('GcpService dnsStyle tests', () => {
this.timeout(120000); jest.setTimeout(120000);
let httpServer; let httpServer;
let client; let client;
before(done => { beforeAll(done => {
client = new GCP({ client = new GCP({
endpoint: `http://${host}`, endpoint: `http://${host}`,
maxRetries: 0, maxRetries: 0,
@ -181,7 +181,7 @@ describe('GcpService dnsStyle tests', function testSuite() {
}); });
}); });
after('Terminating Server', () => { afterAll(() => {
httpServer.close(); httpServer.close();
}); });

View File

@ -64,7 +64,7 @@ function getDataWrapper() {
let dw; let dw;
describe('Routes from DataWrapper to backend client', () => { describe('Routes from DataWrapper to backend client', () => {
before(() => { beforeAll(() => {
dw = getDataWrapper(); dw = getDataWrapper();
}); });

View File

@ -82,7 +82,6 @@ const malformedLogEntry = new MockStream(malformedLogEntryData);
// mock a simple bucketclient to get a fake raft log // mock a simple bucketclient to get a fake raft log
class BucketClientMock { class BucketClientMock {
getRaftLog(raftId, start, limit, targetLeader, reqUids, callback) { getRaftLog(raftId, start, limit, targetLeader, reqUids, callback) {
switch (raftId) { switch (raftId) {
case 0: case 0:
@ -117,11 +116,11 @@ describe('raft record log client', () => {
done(); done();
} }
before(done => { beforeAll(done => {
setup(done); setup(done);
}); });
after(done => { afterAll(done => {
done(); done();
}); });

View File

@ -66,7 +66,7 @@ describe('record log - persistent log of metadata operations', () => {
done(); done();
} }
before(done => { beforeAll(done => {
temp.mkdir('record-log-testdir-', (err, dbDir) => { temp.mkdir('record-log-testdir-', (err, dbDir) => {
const rootDb = level(dbDir); const rootDb = level(dbDir);
db = sublevel(rootDb); db = sublevel(rootDb);
@ -74,7 +74,7 @@ describe('record log - persistent log of metadata operations', () => {
}); });
}); });
after(done => { afterAll(done => {
server.close(); server.close();
done(); done();
}); });
@ -207,7 +207,7 @@ describe('record log - persistent log of metadata operations', () => {
describe('readRecords', () => { describe('readRecords', () => {
let logProxy; let logProxy;
before(done => { beforeAll(done => {
logProxy = createScratchRecordLog(cliLogger, err => { logProxy = createScratchRecordLog(cliLogger, err => {
assert.ifError(err); assert.ifError(err);
// fill the log with 1000 entries // fill the log with 1000 entries
@ -228,7 +228,7 @@ describe('record log - persistent log of metadata operations', () => {
}); });
}); });
after(done => closeRecordLog(logProxy, () => { afterAll(done => closeRecordLog(logProxy, () => {
logProxy = undefined; logProxy = undefined;
done(); done();
})); }));

View File

@ -395,7 +395,7 @@ describe('MongoClientInterface::_processEntryData', () => {
tests.forEach(([msg, isTransient, params, expected]) => it(msg, () => { tests.forEach(([msg, isTransient, params, expected]) => it(msg, () => {
assert.deepStrictEqual( assert.deepStrictEqual(
mongoTestClient._processEntryData(params, isTransient), mongoTestClient._processEntryData(params, isTransient),
expected expected,
); );
})); }));
}); });
@ -498,7 +498,7 @@ describe('MongoClientInterface::_isReplicationEntryStalled', () => {
tests.forEach(([msg, params, expected]) => it(msg, () => { tests.forEach(([msg, params, expected]) => it(msg, () => {
assert.deepStrictEqual( assert.deepStrictEqual(
mongoTestClient._isReplicationEntryStalled(params, testDate), mongoTestClient._isReplicationEntryStalled(params, testDate),
expected expected,
); );
})); }));
}); });
@ -556,7 +556,7 @@ function uploadObjects(client, bucketName, objectList, callback) {
describe('MongoClientInterface, tests', () => { describe('MongoClientInterface, tests', () => {
const hr = 1000 * 60 * 60; const hr = 1000 * 60 * 60;
let client; let client;
before(done => { beforeAll(done => {
mongoserver.waitUntilRunning().then(() => { mongoserver.waitUntilRunning().then(() => {
const opts = { const opts = {
replicaSetHosts: 'localhost:27018', replicaSetHosts: 'localhost:27018',
@ -573,7 +573,7 @@ describe('MongoClientInterface, tests', () => {
}); });
}); });
after(done => { afterAll(done => {
async.series([ async.series([
next => client.close(next), next => client.close(next),
next => mongoserver.stop() next => mongoserver.stop()

View File

@ -32,8 +32,8 @@ describe('StringHash', () => {
done(); done();
}); });
it(`Should distribute uniformly with a maximum of ${ERROR}% of deviation`, it(`Should distribute uniformly with a maximum of ${ERROR}% of deviation`,
function f(done) { (done) => {
this.timeout(20000); jest.setTimeout(20000);
const strings = new Array(STRING_COUNT).fill('') const strings = new Array(STRING_COUNT).fill('')
.map(() => randomString(10)); .map(() => randomString(10));
const arr = new Array(ARRAY_LENGTH).fill(0); const arr = new Array(ARRAY_LENGTH).fill(0);

View File

@ -177,7 +177,7 @@ class LoopbackServerChannel extends EchoChannel {
serverExtensions.map(extension => serverExtensions.map(extension =>
this.KMIP.TextString( this.KMIP.TextString(
extension.name, extension.name,
extension.value) extension.value),
))); )));
} }
if (queryFunctions.includes('Query Extension Map')) { if (queryFunctions.includes('Query Extension Map')) {

View File

@ -50,7 +50,6 @@ class EchoChannel extends EventEmitter {
this.clogged = true; this.clogged = true;
return this; return this;
} }
} }
class MirrorChannel extends EchoChannel { class MirrorChannel extends EchoChannel {

16
tsconfig.json Normal file
View File

@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"rootDir": "./",
"resolveJsonModule": true,
"allowJs": true,
"checkJs": false,
"outDir": "./build",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true
},
"include": [ "./index.js", "./lib/*.js", "./lib/**/*.js" ],
"exclude": [ "./node_modules/*" ]
}

4529
yarn.lock

File diff suppressed because it is too large Load Diff