testeranto 0.47.30 → 0.47.32
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/dist/common/Node.js +13 -21
- package/dist/common/Project.js +228 -208
- package/dist/common/Web.js +59 -13
- package/dist/common/core.js +6 -1
- package/dist/common/electron.js +14 -2
- package/dist/common/preload.js +20 -0
- package/dist/common/subPackages/react/jsx/index.js +26 -0
- package/dist/common/subPackages/react/jsx/node.js +2 -11
- package/dist/common/subPackages/react/jsx/web.js +2 -11
- package/dist/common/subPackages/react-dom/component/node.js +78 -34
- package/dist/common/subPackages/react-dom/component/web.js +50 -46
- package/dist/common/subPackages/react-dom/jsx/node.js +101 -0
- package/dist/common/subPackages/react-test-renderer/component/index.js +78 -0
- package/dist/common/subPackages/react-test-renderer/component/node.js +8 -0
- package/dist/common/subPackages/react-test-renderer/component/web.js +8 -0
- package/dist/common/subPackages/{react-test-render/component/web.js → react-test-renderer/jsx/index.js} +3 -3
- package/dist/common/subPackages/react-test-renderer/jsx/node.js +10 -0
- package/dist/common/subPackages/react-test-renderer/jsx/web.js +10 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/Node.js +13 -21
- package/dist/module/Project.js +228 -208
- package/dist/module/Web.js +59 -13
- package/dist/module/core.js +6 -1
- package/dist/module/electron.js +14 -2
- package/dist/module/preload.js +20 -0
- package/dist/module/subPackages/react/jsx/index.js +22 -0
- package/dist/module/subPackages/react/jsx/node.js +2 -11
- package/dist/module/subPackages/react/jsx/web.js +2 -11
- package/dist/module/subPackages/react-dom/component/node.js +75 -34
- package/dist/module/subPackages/react-dom/component/web.js +50 -46
- package/dist/module/subPackages/react-dom/jsx/node.js +93 -0
- package/dist/module/subPackages/react-test-renderer/component/index.js +52 -0
- package/dist/module/subPackages/react-test-renderer/component/node.js +3 -0
- package/dist/module/subPackages/react-test-renderer/component/web.js +3 -0
- package/dist/module/subPackages/react-test-renderer/fc/node.js +22 -0
- package/dist/module/subPackages/{react-test-render/component/web.js → react-test-renderer/jsx/index.js} +2 -3
- package/dist/module/subPackages/react-test-renderer/jsx/node.js +5 -0
- package/dist/module/subPackages/react-test-renderer/jsx/web.js +5 -0
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/types/Project.d.ts +2 -1
- package/dist/types/core.d.ts +1 -0
- package/dist/types/subPackages/react/jsx/index.d.ts +15 -0
- package/dist/types/subPackages/react/jsx/node.d.ts +3 -10
- package/dist/types/subPackages/react/jsx/web.d.ts +3 -11
- package/dist/types/subPackages/react-dom/component/node.d.ts +9 -14
- package/dist/types/subPackages/react-dom/component/web.d.ts +1 -1
- package/dist/types/subPackages/react-dom/jsx/node.d.ts +14 -0
- package/dist/types/subPackages/react-dom/jsx/web.d.ts +0 -1
- package/dist/types/subPackages/react-test-renderer/component/index.d.ts +20 -0
- package/dist/types/subPackages/react-test-renderer/component/node.d.ts +9 -0
- package/dist/types/subPackages/react-test-renderer/component/web.d.ts +9 -0
- package/dist/types/subPackages/react-test-renderer/jsx/index.d.ts +15 -0
- package/dist/types/subPackages/react-test-renderer/jsx/node.d.ts +4 -0
- package/dist/types/subPackages/react-test-renderer/jsx/web.d.ts +4 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +71 -7
- package/src/Node.ts +18 -30
- package/src/Project.ts +292 -274
- package/src/Web.ts +78 -16
- package/src/core.ts +7 -1
- package/src/electron.ts +18 -2
- package/src/preload.ts +23 -0
- package/src/subPackages/react/jsx/index.ts +64 -0
- package/src/subPackages/react/jsx/node.ts +7 -36
- package/src/subPackages/react/jsx/web.ts +7 -38
- package/src/subPackages/react-dom/component/node.ts +85 -54
- package/src/subPackages/react-dom/component/web.ts +86 -76
- package/src/subPackages/react-dom/jsx/node.ts +150 -0
- package/src/subPackages/react-test-renderer/component/index.ts +101 -0
- package/src/subPackages/react-test-renderer/component/node.ts +30 -0
- package/src/subPackages/react-test-renderer/component/web.ts +30 -0
- package/src/subPackages/react-test-renderer/fc/node.tsx +77 -0
- package/src/subPackages/react-test-renderer/jsx/index.ts +51 -0
- package/src/subPackages/react-test-renderer/jsx/node.ts +31 -0
- package/src/subPackages/react-test-renderer/jsx/web.ts +31 -0
- package/dist/common/subPackages/react-test-render/component/node.js +0 -44
- package/dist/common/subPackages/react-test-render/jsx/node.js +0 -46
- package/dist/common/subPackages/react-test-render/jsx/web.js +0 -46
- package/dist/module/subPackages/react-test-render/component/node.js +0 -16
- package/dist/module/subPackages/react-test-render/jsx/node.js +0 -16
- package/dist/module/subPackages/react-test-render/jsx/web.js +0 -16
- package/dist/types/subPackages/react-test-render/component/node.d.ts +0 -19
- package/dist/types/subPackages/react-test-render/component/web.d.ts +0 -20
- package/dist/types/subPackages/react-test-render/jsx/node.d.ts +0 -20
- package/dist/types/subPackages/react-test-render/jsx/web.d.ts +0 -20
- package/src/subPackages/react-test-render/component/node.ts +0 -80
- package/src/subPackages/react-test-render/component/web.ts +0 -78
- package/src/subPackages/react-test-render/jsx/node.ts +0 -75
- package/src/subPackages/react-test-render/jsx/web.ts +0 -75
package/dist/module/Project.js
CHANGED
|
@@ -53,19 +53,19 @@ export class ITProject {
|
|
|
53
53
|
});
|
|
54
54
|
console.table(procsTable);
|
|
55
55
|
console.table(this.resourceQueue);
|
|
56
|
-
|
|
57
|
-
// console.log("resourceQueue", this.resourceQueue);
|
|
56
|
+
console.log("webSocketServer.clients", Object.keys(this.websockets));
|
|
58
57
|
const resourceRequest = this.resourceQueue.pop();
|
|
59
58
|
if (!resourceRequest) {
|
|
60
59
|
if (!this.devMode && this.mode === "up") {
|
|
61
60
|
this.initiateShutdown("resource request queue is empty");
|
|
62
61
|
}
|
|
63
|
-
if (this.mode === "down" &&
|
|
62
|
+
if (this.mode === "down" &&
|
|
63
|
+
(procsTable.every((p) => p.pid === 0 || p.pid === undefined) ||
|
|
64
|
+
procsTable.length === 0)) {
|
|
64
65
|
this.shutdown();
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
else {
|
|
68
|
-
console.log("handling", resourceRequest);
|
|
69
69
|
if (resourceRequest.protocol === "ipc") {
|
|
70
70
|
this.allocateViaIpc(resourceRequest);
|
|
71
71
|
}
|
|
@@ -89,13 +89,6 @@ export class ITProject {
|
|
|
89
89
|
console.log(this.spinner(), "Shutdown is in progress. Please wait.");
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
// console.log(this.spinner());
|
|
93
|
-
// console.log(
|
|
94
|
-
// this.spinner(),
|
|
95
|
-
// this.mode === `up`
|
|
96
|
-
// ? `press "q" to initiate graceful shutdown`
|
|
97
|
-
// : `please wait while testeranto shuts down gracefully...`
|
|
98
|
-
// );
|
|
99
92
|
});
|
|
100
93
|
};
|
|
101
94
|
this.clearScreen = config.clearScreen;
|
|
@@ -113,6 +106,12 @@ export class ITProject {
|
|
|
113
106
|
this.initiateShutdown("'q' command");
|
|
114
107
|
}
|
|
115
108
|
});
|
|
109
|
+
process.stdin.on('keypress', (str, key) => {
|
|
110
|
+
if (key.name === 'x') {
|
|
111
|
+
console.log("Shutting down hard!");
|
|
112
|
+
process.exit(-1);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
116
115
|
import(testPath).then((tests) => {
|
|
117
116
|
this.tests = tests.default;
|
|
118
117
|
import(featurePath).then((features) => {
|
|
@@ -181,6 +180,7 @@ export class ITProject {
|
|
|
181
180
|
setup(build) {
|
|
182
181
|
build.onEnd(result => {
|
|
183
182
|
console.log(`node build ended with ${result.errors.length} errors`);
|
|
183
|
+
console.log(result);
|
|
184
184
|
result.errors.length !== 0 && process.exit(-1);
|
|
185
185
|
// HERE: somehow restart the server from here, e.g., by sending a signal that you trap and react to inside the server.
|
|
186
186
|
});
|
|
@@ -230,6 +230,7 @@ export class ITProject {
|
|
|
230
230
|
setup(build) {
|
|
231
231
|
build.onEnd(result => {
|
|
232
232
|
console.log(`web build ended with ${result.errors.length} errors`);
|
|
233
|
+
console.log(result);
|
|
233
234
|
result.errors.length !== 0 && process.exit(-1);
|
|
234
235
|
// HERE: somehow restart the server from here, e.g., by sending a signal that you trap and react to inside the server.
|
|
235
236
|
});
|
|
@@ -286,141 +287,159 @@ export class ITProject {
|
|
|
286
287
|
esbuild.context(esbuildConfigWeb).then(async (esbuildWeb) => {
|
|
287
288
|
await esbuildWeb.watch();
|
|
288
289
|
})
|
|
289
|
-
])
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
process.exit(-1);
|
|
290
|
+
]).then(() => {
|
|
291
|
+
if (config.devMode === false) {
|
|
292
|
+
console.log("Your tests were built but not run because devMode was false. Exiting gracefully");
|
|
293
|
+
process.exit(0);
|
|
294
294
|
}
|
|
295
295
|
else {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
port: 8080,
|
|
301
|
-
host: "localhost",
|
|
302
|
-
});
|
|
303
|
-
webSocketServer.on('open', () => {
|
|
304
|
-
console.log('open');
|
|
305
|
-
// process.exit()
|
|
306
|
-
});
|
|
307
|
-
webSocketServer.on('close', (data) => {
|
|
308
|
-
console.log('webSocketServer close: %s', data);
|
|
309
|
-
// process.exit()
|
|
310
|
-
});
|
|
311
|
-
webSocketServer.on('listening', () => {
|
|
312
|
-
console.log("webSocketServer listening", webSocketServer.address());
|
|
313
|
-
// process.exit()
|
|
314
|
-
});
|
|
315
|
-
webSocketServer.on('connection', (webSocket) => {
|
|
316
|
-
console.log('webSocketServer connection');
|
|
317
|
-
webSocket.on('message', (webSocketData) => {
|
|
318
|
-
console.log('webSocket message: %s', webSocketData);
|
|
319
|
-
const payload = webSocketData.valueOf();
|
|
320
|
-
const name = payload.data.name;
|
|
321
|
-
const messageType = payload.type;
|
|
322
|
-
const requestedResources = payload.data;
|
|
323
|
-
this.websockets[name] = webSocket;
|
|
324
|
-
console.log('connected: ' + name + ' in ' + Object.getOwnPropertyNames(this.websockets));
|
|
325
|
-
if (messageType === "testeranto:hola") {
|
|
326
|
-
console.log("hola WS", requestedResources);
|
|
327
|
-
this.requestResource(requestedResources, 'ws');
|
|
296
|
+
pm2.connect(async (err) => {
|
|
297
|
+
if (err) {
|
|
298
|
+
console.error(err);
|
|
299
|
+
process.exit(-1);
|
|
328
300
|
}
|
|
329
|
-
else
|
|
330
|
-
console.log(
|
|
331
|
-
this.releaseTestResources(payload);
|
|
301
|
+
else {
|
|
302
|
+
console.log(`pm2 is connected`);
|
|
332
303
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
};
|
|
338
|
-
const bootInterval = setInterval(async () => {
|
|
339
|
-
const filesToLookup = this.tests
|
|
340
|
-
.map(([p, rt]) => {
|
|
341
|
-
const filepath = makePath(p, rt);
|
|
342
|
-
return {
|
|
343
|
-
filepath,
|
|
344
|
-
exists: fsExists(filepath),
|
|
345
|
-
};
|
|
346
|
-
});
|
|
347
|
-
const allFilesExist = (await Promise.all(filesToLookup.map((f) => f.exists))).every((b) => b);
|
|
348
|
-
if (!allFilesExist) {
|
|
349
|
-
console.log(this.spinner(), "waiting for files to build...");
|
|
350
|
-
filesToLookup.forEach((f) => {
|
|
351
|
-
console.log(f.exists, "\t", f.filepath);
|
|
304
|
+
// run a websocket as an alternative to node IPC
|
|
305
|
+
webSocketServer = new WebSocketServer({
|
|
306
|
+
port: 8080,
|
|
307
|
+
host: "localhost",
|
|
352
308
|
});
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
309
|
+
webSocketServer.on('open', () => {
|
|
310
|
+
console.log('open');
|
|
311
|
+
// process.exit()
|
|
312
|
+
});
|
|
313
|
+
webSocketServer.on('close', (data) => {
|
|
314
|
+
console.log('webSocketServer close: %s', data);
|
|
315
|
+
// process.exit()
|
|
316
|
+
});
|
|
317
|
+
webSocketServer.on('listening', () => {
|
|
318
|
+
console.log("webSocketServer listening", webSocketServer.address());
|
|
319
|
+
// process.exit()
|
|
320
|
+
});
|
|
321
|
+
webSocketServer.on('connection', (webSocket) => {
|
|
322
|
+
console.log('webSocketServer connection');
|
|
323
|
+
webSocket.on('message', (webSocketData) => {
|
|
324
|
+
// console.log('webSocket message: %s', webSocketData);
|
|
325
|
+
const payload = JSON.parse(webSocketData.valueOf().toString());
|
|
326
|
+
// console.log('webSocket payload', JSON.stringify(payload.data.testResourceConfiguration.name, null, 2));
|
|
327
|
+
// as {
|
|
328
|
+
// type: string,
|
|
329
|
+
// data: ITTestResourceRequirement & {
|
|
330
|
+
// testResourceConfiguration: {
|
|
331
|
+
// name: string;
|
|
332
|
+
// }
|
|
333
|
+
// }
|
|
334
|
+
// };
|
|
335
|
+
const messageType = payload.type;
|
|
336
|
+
if (messageType === "testeranto:hola") {
|
|
337
|
+
const name = payload.data.requirement.name;
|
|
338
|
+
const requestedResources = payload.data;
|
|
339
|
+
this.websockets[name] = webSocket;
|
|
340
|
+
console.log('hola WS! connected: ' + name + ' in ' + Object.getOwnPropertyNames(this.websockets));
|
|
341
|
+
this.requestResource(requestedResources.requirement, 'ws');
|
|
342
|
+
}
|
|
343
|
+
else if (messageType === "testeranto:adios") {
|
|
344
|
+
console.log("adios WS", payload.data.testResourceConfiguration.name);
|
|
345
|
+
this.releaseTestResourceWs(payload);
|
|
346
|
+
}
|
|
364
347
|
});
|
|
365
348
|
});
|
|
366
|
-
|
|
367
|
-
.
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
pm2.start({
|
|
384
|
-
script: `yarn electron node_modules/testeranto/dist/common/electron.js ${htmlFile} '${JSON.stringify({
|
|
385
|
-
name: inputFilePath,
|
|
386
|
-
ports: [],
|
|
387
|
-
fs: path.resolve(process.cwd(), config.outdir, inputFilePath),
|
|
388
|
-
})}'`,
|
|
389
|
-
name: inputFilePath,
|
|
390
|
-
autorestart: false,
|
|
391
|
-
args: partialTestResourceByCommandLineArg,
|
|
392
|
-
watch: [jsFile],
|
|
393
|
-
}, (err, proc) => {
|
|
394
|
-
if (err) {
|
|
395
|
-
console.error(err);
|
|
396
|
-
return pm2.disconnect();
|
|
397
|
-
}
|
|
349
|
+
const makePath = (fPath, rt) => {
|
|
350
|
+
return path.resolve("./" + config.outdir + "/" + fPath.replace(path.extname(fPath), "") + ".mjs");
|
|
351
|
+
};
|
|
352
|
+
const bootInterval = setInterval(async () => {
|
|
353
|
+
const filesToLookup = this.tests
|
|
354
|
+
.map(([p, rt]) => {
|
|
355
|
+
const filepath = makePath(p, rt);
|
|
356
|
+
return {
|
|
357
|
+
filepath,
|
|
358
|
+
exists: fsExists(filepath),
|
|
359
|
+
};
|
|
360
|
+
});
|
|
361
|
+
const allFilesExist = (await Promise.all(filesToLookup.map((f) => f.exists))).every((b) => b);
|
|
362
|
+
if (!allFilesExist) {
|
|
363
|
+
console.log(this.spinner(), "waiting for files to build...");
|
|
364
|
+
filesToLookup.forEach((f) => {
|
|
365
|
+
console.log(f.exists, "\t", f.filepath);
|
|
398
366
|
});
|
|
399
367
|
}
|
|
400
|
-
else
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
368
|
+
else {
|
|
369
|
+
clearInterval(bootInterval);
|
|
370
|
+
pm2.launchBus((err, pm2_bus) => {
|
|
371
|
+
pm2_bus.on("testeranto:hola", (packet) => {
|
|
372
|
+
console.log("hola IPC", packet);
|
|
373
|
+
this.requestResource(packet.data.requirement, 'ipc');
|
|
374
|
+
});
|
|
375
|
+
pm2_bus.on("testeranto:adios", (payload) => {
|
|
376
|
+
this.releaseTestResourcePm2(payload.data);
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
this
|
|
380
|
+
.tests
|
|
381
|
+
.reduce((m, [inputFilePath, runtime]) => {
|
|
382
|
+
const script = makePath(inputFilePath, runtime);
|
|
383
|
+
const partialTestResourceByCommandLineArg = `${script} '${JSON.stringify({
|
|
404
384
|
name: inputFilePath,
|
|
405
385
|
ports: [],
|
|
406
386
|
fs: path.resolve(process.cwd(), config.outdir, inputFilePath),
|
|
407
|
-
})}'
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
387
|
+
})}'`;
|
|
388
|
+
if (runtime === "web") {
|
|
389
|
+
const fileAsList = inputFilePath.split("/");
|
|
390
|
+
const fileListHead = fileAsList.slice(0, -1);
|
|
391
|
+
const fname = fileAsList[fileAsList.length - 1];
|
|
392
|
+
const fnameOnly = fname.split(".").slice(0, -1).join(".");
|
|
393
|
+
const htmlFile = [config.outdir, ...fileListHead, `${fnameOnly}.html`].join("/");
|
|
394
|
+
const jsFile = path.resolve(htmlFile.split(".html")[0] + ".mjs");
|
|
395
|
+
console.log("watching", jsFile);
|
|
396
|
+
pm2.start({
|
|
397
|
+
script: `yarn electron node_modules/testeranto/dist/common/electron.js ${htmlFile} '${JSON.stringify({
|
|
398
|
+
scheduled: true,
|
|
399
|
+
name: inputFilePath,
|
|
400
|
+
ports: [],
|
|
401
|
+
fs: path.resolve(process.cwd(), config.outdir, inputFilePath),
|
|
402
|
+
})}'`,
|
|
403
|
+
name: inputFilePath,
|
|
404
|
+
autorestart: false,
|
|
405
|
+
args: partialTestResourceByCommandLineArg,
|
|
406
|
+
watch: [jsFile],
|
|
407
|
+
}, (err, proc) => {
|
|
408
|
+
if (err) {
|
|
409
|
+
console.error(err);
|
|
410
|
+
return pm2.disconnect();
|
|
411
|
+
}
|
|
412
|
+
});
|
|
415
413
|
}
|
|
416
|
-
|
|
414
|
+
else if (runtime === "node") {
|
|
415
|
+
const resolvedPath = path.resolve(script);
|
|
416
|
+
console.log("watching", resolvedPath);
|
|
417
|
+
pm2.start({
|
|
418
|
+
name: inputFilePath,
|
|
419
|
+
script: `node ${resolvedPath} '${JSON.stringify({
|
|
420
|
+
scheduled: true,
|
|
421
|
+
name: inputFilePath,
|
|
422
|
+
ports: [],
|
|
423
|
+
fs: path.resolve(process.cwd(), config.outdir, inputFilePath),
|
|
424
|
+
})}'`,
|
|
425
|
+
autorestart: false,
|
|
426
|
+
watch: [resolvedPath],
|
|
427
|
+
args: partialTestResourceByCommandLineArg
|
|
428
|
+
}, (err, proc) => {
|
|
429
|
+
if (err) {
|
|
430
|
+
console.error(err);
|
|
431
|
+
return pm2.disconnect();
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
this.exitCodes[inputFilePath] = null;
|
|
436
|
+
return [inputFilePath, ...m];
|
|
437
|
+
}, []);
|
|
438
|
+
setInterval(this.mainLoop, TIMEOUT).unref();
|
|
417
439
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
setInterval(this.mainLoop, TIMEOUT).unref();
|
|
422
|
-
}
|
|
423
|
-
}, TIMEOUT).unref();
|
|
440
|
+
}, TIMEOUT).unref();
|
|
441
|
+
});
|
|
442
|
+
}
|
|
424
443
|
});
|
|
425
444
|
});
|
|
426
445
|
});
|
|
@@ -444,21 +463,54 @@ export class ITProject {
|
|
|
444
463
|
this.mode = "down";
|
|
445
464
|
}
|
|
446
465
|
shutdown() {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
466
|
+
let i = 0;
|
|
467
|
+
new Promise((res, reh) => {
|
|
468
|
+
console.log("final results: ");
|
|
469
|
+
const procsTable = [];
|
|
470
|
+
pm2.list((err, procs) => {
|
|
471
|
+
procs.forEach((proc, ndx) => {
|
|
472
|
+
const exitCode = this.exitCodes[proc.name];
|
|
473
|
+
if (exitCode !== 0) {
|
|
474
|
+
i++;
|
|
475
|
+
}
|
|
476
|
+
procsTable.push({
|
|
477
|
+
name: proc.name,
|
|
478
|
+
pm_id: proc.pm_id,
|
|
479
|
+
exitCode
|
|
480
|
+
});
|
|
481
|
+
if (ndx === procs.length - 1) {
|
|
482
|
+
console.table(procsTable);
|
|
483
|
+
res(i);
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
});
|
|
487
|
+
}).then((failures) => {
|
|
488
|
+
console.log("Stopping PM2");
|
|
489
|
+
pm2.stop("all", (e) => console.error(e));
|
|
490
|
+
// pm2.killDaemon((e) => console.error(e));
|
|
491
|
+
pm2.disconnect();
|
|
492
|
+
console.log(`gracefully exiting with ${failures} failures`);
|
|
493
|
+
process.exit(failures);
|
|
494
|
+
});
|
|
452
495
|
}
|
|
453
496
|
spinner() {
|
|
454
497
|
this.spinCycle = (this.spinCycle + 1) % this.spinAnimation.length;
|
|
455
498
|
return this.spinAnimation[this.spinCycle];
|
|
456
499
|
}
|
|
457
|
-
async
|
|
500
|
+
async releaseTestResourceWs(payload) {
|
|
501
|
+
const name = payload.data.testResourceConfiguration.name;
|
|
502
|
+
const failed = payload.data.failed;
|
|
503
|
+
this.exitCodes[name] = failed;
|
|
504
|
+
Object.keys(this.ports).forEach((port) => {
|
|
505
|
+
if (this.ports[port] === name) {
|
|
506
|
+
this.ports[port] = OPEN_PORT;
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
async releaseTestResourcePm2(payload) {
|
|
458
511
|
const name = payload.testResourceConfiguration.name;
|
|
459
512
|
const failed = payload.failed;
|
|
460
|
-
|
|
461
|
-
// reset ports
|
|
513
|
+
this.exitCodes[name] = failed;
|
|
462
514
|
pm2.list((err, processes) => {
|
|
463
515
|
processes.forEach((proc) => {
|
|
464
516
|
if (proc.name === name) {
|
|
@@ -470,86 +522,55 @@ export class ITProject {
|
|
|
470
522
|
}
|
|
471
523
|
});
|
|
472
524
|
});
|
|
473
|
-
this.exitCodes[name] = failed;
|
|
474
525
|
}
|
|
475
526
|
allocateViaWs(resourceRequest) {
|
|
476
|
-
const
|
|
527
|
+
const name = resourceRequest.requirement.name;
|
|
477
528
|
const testResourceRequirement = resourceRequest.requirement;
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
529
|
+
const websocket = this.websockets[name];
|
|
530
|
+
if ((testResourceRequirement === null || testResourceRequirement === void 0 ? void 0 : testResourceRequirement.ports) === 0) {
|
|
531
|
+
websocket.send(JSON.stringify({
|
|
532
|
+
data: {
|
|
533
|
+
testResourceConfiguration: {
|
|
534
|
+
ports: [],
|
|
535
|
+
},
|
|
536
|
+
}
|
|
537
|
+
}));
|
|
538
|
+
}
|
|
539
|
+
else if (((testResourceRequirement === null || testResourceRequirement === void 0 ? void 0 : testResourceRequirement.ports) || 0) > 0) {
|
|
540
|
+
// clear any port-slots associated with this job
|
|
541
|
+
Object.values(this.ports).forEach((jobMaybe, portNumber) => {
|
|
542
|
+
if (jobMaybe && jobMaybe === name) {
|
|
543
|
+
this.ports[portNumber] = OPEN_PORT;
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
// find a list of open ports
|
|
547
|
+
const foundOpenPorts = Object.keys(this.ports).filter((p) => this.ports[p] === OPEN_PORT);
|
|
548
|
+
if (foundOpenPorts.length >= testResourceRequirement.ports) {
|
|
549
|
+
const selectionOfPorts = foundOpenPorts.slice(0, testResourceRequirement.ports);
|
|
550
|
+
websocket.send(JSON.stringify({
|
|
551
|
+
data: {
|
|
552
|
+
testResourceConfiguration: {
|
|
553
|
+
ports: selectionOfPorts,
|
|
494
554
|
},
|
|
495
|
-
};
|
|
496
|
-
if ((testResourceRequirement === null || testResourceRequirement === void 0 ? void 0 : testResourceRequirement.ports) === 0) {
|
|
497
|
-
pm2.sendDataToProcessId(p.pid, message, function (err, res) {
|
|
498
|
-
// console.log("sendDataToProcessId", err, res, message);
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
if (((testResourceRequirement === null || testResourceRequirement === void 0 ? void 0 : testResourceRequirement.ports) || 0) > 0) {
|
|
502
|
-
// clear any port-slots associated with this job
|
|
503
|
-
Object.values(this.ports).forEach((jobMaybe, portNumber) => {
|
|
504
|
-
if (jobMaybe && jobMaybe === pName) {
|
|
505
|
-
this.ports[portNumber] = OPEN_PORT;
|
|
506
|
-
}
|
|
507
|
-
});
|
|
508
|
-
// find a list of open ports
|
|
509
|
-
const foundOpenPorts = Object.keys(this.ports).filter((p) => this.ports[p] === OPEN_PORT);
|
|
510
|
-
// if there are enough open port-slots...
|
|
511
|
-
if (foundOpenPorts.length >= testResourceRequirement.ports) {
|
|
512
|
-
const selectionOfPorts = foundOpenPorts.slice(0, testResourceRequirement.ports);
|
|
513
|
-
const message = {
|
|
514
|
-
// these fields must be present
|
|
515
|
-
id: p.pid,
|
|
516
|
-
topic: "some topic",
|
|
517
|
-
// process:msg will be send as 'message' on target process
|
|
518
|
-
type: "process:msg",
|
|
519
|
-
// Data to be sent
|
|
520
|
-
data: {
|
|
521
|
-
testResourceConfiguration: {
|
|
522
|
-
// fs: fPath,
|
|
523
|
-
ports: selectionOfPorts,
|
|
524
|
-
},
|
|
525
|
-
id: p.pid,
|
|
526
|
-
},
|
|
527
|
-
};
|
|
528
|
-
pm2.sendDataToProcessId(p.pid, message, function (err, res) {
|
|
529
|
-
// no-op
|
|
530
|
-
});
|
|
531
|
-
// mark the selected ports as occupied
|
|
532
|
-
for (const foundOpenPort of selectionOfPorts) {
|
|
533
|
-
this.ports[foundOpenPort] = p.pid.toString();
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
else {
|
|
537
|
-
console.log(`no port was open so send the ${p.pid} job to the back of the resourceQueue`);
|
|
538
|
-
this.resourceQueue.push(resourceRequest);
|
|
539
|
-
}
|
|
540
555
|
}
|
|
556
|
+
}));
|
|
557
|
+
// mark the selected ports as occupied
|
|
558
|
+
for (const foundOpenPort of selectionOfPorts) {
|
|
559
|
+
this.ports[foundOpenPort] = name;
|
|
541
560
|
}
|
|
542
|
-
}
|
|
543
|
-
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
console.log(`no port was open so send the ${name} job to the back of the resourceQueue`);
|
|
564
|
+
this.resourceQueue.push(resourceRequest);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
544
567
|
}
|
|
545
568
|
allocateViaIpc(resourceRequest) {
|
|
546
|
-
console.log("allocateViaIpc", resourceRequest);
|
|
547
569
|
const pName = resourceRequest.requirement.name;
|
|
548
570
|
const testResourceRequirement = resourceRequest.requirement;
|
|
549
571
|
pm2.list((err, processes) => {
|
|
550
572
|
console.error(err);
|
|
551
573
|
processes.forEach((p) => {
|
|
552
|
-
console.log("p.pid, p.name, p.pm_id", p.pid, p.name, p.pm_id);
|
|
553
574
|
if (p.name === pName && p.pid) {
|
|
554
575
|
const message = {
|
|
555
576
|
// these fields must be present
|
|
@@ -565,7 +586,6 @@ export class ITProject {
|
|
|
565
586
|
id: p.pm_id,
|
|
566
587
|
},
|
|
567
588
|
};
|
|
568
|
-
console.log("message", message);
|
|
569
589
|
if ((testResourceRequirement === null || testResourceRequirement === void 0 ? void 0 : testResourceRequirement.ports) === 0) {
|
|
570
590
|
pm2.sendDataToProcessId(p.pm_id, message, function (err, res) {
|
|
571
591
|
// console.log("sendDataToProcessId", err, res, message);
|
package/dist/module/Web.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { defaultTestResourceRequirement, } from "./core";
|
|
2
2
|
import TesterantoLevelTwo from "./core";
|
|
3
|
-
// import { ipcRenderer } from "electron";
|
|
4
3
|
const webSocket = new WebSocket("ws://localhost:8080");
|
|
5
|
-
const
|
|
4
|
+
const receiveTestResourceConfigUnscheduled = async (t, testresource) => {
|
|
5
|
+
const { failed, artifacts, logPromise } = await t.receiveTestResourceConfig(testresource);
|
|
6
|
+
Promise.all([...artifacts, logPromise]).then(async () => {
|
|
7
|
+
// ipcRenderer.invoke('quit-app', failed);
|
|
8
|
+
window.exit(failed);
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
const receiveTestResourceConfigScheduled = async (t, testresource) => {
|
|
6
12
|
const { failed, artifacts, logPromise } = await t.receiveTestResourceConfig(testresource);
|
|
7
13
|
webSocket.send(JSON.stringify({
|
|
8
14
|
type: "testeranto:adios",
|
|
@@ -30,12 +36,10 @@ export default async (input, testSpecification, testImplementation, testInterfac
|
|
|
30
36
|
const testResourceArg = decodeURIComponent(new URLSearchParams(location.search).get('requesting') || '');
|
|
31
37
|
try {
|
|
32
38
|
const partialTestResource = JSON.parse(testResourceArg);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
console.log("test configuration is incomplete", partialTestResource);
|
|
38
|
-
console.log("requesting test resources via ws", testResourceRequirement);
|
|
39
|
+
console.log("initial test resource", partialTestResource);
|
|
40
|
+
if (partialTestResource.scheduled) {
|
|
41
|
+
console.log("test is scheduled");
|
|
42
|
+
console.log("awaiting test resources via WS...");
|
|
39
43
|
webSocket.addEventListener("open", (event) => {
|
|
40
44
|
webSocket.addEventListener("message", (event) => {
|
|
41
45
|
console.log("Message from server ", event.data);
|
|
@@ -43,20 +47,62 @@ export default async (input, testSpecification, testImplementation, testInterfac
|
|
|
43
47
|
const r = JSON.stringify({
|
|
44
48
|
type: "testeranto:hola",
|
|
45
49
|
data: {
|
|
46
|
-
testResourceRequirement,
|
|
50
|
+
requirement: Object.assign(Object.assign({}, testResourceRequirement), { name: partialTestResource.name })
|
|
47
51
|
},
|
|
48
52
|
});
|
|
49
53
|
webSocket.send(r);
|
|
50
54
|
console.log("awaiting test resources via websocket...", r);
|
|
51
55
|
webSocket.onmessage = (async (msg) => {
|
|
52
56
|
console.log("message: ", msg);
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
const resourcesFromWs = JSON.parse(msg.data);
|
|
58
|
+
console.log("secondary test resource", resourcesFromWs);
|
|
59
|
+
const secondTestResource = Object.assign(Object.assign({ fs: "." }, JSON.parse(JSON.stringify(partialTestResource))), JSON.parse(JSON.stringify(resourcesFromWs)));
|
|
60
|
+
console.log("final test resource", secondTestResource);
|
|
61
|
+
receiveTestResourceConfigScheduled(t, secondTestResource);
|
|
57
62
|
});
|
|
58
63
|
});
|
|
59
64
|
}
|
|
65
|
+
else {
|
|
66
|
+
receiveTestResourceConfigUnscheduled(t, partialTestResource);
|
|
67
|
+
}
|
|
68
|
+
// const partialTestResource = JSON.parse(
|
|
69
|
+
// testResourceArg
|
|
70
|
+
// ) as ITTestResourceConfiguration;
|
|
71
|
+
// if (partialTestResource.fs && partialTestResource.ports) {
|
|
72
|
+
// receiveTestResourceConfig(t, partialTestResource);
|
|
73
|
+
// } else {
|
|
74
|
+
// console.log("test configuration is incomplete", partialTestResource);
|
|
75
|
+
// console.log(
|
|
76
|
+
// "requesting test resources via ws",
|
|
77
|
+
// testResourceRequirement
|
|
78
|
+
// );
|
|
79
|
+
// webSocket.addEventListener("open", (event) => {
|
|
80
|
+
// webSocket.addEventListener("message", (event) => {
|
|
81
|
+
// console.log("Message from server ", event.data);
|
|
82
|
+
// });
|
|
83
|
+
// const r = JSON.stringify({
|
|
84
|
+
// type: "testeranto:hola",
|
|
85
|
+
// data: {
|
|
86
|
+
// testResourceRequirement,
|
|
87
|
+
// },
|
|
88
|
+
// });
|
|
89
|
+
// webSocket.send(r);
|
|
90
|
+
// console.log("awaiting test resources via websocket...", r);
|
|
91
|
+
// webSocket.onmessage = (
|
|
92
|
+
// async (msg: MessageEvent<any>) => {
|
|
93
|
+
// console.log("message: ", msg);
|
|
94
|
+
// const resourcesFromPm2 = msg.data.testResourceConfiguration;
|
|
95
|
+
// const secondTestResource = {
|
|
96
|
+
// fs: ".",
|
|
97
|
+
// ...JSON.parse(JSON.stringify(partialTestResource)),
|
|
98
|
+
// ...JSON.parse(JSON.stringify(resourcesFromPm2)),
|
|
99
|
+
// } as ITTestResourceConfiguration;
|
|
100
|
+
// console.log("secondTestResource", secondTestResource);
|
|
101
|
+
// receiveTestResourceConfig(t, secondTestResource);
|
|
102
|
+
// }
|
|
103
|
+
// );
|
|
104
|
+
// });
|
|
105
|
+
// }
|
|
60
106
|
}
|
|
61
107
|
catch (e) {
|
|
62
108
|
console.error(e);
|