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 f912e22
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .github/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ services:
- DEFAULT_BUCKET_KEY_FORMAT
- METADATA_MAX_CACHED_BUCKETS
- ENABLE_NULL_VERSION_COMPAT_MODE
- SCUBA_HOST
- SCUBA_PORT
- SCUBA_HEALTHCHECK_FREQUENCY
env_file:
- creds.env
depends_on:
Expand Down
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
9 changes: 6 additions & 3 deletions tests/functional/aws-node-sdk/test/bucket/getBucketQuota.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ 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`);
const a = await sendRequest('DELETE', '127.0.0.1:8000', `/${bucket}/?quota=true`);
console.log('got', a);

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

View workflow job for this annotation

GitHub Actions / linting-coverage

Unexpected console statement
try {
await sendRequest('GET', '127.0.0.1:8000', `/${bucket}/?quota=true`);
const b = await sendRequest('GET', '127.0.0.1:8000', `/${bucket}/?quota=true`);
console.log('got', b);

Check failure on line 48 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 NoSuchBucketQuota error');
} catch (err) {
console.log('got2', err);

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

View workflow job for this annotation

GitHub Actions / linting-coverage

Unexpected console statement
assert.strictEqual(err.Error.Code[0], 'NoSuchBucketQuota');
}
} catch (err) {
Expand Down
7 changes: 5 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 Down
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 f912e22

Please sign in to comment.