test: ensure that all worker servers are ready

Wait for the `'listening'` message from all workers before creating the
first connection. This fixes an `EMFILE` error that is raised on Windows
when running the following command

```
python tools/test.py -J --repeat=1000 parallel/test-tls-ticket-cluster
```

PR-URL: https://github.com/nodejs/node/pull/52563
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
Luigi Pinca
2024-04-19 05:17:19 -04:00
committed by GitHub
parent 91661ec08b
commit 580aae58f6

View File

@@ -33,10 +33,10 @@ const workerCount = 4;
const expectedReqCount = 16;
if (cluster.isPrimary) {
let listeningCount = 0;
let reusedCount = 0;
let reqCount = 0;
let lastSession = null;
let shootOnce = false;
let workerPort = null;
function shoot() {
@@ -73,9 +73,8 @@ if (cluster.isPrimary) {
console.error('[primary] got %j', msg);
if (msg === 'reused') {
++reusedCount;
} else if (msg === 'listening' && !shootOnce) {
workerPort = port || workerPort;
shootOnce = true;
} else if (msg === 'listening' && ++listeningCount === workerCount) {
workerPort = port;
shoot();
}
});