From 0009faad0944407b84e127054e8b3f8d7a4ada95 Mon Sep 17 00:00:00 2001 From: Deokjin Kim Date: Thu, 29 Dec 2022 10:38:04 +0900 Subject: [PATCH] test: use `os.availableParallelism()` Refs: https://github.com/nodejs/node/pull/45895 PR-URL: https://github.com/nodejs/node/pull/46003 Reviewed-By: Moshe Atlow Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Yagiz Nizipli --- test/parallel/test-cluster-concurrent-disconnect.js | 2 +- test/parallel/test-gc-http-client-connaborted.js | 2 +- test/parallel/test-gc-net-timeout.js | 2 +- test/parallel/test-worker-memory.js | 2 +- test/pummel/test-policy-integrity-dep.js | 2 +- test/pummel/test-policy-integrity-parent-commonjs.js | 2 +- test/pummel/test-policy-integrity-parent-module.js | 2 +- test/pummel/test-policy-integrity-parent-no-package-json.js | 2 +- test/pummel/test-policy-integrity-worker-commonjs.js | 2 +- test/pummel/test-policy-integrity-worker-module.js | 2 +- test/pummel/test-policy-integrity-worker-no-package-json.js | 2 +- test/sequential/test-gc-http-client-onerror.js | 2 +- test/sequential/test-gc-http-client-timeout.js | 2 +- test/sequential/test-gc-http-client.js | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/parallel/test-cluster-concurrent-disconnect.js b/test/parallel/test-cluster-concurrent-disconnect.js index e3771a0a4fdcb0..c2ba7b43447733 100644 --- a/test/parallel/test-cluster-concurrent-disconnect.js +++ b/test/parallel/test-cluster-concurrent-disconnect.js @@ -10,7 +10,7 @@ const os = require('os'); if (cluster.isPrimary) { const workers = []; - const numCPUs = os.cpus().length; + const numCPUs = os.availableParallelism(); let waitOnline = numCPUs; for (let i = 0; i < numCPUs; i++) { const worker = cluster.fork(); diff --git a/test/parallel/test-gc-http-client-connaborted.js b/test/parallel/test-gc-http-client-connaborted.js index fd276d30e2beb1..e9282653f2c132 100644 --- a/test/parallel/test-gc-http-client-connaborted.js +++ b/test/parallel/test-gc-http-client-connaborted.js @@ -8,7 +8,7 @@ const onGC = require('../common/ongc'); const http = require('http'); const os = require('os'); -const cpus = os.cpus().length; +const cpus = os.availableParallelism(); let createClients = true; let done = 0; let count = 0; diff --git a/test/parallel/test-gc-net-timeout.js b/test/parallel/test-gc-net-timeout.js index 6b9d51c98d0e84..dfb2bbfd92ac55 100644 --- a/test/parallel/test-gc-net-timeout.js +++ b/test/parallel/test-gc-net-timeout.js @@ -26,7 +26,7 @@ function serverHandler(sock) { }, 100); } -const cpus = os.cpus().length; +const cpus = os.availableParallelism(); let createClients = true; let done = 0; let count = 0; diff --git a/test/parallel/test-worker-memory.js b/test/parallel/test-worker-memory.js index 19b89d4321d6d7..8c38409a26bab1 100644 --- a/test/parallel/test-worker-memory.js +++ b/test/parallel/test-worker-memory.js @@ -7,7 +7,7 @@ const assert = require('assert'); const util = require('util'); const { Worker } = require('worker_threads'); -let numWorkers = +process.env.JOBS || require('os').cpus().length; +let numWorkers = +process.env.JOBS || require('os').availableParallelism(); if (numWorkers > 20) { // Cap the number of workers at 20 (as an even divisor of 60 used as // the total number of workers started) otherwise the test fails on diff --git a/test/pummel/test-policy-integrity-dep.js b/test/pummel/test-policy-integrity-dep.js index 02f24d02a23544..cbccc60cdb4468 100644 --- a/test/pummel/test-policy-integrity-dep.js +++ b/test/pummel/test-policy-integrity-dep.js @@ -22,7 +22,7 @@ const fs = require('fs'); const path = require('path'); const { pathToFileURL } = require('url'); -const cpus = require('os').cpus().length; +const cpus = require('os').availableParallelism(); function hash(algo, body) { const values = []; diff --git a/test/pummel/test-policy-integrity-parent-commonjs.js b/test/pummel/test-policy-integrity-parent-commonjs.js index 425abe38ebd9fb..2e77786e3b925f 100644 --- a/test/pummel/test-policy-integrity-parent-commonjs.js +++ b/test/pummel/test-policy-integrity-parent-commonjs.js @@ -22,7 +22,7 @@ const fs = require('fs'); const path = require('path'); const { pathToFileURL } = require('url'); -const cpus = require('os').cpus().length; +const cpus = require('os').availableParallelism(); function hash(algo, body) { const values = []; diff --git a/test/pummel/test-policy-integrity-parent-module.js b/test/pummel/test-policy-integrity-parent-module.js index dda800dc3652fc..1c1c8cbbb47cd8 100644 --- a/test/pummel/test-policy-integrity-parent-module.js +++ b/test/pummel/test-policy-integrity-parent-module.js @@ -22,7 +22,7 @@ const fs = require('fs'); const path = require('path'); const { pathToFileURL } = require('url'); -const cpus = require('os').cpus().length; +const cpus = require('os').availableParallelism(); function hash(algo, body) { const values = []; diff --git a/test/pummel/test-policy-integrity-parent-no-package-json.js b/test/pummel/test-policy-integrity-parent-no-package-json.js index a722263e1e484a..012b2228d3eb98 100644 --- a/test/pummel/test-policy-integrity-parent-no-package-json.js +++ b/test/pummel/test-policy-integrity-parent-no-package-json.js @@ -22,7 +22,7 @@ const fs = require('fs'); const path = require('path'); const { pathToFileURL } = require('url'); -const cpus = require('os').cpus().length; +const cpus = require('os').availableParallelism(); function hash(algo, body) { const values = []; diff --git a/test/pummel/test-policy-integrity-worker-commonjs.js b/test/pummel/test-policy-integrity-worker-commonjs.js index b5d49222a2f01c..bfa24cd8fd407b 100644 --- a/test/pummel/test-policy-integrity-worker-commonjs.js +++ b/test/pummel/test-policy-integrity-worker-commonjs.js @@ -22,7 +22,7 @@ const fs = require('fs'); const path = require('path'); const { pathToFileURL } = require('url'); -const cpus = require('os').cpus().length; +const cpus = require('os').availableParallelism(); function hash(algo, body) { const values = []; diff --git a/test/pummel/test-policy-integrity-worker-module.js b/test/pummel/test-policy-integrity-worker-module.js index a8a4fb2c29589f..e51e24be45883e 100644 --- a/test/pummel/test-policy-integrity-worker-module.js +++ b/test/pummel/test-policy-integrity-worker-module.js @@ -22,7 +22,7 @@ const fs = require('fs'); const path = require('path'); const { pathToFileURL } = require('url'); -const cpus = require('os').cpus().length; +const cpus = require('os').availableParallelism(); function hash(algo, body) { const values = []; diff --git a/test/pummel/test-policy-integrity-worker-no-package-json.js b/test/pummel/test-policy-integrity-worker-no-package-json.js index e5b3e3ccfabbf6..c1cfa22eb694ed 100644 --- a/test/pummel/test-policy-integrity-worker-no-package-json.js +++ b/test/pummel/test-policy-integrity-worker-no-package-json.js @@ -22,7 +22,7 @@ const fs = require('fs'); const path = require('path'); const { pathToFileURL } = require('url'); -const cpus = require('os').cpus().length; +const cpus = require('os').availableParallelism(); function hash(algo, body) { const values = []; diff --git a/test/sequential/test-gc-http-client-onerror.js b/test/sequential/test-gc-http-client-onerror.js index d5ae7fbd20c156..7574c0f9373634 100644 --- a/test/sequential/test-gc-http-client-onerror.js +++ b/test/sequential/test-gc-http-client-onerror.js @@ -6,7 +6,7 @@ const common = require('../common'); const onGC = require('../common/ongc'); -const cpus = require('os').cpus().length; +const cpus = require('os').availableParallelism(); function serverHandler(req, res) { req.resume(); diff --git a/test/sequential/test-gc-http-client-timeout.js b/test/sequential/test-gc-http-client-timeout.js index 3472e79422d081..51dec7f043182d 100644 --- a/test/sequential/test-gc-http-client-timeout.js +++ b/test/sequential/test-gc-http-client-timeout.js @@ -16,7 +16,7 @@ function serverHandler(req, res) { }, 100); } -const cpus = os.cpus().length; +const cpus = os.availableParallelism(); const numRequests = 36; let createClients = true; let done = 0; diff --git a/test/sequential/test-gc-http-client.js b/test/sequential/test-gc-http-client.js index 34f565c315d454..8e9d3e9e729db2 100644 --- a/test/sequential/test-gc-http-client.js +++ b/test/sequential/test-gc-http-client.js @@ -5,7 +5,7 @@ const common = require('../common'); const onGC = require('../common/ongc'); -const cpus = require('os').cpus().length; +const cpus = require('os').availableParallelism(); function serverHandler(req, res) { res.writeHead(200, { 'Content-Type': 'text/plain' });