@depup/artillery 2.0.30-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -0
- package/bin/run +29 -0
- package/bin/run.cmd +3 -0
- package/changes.json +138 -0
- package/console-reporter.js +1 -0
- package/lib/artillery-global.js +33 -0
- package/lib/cli/banner.js +8 -0
- package/lib/cli/common-flags.js +80 -0
- package/lib/cli/hooks/version.js +20 -0
- package/lib/cmds/dino.js +109 -0
- package/lib/cmds/quick.js +122 -0
- package/lib/cmds/report.js +34 -0
- package/lib/cmds/run-aci.js +91 -0
- package/lib/cmds/run-fargate.js +192 -0
- package/lib/cmds/run-lambda.js +96 -0
- package/lib/cmds/run.js +671 -0
- package/lib/console-capture.js +92 -0
- package/lib/console-reporter.js +438 -0
- package/lib/create-bom/built-in-plugins.js +12 -0
- package/lib/create-bom/create-bom.js +301 -0
- package/lib/dispatcher.js +9 -0
- package/lib/dist.js +222 -0
- package/lib/index.js +5 -0
- package/lib/launch-platform.js +439 -0
- package/lib/load-plugins.js +113 -0
- package/lib/platform/aws/aws-cloudwatch.js +106 -0
- package/lib/platform/aws/aws-create-sqs-queue.js +58 -0
- package/lib/platform/aws/aws-ensure-s3-bucket-exists.js +78 -0
- package/lib/platform/aws/aws-get-account-id.js +26 -0
- package/lib/platform/aws/aws-get-bucket-region.js +18 -0
- package/lib/platform/aws/aws-get-credentials.js +28 -0
- package/lib/platform/aws/aws-get-default-region.js +26 -0
- package/lib/platform/aws/aws-whoami.js +15 -0
- package/lib/platform/aws/constants.js +7 -0
- package/lib/platform/aws/iam-cf-templates/aws-iam-fargate-cf-template.yml +219 -0
- package/lib/platform/aws/iam-cf-templates/aws-iam-lambda-cf-template.yml +125 -0
- package/lib/platform/aws/iam-cf-templates/gh-oidc-fargate.yml +241 -0
- package/lib/platform/aws/iam-cf-templates/gh-oidc-lambda.yml +153 -0
- package/lib/platform/aws-ecs/ecs.js +247 -0
- package/lib/platform/aws-ecs/legacy/aws-util.js +134 -0
- package/lib/platform/aws-ecs/legacy/bom.js +528 -0
- package/lib/platform/aws-ecs/legacy/constants.js +27 -0
- package/lib/platform/aws-ecs/legacy/create-s3-client.js +24 -0
- package/lib/platform/aws-ecs/legacy/create-test.js +247 -0
- package/lib/platform/aws-ecs/legacy/errors.js +34 -0
- package/lib/platform/aws-ecs/legacy/find-public-subnets.js +149 -0
- package/lib/platform/aws-ecs/legacy/plugins/artillery-plugin-inspect-script/index.js +27 -0
- package/lib/platform/aws-ecs/legacy/plugins/artillery-plugin-sqs-reporter/azure-aqs.js +80 -0
- package/lib/platform/aws-ecs/legacy/plugins/artillery-plugin-sqs-reporter/index.js +202 -0
- package/lib/platform/aws-ecs/legacy/plugins.js +16 -0
- package/lib/platform/aws-ecs/legacy/run-cluster.js +1994 -0
- package/lib/platform/aws-ecs/legacy/sqs-reporter.js +401 -0
- package/lib/platform/aws-ecs/legacy/tags.js +22 -0
- package/lib/platform/aws-ecs/legacy/test-run-status.js +9 -0
- package/lib/platform/aws-ecs/legacy/time.js +67 -0
- package/lib/platform/aws-ecs/legacy/util.js +97 -0
- package/lib/platform/aws-ecs/worker/Dockerfile +64 -0
- package/lib/platform/aws-ecs/worker/helpers.sh +80 -0
- package/lib/platform/aws-ecs/worker/loadgen-worker +656 -0
- package/lib/platform/aws-lambda/dependencies.js +130 -0
- package/lib/platform/aws-lambda/index.js +734 -0
- package/lib/platform/aws-lambda/lambda-handler/a9-handler-dependencies.js +73 -0
- package/lib/platform/aws-lambda/lambda-handler/a9-handler-helpers.js +43 -0
- package/lib/platform/aws-lambda/lambda-handler/a9-handler-index.js +235 -0
- package/lib/platform/aws-lambda/lambda-handler/package.json +15 -0
- package/lib/platform/aws-lambda/prices.js +29 -0
- package/lib/platform/az/aci.js +694 -0
- package/lib/platform/az/aqs-queue-consumer.js +88 -0
- package/lib/platform/az/regions.js +52 -0
- package/lib/platform/cloud/api.js +72 -0
- package/lib/platform/cloud/cloud.js +448 -0
- package/lib/platform/cloud/http-client.js +19 -0
- package/lib/platform/local/artillery-worker-local.js +154 -0
- package/lib/platform/local/index.js +174 -0
- package/lib/platform/local/worker.js +261 -0
- package/lib/platform/worker-states.js +13 -0
- package/lib/queue-consumer/index.js +56 -0
- package/lib/stash.js +41 -0
- package/lib/telemetry.js +78 -0
- package/lib/util/await-on-ee.js +24 -0
- package/lib/util/generate-id.js +9 -0
- package/lib/util/parse-tag-string.js +21 -0
- package/lib/util/prepare-test-execution-plan.js +216 -0
- package/lib/util/sleep.js +7 -0
- package/lib/util/validate-script.js +132 -0
- package/lib/util.js +294 -0
- package/lib/utils-config.js +31 -0
- package/package.json +323 -0
- package/types.d.ts +317 -0
- package/util.js +1 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
4
|
+
|
|
5
|
+
const { SQSClient, SendMessageCommand } = require('@aws-sdk/client-sqs');
|
|
6
|
+
const { S3Client, PutObjectCommand } = require('@aws-sdk/client-s3');
|
|
7
|
+
const _debug = require('debug')('plugin:sqsReporter');
|
|
8
|
+
const uuid = require('node:crypto').randomUUID;
|
|
9
|
+
const { getAQS, sendMessage } = require('./azure-aqs');
|
|
10
|
+
|
|
11
|
+
// SQS has 1MB message limit. Use 950KB threshold for safety margin.
|
|
12
|
+
const SQS_SIZE_LIMIT = 950 * 1024;
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
Plugin: ArtillerySQSPlugin,
|
|
16
|
+
LEGACY_METRICS_FORMAT: false
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function ArtillerySQSPlugin(script, events) {
|
|
20
|
+
this.script = script;
|
|
21
|
+
this.events = events;
|
|
22
|
+
|
|
23
|
+
this.unsent = 0;
|
|
24
|
+
|
|
25
|
+
// List of objects: [{key: 'SomeKey', value: 'SomeValue'}, ...]
|
|
26
|
+
this.tags = process.env.SQS_TAGS ? JSON.parse(process.env.SQS_TAGS) : [];
|
|
27
|
+
this.testId = null;
|
|
28
|
+
const messageAttributes = {};
|
|
29
|
+
|
|
30
|
+
this.tags.forEach((tag) => {
|
|
31
|
+
if (tag.key === 'testId') {
|
|
32
|
+
this.testId = tag.value;
|
|
33
|
+
}
|
|
34
|
+
messageAttributes[tag.key] = {
|
|
35
|
+
DataType: 'String',
|
|
36
|
+
StringValue: tag.value
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
this.messageAttributes = messageAttributes;
|
|
41
|
+
|
|
42
|
+
this.sqs = null;
|
|
43
|
+
this.aqs = null;
|
|
44
|
+
|
|
45
|
+
if (process.env.SQS_QUEUE_URL) {
|
|
46
|
+
this.sqs = new SQSClient({
|
|
47
|
+
region:
|
|
48
|
+
process.env.SQS_REGION || script.config.plugins['sqs-reporter'].region
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
this.queueUrl =
|
|
52
|
+
process.env.SQS_QUEUE_URL ||
|
|
53
|
+
script.config.plugins['sqs-reporter'].queueUrl;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
this.s3 = null;
|
|
57
|
+
this.s3Bucket = process.env.ARTILLERY_S3_BUCKET || null;
|
|
58
|
+
if (this.sqs && this.s3Bucket) {
|
|
59
|
+
this.s3 = new S3Client({
|
|
60
|
+
region:
|
|
61
|
+
process.env.SQS_REGION || script.config.plugins['sqs-reporter'].region
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (process.env.AZURE_STORAGE_QUEUE_URL) {
|
|
66
|
+
this.aqs = getAQS();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
events.on('stats', (statsOriginal) => {
|
|
70
|
+
const serialized = global.artillery.__SSMS.serializeMetrics(statsOriginal);
|
|
71
|
+
const body = {
|
|
72
|
+
event: 'workerStats',
|
|
73
|
+
stats: serialized
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
this.sendMessage(body);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
//TODO: reconcile some of this code with how lambda does sqs reporting
|
|
80
|
+
events.on('phaseStarted', (phaseContext) => {
|
|
81
|
+
const body = {
|
|
82
|
+
event: 'phaseStarted',
|
|
83
|
+
phase: phaseContext
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
this.sendMessage(body);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
//TODO: reconcile some of this code with how lambda does sqs reporting
|
|
90
|
+
events.on('phaseCompleted', (phaseContext) => {
|
|
91
|
+
const body = {
|
|
92
|
+
event: 'phaseCompleted',
|
|
93
|
+
phase: phaseContext
|
|
94
|
+
};
|
|
95
|
+
this.sendMessage(body);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
events.on('done', (_stats) => {
|
|
99
|
+
const body = {
|
|
100
|
+
event: 'done',
|
|
101
|
+
stats: global.artillery.__SSMS.serializeMetrics(_stats)
|
|
102
|
+
};
|
|
103
|
+
this.sendMessage(body);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
global.artillery.globalEvents.on('log', (opts, ...args) => {
|
|
107
|
+
if (process.env.SHIP_LOGS) {
|
|
108
|
+
const body = {
|
|
109
|
+
event: 'artillery.log',
|
|
110
|
+
log: {
|
|
111
|
+
opts,
|
|
112
|
+
args: [...args]
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
this.sendMessage(body);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
return this;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
ArtillerySQSPlugin.prototype.cleanup = function (done) {
|
|
124
|
+
const interval = setInterval(() => {
|
|
125
|
+
if (this.unsent <= 0) {
|
|
126
|
+
clearInterval(interval);
|
|
127
|
+
done(null);
|
|
128
|
+
}
|
|
129
|
+
}, 200).unref();
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
ArtillerySQSPlugin.prototype.sendMessage = function (body) {
|
|
133
|
+
if (this.sqs) {
|
|
134
|
+
this.sendSQS(body);
|
|
135
|
+
} else {
|
|
136
|
+
this.sendAQS(body);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
ArtillerySQSPlugin.prototype.sendSQS = async function (body) {
|
|
141
|
+
this.unsent++;
|
|
142
|
+
|
|
143
|
+
const payload = JSON.stringify(body);
|
|
144
|
+
const payloadSize = Buffer.byteLength(payload, 'utf8');
|
|
145
|
+
|
|
146
|
+
try {
|
|
147
|
+
let messageBody = payload;
|
|
148
|
+
|
|
149
|
+
// Upload to S3 if payload exceeds SQS limit
|
|
150
|
+
if (payloadSize > SQS_SIZE_LIMIT && this.s3 && this.s3Bucket) {
|
|
151
|
+
const workerId = this.tags.find((t) => t.key === 'workerId')?.value;
|
|
152
|
+
const messageId = uuid();
|
|
153
|
+
const s3Key = `tests/${this.testId}/overflow/${workerId}/${messageId}.json`;
|
|
154
|
+
|
|
155
|
+
await this.s3.send(
|
|
156
|
+
new PutObjectCommand({
|
|
157
|
+
Bucket: this.s3Bucket,
|
|
158
|
+
Key: s3Key,
|
|
159
|
+
Body: payload,
|
|
160
|
+
ContentType: 'application/json'
|
|
161
|
+
})
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
messageBody = JSON.stringify({
|
|
165
|
+
event: body.event,
|
|
166
|
+
_overflowRef: s3Key
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
_debug(
|
|
170
|
+
'Payload %d bytes exceeded limit, uploaded to S3: %s',
|
|
171
|
+
payloadSize,
|
|
172
|
+
s3Key
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const params = {
|
|
177
|
+
MessageBody: messageBody,
|
|
178
|
+
QueueUrl: this.queueUrl,
|
|
179
|
+
MessageAttributes: this.messageAttributes,
|
|
180
|
+
MessageDeduplicationId: uuid(),
|
|
181
|
+
MessageGroupId: this.testId
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
await this.sqs.send(new SendMessageCommand(params));
|
|
185
|
+
} catch (err) {
|
|
186
|
+
console.error(err);
|
|
187
|
+
} finally {
|
|
188
|
+
this.unsent--;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
ArtillerySQSPlugin.prototype.sendAQS = async function (body) {
|
|
193
|
+
this.unsent++;
|
|
194
|
+
sendMessage(this.aqs, body, this.tags)
|
|
195
|
+
.then((_res) => {
|
|
196
|
+
this.unsent--;
|
|
197
|
+
})
|
|
198
|
+
.catch((err) => {
|
|
199
|
+
console.error(err);
|
|
200
|
+
this.unsent--;
|
|
201
|
+
});
|
|
202
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module.exports.getAllPluginNames = function () {
|
|
2
|
+
return [...this.getOfficialPlugins(), ...this.getProPlugins()];
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
module.exports.getOfficialPlugins = () => [
|
|
6
|
+
'ensure',
|
|
7
|
+
'expect',
|
|
8
|
+
'metrics-by-endpoint',
|
|
9
|
+
'publish-metrics',
|
|
10
|
+
'apdex',
|
|
11
|
+
'slack'
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
module.exports.getOfficialEngines = () => ['playwright'];
|
|
15
|
+
|
|
16
|
+
module.exports.getProPlugins = () => ['http-ssl-auth', 'http-file-uploads', 'sqs-reporter'];
|