testaro 5.17.0 → 5.17.2
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/create.js +32 -16
- package/package.json +1 -1
- package/tests/hover.js +5 -5
package/create.js
CHANGED
|
@@ -26,8 +26,10 @@ const timeoutHosts = [];
|
|
|
26
26
|
// ########## VARIABLES
|
|
27
27
|
|
|
28
28
|
let healthy = true;
|
|
29
|
+
// Set 5 minutes as a default time limit per host script.
|
|
29
30
|
let timeLimit = 300;
|
|
30
31
|
let reportCount = 0;
|
|
32
|
+
let specCount = Infinity;
|
|
31
33
|
|
|
32
34
|
// ########## FUNCTIONS
|
|
33
35
|
|
|
@@ -46,12 +48,19 @@ const runHost = async (id, script) => {
|
|
|
46
48
|
};
|
|
47
49
|
// Recursively runs host scripts.
|
|
48
50
|
const runHosts = async (timeStamp, specs) => {
|
|
49
|
-
|
|
51
|
+
if (specs.length >= specCount) {
|
|
52
|
+
console.log(`ERROR: Tried to run again with host count ${specs.length}`);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
specCount = specs.length;
|
|
57
|
+
}
|
|
58
|
+
// If any host scripts remain to be run and the process has not been interrupted:
|
|
50
59
|
if (specs.length && healthy) {
|
|
51
|
-
//
|
|
60
|
+
// Remove the first host script from the list.
|
|
52
61
|
const spec = specs.shift();
|
|
53
62
|
const {id, host, script} = spec;
|
|
54
|
-
// Fork a child process to run
|
|
63
|
+
// Fork a child process to run that host script.
|
|
55
64
|
const subprocess = fork(
|
|
56
65
|
'runHost', [id, JSON.stringify(script), JSON.stringify(host)],
|
|
57
66
|
{
|
|
@@ -60,18 +69,20 @@ const runHosts = async (timeStamp, specs) => {
|
|
|
60
69
|
}
|
|
61
70
|
);
|
|
62
71
|
let runMoreTimer = null;
|
|
63
|
-
//
|
|
72
|
+
// Let it run until it ends or, if the script or default time limit expires:
|
|
64
73
|
const timer = setTimeout(async () => {
|
|
65
74
|
clearTimeout(timer);
|
|
66
|
-
// Record the host as timed out.
|
|
75
|
+
// Record the host script as timed out.
|
|
67
76
|
timeoutHosts.push(id);
|
|
68
77
|
// Kill the child process.
|
|
69
78
|
subprocess.kill('SIGKILL');
|
|
70
|
-
console.log(`Script for host ${id}
|
|
71
|
-
//
|
|
79
|
+
console.log(`Script for host ${id} took more than ${timeLimit} seconds, so was killed`);
|
|
80
|
+
// Wait 10 seconds. Then:
|
|
72
81
|
runMoreTimer = setTimeout(async () => {
|
|
73
82
|
clearTimeout(runMoreTimer);
|
|
83
|
+
// If the timeout did not coincide with the termination of the script:
|
|
74
84
|
if (! (successHosts.includes(id) || crashHosts.includes(id))) {
|
|
85
|
+
// Run the remaining host scripts.
|
|
75
86
|
console.log('Continuing with the remaining host scripts');
|
|
76
87
|
await runHosts(timeStamp, specs);
|
|
77
88
|
}
|
|
@@ -91,15 +102,20 @@ const runHosts = async (timeStamp, specs) => {
|
|
|
91
102
|
});
|
|
92
103
|
// If the child process ends:
|
|
93
104
|
subprocess.on('exit', async () => {
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
-
clearTimeout(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
105
|
+
// Wait 5 seconds, then:
|
|
106
|
+
const postExitTimer = setTimeout(async () => {
|
|
107
|
+
clearTimeout(postExitTimer);
|
|
108
|
+
// If its end was not due to success or a timeout:
|
|
109
|
+
if (! (successHosts.includes(id) || timeoutHosts.includes(id))) {
|
|
110
|
+
clearTimeout(runMoreTimer);
|
|
111
|
+
clearTimeout(timer);
|
|
112
|
+
// Record the host as having crashed.
|
|
113
|
+
crashHosts.push(id);
|
|
114
|
+
console.log(`Script for host ${id} crashed`);
|
|
115
|
+
// Run the remaining host scripts.
|
|
116
|
+
await runHosts(timeStamp, specs);
|
|
117
|
+
}
|
|
118
|
+
}, 5000);
|
|
103
119
|
});
|
|
104
120
|
}
|
|
105
121
|
// Otherwise, i.e. if no more host scripts are to be run:
|
package/package.json
CHANGED
package/tests/hover.js
CHANGED
|
@@ -273,13 +273,13 @@ exports.reporter = async (page, sampleSize = -1, withItems) => {
|
|
|
273
273
|
data.totals.triggers = triggers.length;
|
|
274
274
|
// Get the sample.
|
|
275
275
|
const sample = getSample(triggers, sampleSize);
|
|
276
|
-
data.
|
|
277
|
-
// Set a time limit to cover possible
|
|
278
|
-
const timeLimit = Math.round(2.
|
|
276
|
+
data.totals.triggerSample = sample.length;
|
|
277
|
+
// Set a time limit to cover possible 2 seconds per trigger.
|
|
278
|
+
const timeLimit = Math.round(2.8 * sample.length + 2);
|
|
279
279
|
const timeout = setTimeout(async () => {
|
|
280
280
|
await page.close();
|
|
281
281
|
console.log(
|
|
282
|
-
`ERROR: hover test timed out at ${timeLimit} seconds; page closed`
|
|
282
|
+
`ERROR: hover test on sample of ${sample.length} triggers timed out at ${timeLimit} seconds; page closed`
|
|
283
283
|
);
|
|
284
284
|
hasTimedOut = true;
|
|
285
285
|
data = {
|
|
@@ -289,7 +289,7 @@ exports.reporter = async (page, sampleSize = -1, withItems) => {
|
|
|
289
289
|
clearTimeout(timeout);
|
|
290
290
|
}, 1000 * timeLimit);
|
|
291
291
|
// Find and document the impacts.
|
|
292
|
-
if (
|
|
292
|
+
if (sample.length && ! hasTimedOut) {
|
|
293
293
|
await find(data, withItems, page, sample);
|
|
294
294
|
}
|
|
295
295
|
clearTimeout(timeout);
|