From 4c63cb848535ea885c35e854f501599be42f0e65 Mon Sep 17 00:00:00 2001 From: williamlardier Date: Mon, 15 Apr 2024 15:07:52 +0200 Subject: [PATCH] s --- config.json | 2 +- .../test/bucket/getBucketQuota.js | 3 +- .../aws-node-sdk/test/quota/tooling.js | 8 +++- tests/functional/config.json | 4 ++ tests/scuba/awsNodeSdk.js | 39 +++++++++++-------- 5 files changed, 35 insertions(+), 21 deletions(-) diff --git a/config.json b/config.json index 3a44b36aed..fe0aaa2ad9 100644 --- a/config.json +++ b/config.json @@ -60,7 +60,7 @@ }, "clusters": 1, "log": { - "logLevel": "info", + "logLevel": "trace", "dumpLevel": "error" }, "healthChecks": { diff --git a/tests/functional/aws-node-sdk/test/bucket/getBucketQuota.js b/tests/functional/aws-node-sdk/test/bucket/getBucketQuota.js index 2a41a70e7e..2a073dc3c3 100644 --- a/tests/functional/aws-node-sdk/test/bucket/getBucketQuota.js +++ b/tests/functional/aws-node-sdk/test/bucket/getBucketQuota.js @@ -39,7 +39,7 @@ describe('Test get bucket quota', () => { } }); - it('should return no such bucket quota', async () => { + it.only('should return no such bucket quota', async () => { try { await sendRequest('DELETE', '127.0.0.1:8000', `/${bucket}/?quota=true`); try { @@ -49,6 +49,7 @@ describe('Test get bucket quota', () => { assert.strictEqual(err.Error.Code[0], 'NoSuchBucketQuota'); } } catch (err) { + console.log(err); assert.fail(`Expected no error, but got ${err}`); } }); diff --git a/tests/functional/aws-node-sdk/test/quota/tooling.js b/tests/functional/aws-node-sdk/test/quota/tooling.js index afd4ec432c..d67f6099d2 100644 --- a/tests/functional/aws-node-sdk/test/quota/tooling.js +++ b/tests/functional/aws-node-sdk/test/quota/tooling.js @@ -2,7 +2,7 @@ const fetch = require('node-fetch'); const AWS = require('aws-sdk'); const xml2js = require('xml2js'); -const sendRequest = async (method, host, path, body = '') => +const sendRequest = async (method, host, path, body = '', config = null) => new Promise(async (resolve, reject) => { const service = 's3'; const endpoint = new AWS.Endpoint(host); @@ -18,7 +18,10 @@ const sendRequest = async (method, host, path, body = '') => request.region = 'us-east-1'; const signer = new AWS.Signers.V4(request, service); - signer.addAuthorization(AWS.config.credentials, new Date()); + const accessKeyId = config?.accessKey || AWS.config.credentials?.accessKeyId; + const secretAccessKey = config?.secretKey || AWS.config.credentials?.secretAccessKey; + const credentials = new AWS.Credentials(accessKeyId, secretAccessKey); + signer.addAuthorization(credentials, new Date()); const url = `http://${host}${path}`; const options = { @@ -34,6 +37,7 @@ const sendRequest = async (method, host, path, body = '') => const response = await fetch(url, options); const text = await response.text(); const result = await xml2js.parseStringPromise(text); + console.log(result); if (result && result.Error) { reject(result); } else { diff --git a/tests/functional/config.json b/tests/functional/config.json index 24e61986f5..78c7aebfd1 100644 --- a/tests/functional/config.json +++ b/tests/functional/config.json @@ -6,5 +6,9 @@ "localCache": { "host": "127.0.0.1", "port": 6379 + }, + "log": { + "logLevel": "trace", + "dumpLevel": "error" } } diff --git a/tests/scuba/awsNodeSdk.js b/tests/scuba/awsNodeSdk.js index 3b1d6e23a9..de5a502b87 100644 --- a/tests/scuba/awsNodeSdk.js +++ b/tests/scuba/awsNodeSdk.js @@ -4,6 +4,7 @@ const { S3 } = require('aws-sdk'); const getConfig = require('../functional/aws-node-sdk/test/support/config'); const { Scuba: MockScuba, inflightFlushFrequencyMS } = require('../utilities/mock/Scuba'); const sendRequest = require('../functional/aws-node-sdk/test/quota/tooling').sendRequest; +const memCredentials = require('../functional/aws-node-sdk/lib/json/mem_credentials.json'); let s3Client = null; const quota = { quota: 1000 }; @@ -205,6 +206,10 @@ describe('quota evaluation with scuba metrics', function t() { this.timeout(30000); const scuba = new MockScuba(); const putQuotaVerb = 'PUT'; + const config = { + accessKey: memCredentials.default.accessKey, + secretKey: memCredentials.default.secretKey, + }; before(done => { const config = getConfig('default', { signatureVersion: 'v4' }); @@ -227,8 +232,8 @@ describe('quota evaluation with scuba metrics', function t() { const size = 1024; return async.series([ next => createBucket(bucket, next), - next => sendRequest(putQuotaVerb, '127.0.0.1:8000', `/${bucket}/?quota=true`, JSON.stringify(quota)) - .then(() => next()).catch(err => next(err)), + next => sendRequest(putQuotaVerb, '127.0.0.1:8000', `/${bucket}/?quota=true`, + JSON.stringify(quota), config).then(() => next()).catch(err => next(err)), next => putObject(bucket, key, size, err => { assert.strictEqual(err.code, 'QuotaExceeded'); return next(); @@ -243,8 +248,8 @@ describe('quota evaluation with scuba metrics', function t() { const size = 900; return async.series([ next => createBucket(bucket, next), - next => sendRequest(putQuotaVerb, '127.0.0.1:8000', `/${bucket}/?quota=true`, JSON.stringify(quota)) - .then(() => next()).catch(err => next(err)), + next => sendRequest(putQuotaVerb, '127.0.0.1:8000', `/${bucket}/?quota=true`, + JSON.stringify(quota), config).then(() => next()).catch(err => next(err)), next => putObject(bucket, key, size, next), next => wait(inflightFlushFrequencyMS * 2, next), next => copyObject(bucket, key, err => { @@ -264,8 +269,8 @@ describe('quota evaluation with scuba metrics', function t() { let uploadId = null; return async.series([ next => createBucket(bucket, next), - next => sendRequest(putQuotaVerb, '127.0.0.1:8000', `/${bucket}/?quota=true`, JSON.stringify(quota)) - .then(() => next()).catch(err => next(err)), + next => sendRequest(putQuotaVerb, '127.0.0.1:8000', `/${bucket}/?quota=true`, + JSON.stringify(quota), config).then(() => next()).catch(err => next(err)), next => objectMPU(bucket, key, parts, partSize, (err, _uploadId) => { uploadId = _uploadId; assert.strictEqual(err.code, 'QuotaExceeded'); @@ -287,8 +292,8 @@ describe('quota evaluation with scuba metrics', function t() { const size = 300; return async.series([ next => createBucket(bucket, next), - next => sendRequest(putQuotaVerb, '127.0.0.1:8000', `/${bucket}/?quota=true`, JSON.stringify(quota)) - .then(() => next()).catch(err => next(err)), + next => sendRequest(putQuotaVerb, '127.0.0.1:8000', `/${bucket}/?quota=true`, + JSON.stringify(quota), config).then(() => next()).catch(err => next(err)), next => putObject(bucket, key, size, err => { assert.ifError(err); return next(); @@ -305,8 +310,8 @@ describe('quota evaluation with scuba metrics', function t() { const size = 1024; return async.series([ next => createBucket(bucket, next), - next => sendRequest(putQuotaVerb, '127.0.0.1:8000', `/${bucket}/?quota=true`, JSON.stringify(quota)) - .then(() => next()).catch(err => next(err)), + next => sendRequest(putQuotaVerb, '127.0.0.1:8000', `/${bucket}/?quota=true`, + JSON.stringify(quota), config).then(() => next()).catch(err => next(err)), next => putObject(bucket, key, size, err => { assert.ifError(err); return next(); @@ -330,7 +335,7 @@ describe('quota evaluation with scuba metrics', function t() { return async.series([ next => createBucket(bucket, next), next => sendRequest(putQuotaVerb, '127.0.0.1:8000', `/${bucket}/?quota=true`, - JSON.stringify({ quota: Math.round(partSize * 2.5) })) + JSON.stringify({ quota: Math.round(partSize * 2.5) }), config) .then(() => next()).catch(err => next(err)), next => putObject(bucket, keyToCopy, partSize, next), next => uploadPartCopy(bucket, key, parts, partSize, inflightFlushFrequencyMS * 2, keyToCopy, @@ -351,8 +356,8 @@ describe('quota evaluation with scuba metrics', function t() { const size = 900; return async.series([ next => createBucket(bucket, next), - next => sendRequest(putQuotaVerb, '127.0.0.1:8000', `/${bucket}/?quota=true`, JSON.stringify(quota)) - .then(() => next()).catch(err => next(err)), + next => sendRequest(putQuotaVerb, '127.0.0.1:8000', `/${bucket}/?quota=true`, + JSON.stringify(quota), config).then(() => next()).catch(err => next(err)), next => putObject(bucket, key, size, err => { assert.ifError(err); return next(); @@ -373,8 +378,8 @@ describe('quota evaluation with scuba metrics', function t() { const size = 400; return async.series([ next => createBucket(bucket, next), - next => sendRequest(putQuotaVerb, '127.0.0.1:8000', `/${bucket}/?quota=true`, JSON.stringify(quota)) - .then(() => next()).catch(err => next(err)), + next => sendRequest(putQuotaVerb, '127.0.0.1:8000', `/${bucket}/?quota=true`, + JSON.stringify(quota), config).then(() => next()).catch(err => next(err)), next => putObject(bucket, `${key}1`, size, err => { assert.ifError(err); return next(); @@ -412,8 +417,8 @@ describe('quota evaluation with scuba metrics', function t() { const size = 400; return async.series([ next => createBucket(bucket, next), - next => sendRequest(putQuotaVerb, '127.0.0.1:8000', `/${bucket}/?quota=true`, JSON.stringify(quota)) - .then(() => next()).catch(err => next(err)), + next => sendRequest(putQuotaVerb, '127.0.0.1:8000', `/${bucket}/?quota=true`, + JSON.stringify(quota), config).then(() => next()).catch(err => next(err)), next => putObject(bucket, key, size, err => { assert.ifError(err); return next();