Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
williamlardier committed Apr 15, 2024
1 parent 0bee8a0 commit 4c63cb8
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 21 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
},
"clusters": 1,
"log": {
"logLevel": "info",
"logLevel": "trace",
"dumpLevel": "error"
},
"healthChecks": {
Expand Down
3 changes: 2 additions & 1 deletion tests/functional/aws-node-sdk/test/bucket/getBucketQuota.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {

Check failure on line 42 in tests/functional/aws-node-sdk/test/bucket/getBucketQuota.js

View workflow job for this annotation

GitHub Actions / linting-coverage

Unexpected exclusive mocha test
try {
await sendRequest('DELETE', '127.0.0.1:8000', `/${bucket}/?quota=true`);
try {
Expand All @@ -49,6 +49,7 @@ describe('Test get bucket quota', () => {
assert.strictEqual(err.Error.Code[0], 'NoSuchBucketQuota');
}
} catch (err) {
console.log(err);

Check failure on line 52 in tests/functional/aws-node-sdk/test/bucket/getBucketQuota.js

View workflow job for this annotation

GitHub Actions / linting-coverage

Unexpected console statement
assert.fail(`Expected no error, but got ${err}`);
}
});
Expand Down
8 changes: 6 additions & 2 deletions tests/functional/aws-node-sdk/test/quota/tooling.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 = {
Expand All @@ -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);

Check failure on line 40 in tests/functional/aws-node-sdk/test/quota/tooling.js

View workflow job for this annotation

GitHub Actions / linting-coverage

Unexpected console statement
if (result && result.Error) {
reject(result);
} else {
Expand Down
4 changes: 4 additions & 0 deletions tests/functional/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
"localCache": {
"host": "127.0.0.1",
"port": 6379
},
"log": {
"logLevel": "trace",
"dumpLevel": "error"
}
}
39 changes: 22 additions & 17 deletions tests/scuba/awsNodeSdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -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' });
Expand All @@ -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();
Expand All @@ -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 => {
Expand All @@ -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');
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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,
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 4c63cb8

Please sign in to comment.