Skip to content

Commit

Permalink
test: ensure that all worker servers are ready
Browse files Browse the repository at this point in the history
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: #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>
  • Loading branch information
lpinca authored and marco-ippolito committed May 3, 2024
1 parent c871fad commit 6da558a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions test/parallel/test-tls-ticket-cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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();
}
});
Expand Down

0 comments on commit 6da558a

Please sign in to comment.