artillery-plugin-slack 1.1.0 → 1.2.0-2af901e
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/index.js +10 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -9,7 +9,7 @@ class SlackPlugin {
|
|
|
9
9
|
this.script = script;
|
|
10
10
|
this.events = events;
|
|
11
11
|
|
|
12
|
-
if (process.env.LOCAL_WORKER_ID) {
|
|
12
|
+
if (process.env.LOCAL_WORKER_ID || process.env.WORKER_ID) {
|
|
13
13
|
debug('Running in a worker, exiting');
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
@@ -22,6 +22,7 @@ class SlackPlugin {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
if (global.artillery && global.artillery.cloudEnabled) {
|
|
25
|
+
debug('Artillery Cloud enabled, configuring Run URL');
|
|
25
26
|
this.cloudEnabled = true;
|
|
26
27
|
const baseUrl =
|
|
27
28
|
process.env.ARTILLERY_CLOUD_ENDPOINT || 'https://app.artillery.io';
|
|
@@ -41,7 +42,7 @@ class SlackPlugin {
|
|
|
41
42
|
passed: 0,
|
|
42
43
|
checkList: []
|
|
43
44
|
};
|
|
44
|
-
|
|
45
|
+
debug('Sorting and formatting ensure checks');
|
|
45
46
|
checkTests
|
|
46
47
|
.sort((a, b) => (a.result < b.result ? 1 : -1))
|
|
47
48
|
.forEach((check) => {
|
|
@@ -65,6 +66,7 @@ class SlackPlugin {
|
|
|
65
66
|
// When ensure is enabled, whether the beforeExit or the checks event will be triggered first will depend on the order of plugins in the test script
|
|
66
67
|
// Since we need data from both events, first event triggered will store the data and the second event will send the report
|
|
67
68
|
if (this.exitCode !== undefined && this.report && !this.reportSent) {
|
|
69
|
+
debug('Sending report from checks event');
|
|
68
70
|
await this.sendReport(this.report, this.ensureChecks);
|
|
69
71
|
this.reportSent = true;
|
|
70
72
|
}
|
|
@@ -78,6 +80,7 @@ class SlackPlugin {
|
|
|
78
80
|
if (this.ensureEnabled && !this.ensureChecks && !this.reportSent) {
|
|
79
81
|
this.report = opts.report;
|
|
80
82
|
} else {
|
|
83
|
+
debug('Sending report from beforeExit event');
|
|
81
84
|
await this.sendReport(opts.report, this.ensureChecks);
|
|
82
85
|
this.reportSent = true;
|
|
83
86
|
}
|
|
@@ -217,10 +220,14 @@ class SlackPlugin {
|
|
|
217
220
|
if (durationInMs < 1000) {
|
|
218
221
|
return `${durationInMs} miliseconds`;
|
|
219
222
|
}
|
|
223
|
+
const miliseconds = duration.get('millisecond');
|
|
220
224
|
const timeComponents = ['day', 'hour', 'minute', 'second'];
|
|
221
225
|
const formatedTimeComponents = timeComponents
|
|
222
226
|
.map((component) => {
|
|
223
|
-
|
|
227
|
+
let value = duration.get(component);
|
|
228
|
+
if (component === 'second' && miliseconds) {
|
|
229
|
+
value += 1;
|
|
230
|
+
}
|
|
224
231
|
return value
|
|
225
232
|
? `${value} ${value === 1 ? component : component + 's'}`
|
|
226
233
|
: '';
|