Skip to content

Commit 049205b

Browse files
test(fargate): add aws fargate tests to cli repo (#2407)
* test(fargate): add simple bom test * test(fargate): add mixed hierarchy test * test(fargate): add ensure test * test(fargate): add ensure and expect failure test * test(fargate): add expect failure test * test(fargate): add kitchen sink test with multiple features * test(fargate): add lots of output test * test(fargate): add memory hog test * test(fargate): increase think time in memory-hog * test(fargate): increase test timeout due to aws tests being long * test(cli): create report abstraction and use in fargate tests * test(fargate): record fargate tests to cloud dashboard * test(fargate): rename fargate scenarios to improve debugging * test(fargate): increase deps for mixed-hierarchy test * test(fargate): use 51 workers as in original test
1 parent 84b6b14 commit 049205b

40 files changed

+1552
-17
lines changed

packages/artillery/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"test:unit": "export ARTILLERY_TELEMETRY_DEFAULTS='{\"source\":\"test-suite\"}' && tap --no-coverage --timeout=420 --color test/unit/*.test.js",
4747
"test:acceptance": "export ARTILLERY_TELEMETRY_DEFAULTS='{\"source\":\"test-suite\"}' && tap --no-coverage --timeout=420 test/cli/*.test.js && bash test/lib/run.sh && tap --no-coverage --color test/testcases/plugins/*.test.js",
4848
"test": "npm run test:unit && npm run test:acceptance",
49-
"test:aws": "export ARTILLERY_TELEMETRY_DEFAULTS='{\"source\":\"test-suite\"}' && tap --no-coverage --color --timeout=600 test/cloud-e2e/**/*.test.js",
49+
"test:aws": "export ARTILLERY_TELEMETRY_DEFAULTS='{\"source\":\"test-suite\"}' && tap --no-coverage --color --timeout=3600 test/cloud-e2e/**/*.test.js",
5050
"lint": "eslint --ext \".js,.ts,.tsx\" .",
5151
"lint-fix": "npm run lint -- --fix"
5252
},

packages/artillery/test/cli/_helpers.js

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const path = require('path');
55
const os = require('os');
66
const { getBinPathSync } = require('get-bin-path');
77
const a9path = getBinPathSync();
8+
const { createHash } = require('crypto');
89

910
async function execute(args, options) {
1011
try {
@@ -30,6 +31,14 @@ async function getRootPath(filename) {
3031
return path.resolve(__dirname, '..', '..', filename);
3132
}
3233

34+
function generateTmpReportPath(testName, extension) {
35+
return returnTmpPath(
36+
`report-${createHash('md5')
37+
.update(testName)
38+
.digest('hex')}-${Date.now()}.${extension}`
39+
);
40+
}
41+
3342
function getTestTags(additionalTags) {
3443
const actorTag = `actor:${process.env.GITHUB_ACTOR || 'localhost'}`;
3544
const repoTag = `repo:${process.env.GITHUB_REPO || 'artilleryio/artillery'}`;
@@ -43,5 +52,6 @@ module.exports = {
4352
deleteFile,
4453
getRootPath,
4554
returnTmpPath,
55+
generateTmpReportPath,
4656
getTestTags
4757
};

packages/artillery/test/cli/command-report.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const tap = require('tap');
2-
const { execute, returnTmpPath } = require('../cli/_helpers.js');
2+
const { execute, generateTmpReportPath } = require('../cli/_helpers.js');
33

44
tap.test('If we report specifying output, no browser is opened', async (t) => {
5-
const outputFilePath = returnTmpPath('report.html');
5+
const outputFilePath = generateTmpReportPath(t.name, 'html');
66

77
const [exitCode] = await execute([
88
'report',

packages/artillery/test/cli/command-run.test.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,16 @@ const {
33
execute,
44
deleteFile,
55
getRootPath,
6-
returnTmpPath
6+
returnTmpPath,
7+
generateTmpReportPath
78
} = require('../cli/_helpers.js');
89
const fs = require('fs');
910
const path = require('path');
1011
const execa = require('execa');
11-
const { createHash } = require('crypto');
1212

1313
let reportFilePath;
1414
tap.beforeEach(async (t) => {
15-
reportFilePath = returnTmpPath(
16-
`report-${createHash('md5')
17-
.update(t.name)
18-
.digest('hex')}-${Date.now()}.json`
19-
);
15+
reportFilePath = generateTmpReportPath(t.name, 'json');
2016
});
2117

2218
tap.test('Run a simple script', async (t) => {

packages/artillery/test/cli/run-typescript.test.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
const tap = require('tap');
2-
const { execute, returnTmpPath } = require('../cli/_helpers.js');
3-
const { createHash } = require('crypto');
2+
const { execute, generateTmpReportPath } = require('../cli/_helpers.js');
43
const fs = require('fs');
54

65
let reportFilePath;
76
tap.beforeEach(async (t) => {
8-
reportFilePath = returnTmpPath(
9-
`report-${createHash('md5')
10-
.update(t.name)
11-
.digest('hex')}-${Date.now()}.json`
12-
);
7+
reportFilePath = generateTmpReportPath(t.name, 'json');
138
});
149

1510
tap.test('Can run a Typescript processor', async (t) => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
config:
2+
target: "http://asciiart.artillery.io:8080"
3+
plugins:
4+
expect: {}
5+
ensure:
6+
p99: 10000
7+
thresholds:
8+
- "http.response_time.p95": 1
9+
phases:
10+
- duration: 5
11+
arrivalRate: 1
12+
scenarios:
13+
- name: expect-ensure-exit-condition-test
14+
flow:
15+
- get:
16+
url: "/"
17+
expect:
18+
- statusCode: 300
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
config:
2+
target: "http://asciiart.artillery.io:8080"
3+
plugins:
4+
expect: {}
5+
phases:
6+
- duration: 5
7+
arrivalRate: 1
8+
scenarios:
9+
- name: expect-exit-condition-test
10+
flow:
11+
- get:
12+
url: "/"
13+
expect:
14+
- statusCode: 300
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DOTENV1=/
2+
DOTENV2=/dino
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
config:
2+
target: http://asciiart.artillery.io:8080
3+
plugins:
4+
ensure: {}
5+
phases:
6+
- duration: 20
7+
arrivalRate: 1
8+
ensure:
9+
p99: 10000
10+
thresholds:
11+
- "http.response_time.p99": 10000
12+
scenarios:
13+
- name: load homepage
14+
flow:
15+
- get:
16+
url: "{{$processEnvironment.SECRET1}}"
17+
- get:
18+
url: "{{$processEnvironment.SECRET2}}"
19+
- get:
20+
url: "{{$processEnvironment.DOTENV1}}"
21+
- get:
22+
url: "{{$processEnvironment.DOTENV2}}"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
config:
2+
target: http://asciiart.artillery.io:8080
3+
phases:
4+
- arrivalRate: 1
5+
duration: 60
6+
defaults:
7+
headers:
8+
user-agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
9+
processor: "./processor.js"
10+
scenarios:
11+
- flow:
12+
- get:
13+
url: "/"
14+
afterResponse: logOutput
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function logOutput(req, res, userContext, events, done) {
2+
for (let i = 0; i < 10; i++) {
3+
events.emit(
4+
'counter',
5+
`very.very.long.name.for.a.counter.metric.so.that.we.generate.a.lot.of.console.output.${Date.now()}${i}`,
6+
1
7+
);
8+
events.emit(
9+
'histogram',
10+
`very.very.long.name.for.a.histogram.metric.so.that.we.generate.a.lot.of.console.output.${Date.now()}${i}`,
11+
100
12+
);
13+
}
14+
return done();
15+
}
16+
17+
module.exports = {
18+
logOutput
19+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# 10 VUs, making 10 calls each to a function that allocates 100MB -> ~10GB total
2+
# This will fail with default configuration, which is:
3+
# - 4GB RAM given to workers on Fargate
4+
# - Node.js memory limit of 4GB
5+
6+
config:
7+
target: http://asciiart.artillery.io:8080
8+
phases:
9+
- arrivalRate: 1
10+
duration: 10
11+
processor: './processor.js'
12+
13+
scenarios:
14+
- flow:
15+
- loop:
16+
- get:
17+
url: "/armadillo"
18+
beforeRequest: hogSomeRam
19+
- think: 1
20+
count: 10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
let data = [];
2+
3+
console.log('NODE_OPTIONS:');
4+
console.log(process.env.NODE_OPTIONS);
5+
6+
function hogSomeRam(req, context, events, next) {
7+
// Allocate 100MB
8+
data.push(Buffer.alloc(1024 * 1024 * 100, 1));
9+
10+
console.log(new Date(), 'allocated more data');
11+
console.log('RSS (MB):', process.memoryUsage().rss / 1024 / 1024);
12+
13+
return next();
14+
}
15+
16+
module.exports = {
17+
hogSomeRam
18+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const bc = require('@babel/core');
2+
const uuid = require('uuid');
3+
const client = require('aws-sdk/clients/lambda');
4+
5+
module.exports = {
6+
setUrl: require('./set-url')
7+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const meow = require('../meow');
2+
module.exports = require('aws4');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const lodash = require('lodash');
2+
module.export = 'meow';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = setUrl;
2+
3+
const AWS = require('aws-sdk');
4+
const signer = require('./lib/signer');
5+
6+
function setUrl(req, res, ctx, ee, done) {
7+
req.url = '/';
8+
return done();
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
config:
2+
target: http://asciiart.artillery.io:8080
3+
processor: "../code/functions.js"
4+
environments:
5+
main:
6+
phases:
7+
- duration: 20
8+
arrivalRate: 1
9+
payload:
10+
- path: "../data/variables.csv" # this is resolved relative to the main script for now, NOT this file
11+
fields: ["username", "email"]
12+
plugins:
13+
metrics-by-endpoint: {}
14+
stage:
15+
plugins:
16+
datadog: {}
17+
plugins:
18+
http-file-uploads:
19+
filePaths:
20+
- ../data/files
21+
publish-metrics:
22+
- type: statsd
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
3+
4+

0 commit comments

Comments
 (0)