GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: refactor test-cluster-disconnect · nodejs/node@b69cac7

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-cluster-disconnect.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-cluster-disconnect.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-cluster-disconnect.js
+8-27Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if (cluster.isWorker) {
2121
const socket = net.connect(port, '127.0.0.1', () => {
2222
// buffer result
2323
let result = '';
24-
socket.on('data', common.mustCall((chunk) => { result += chunk; }));
24+
socket.on('data', (chunk) => { result += chunk; });
2525

2626
// check result
2727
socket.on('end', common.mustCall(() => {
@@ -34,7 +34,7 @@ if (cluster.isWorker) {
3434
const testCluster = function(cb) {
3535
let done = 0;
3636

37-
for (let i = 0, l = servers; i < l; i++) {
37+
for (let i = 0; i < servers; i++) {
3838
testConnection(common.PORT + i, (success) => {
3939
assert.ok(success);
4040
done += 1;
@@ -60,40 +60,21 @@ if (cluster.isWorker) {
6060
}
6161
};
6262

63-
64-
const results = {
65-
start: 0,
66-
test: 0,
67-
disconnect: 0
68-
};
69-
7063
const test = function(again) {
7164
//1. start cluster
72-
startCluster(() => {
73-
results.start += 1;
74-
65+
startCluster(common.mustCall(() => {
7566
//2. test cluster
76-
testCluster(() => {
77-
results.test += 1;
78-
67+
testCluster(common.mustCall(() => {
7968
//3. disconnect cluster
80-
cluster.disconnect(() => {
81-
results.disconnect += 1;
82-
69+
cluster.disconnect(common.mustCall(() => {
8370
// run test again to confirm cleanup
8471
if (again) {
8572
test();
8673
}
87-
});
88-
});
89-
});
74+
}));
75+
}));
76+
}));
9077
};
9178

9279
test(true);
93-
94-
process.once('exit', () => {
95-
assert.strictEqual(results.start, 2);
96-
assert.strictEqual(results.test, 2);
97-
assert.strictEqual(results.disconnect, 2);
98-
});
9980
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.