From a92319290f6ed67016b34e102a4d602b428bab5f Mon Sep 17 00:00:00 2001 From: Oleg Elifantiev Date: Tue, 2 Jun 2015 09:01:09 +0300 Subject: [PATCH] One test instead of two (no scheduling policy specified) --- ...luster-worker-wait-server-close-schedrr.js | 68 ------------------- ... test-cluster-worker-wait-server-close.js} | 2 - 2 files changed, 70 deletions(-) delete mode 100644 test/parallel/test-cluster-worker-wait-server-close-schedrr.js rename test/parallel/{test-cluster-worker-wait-server-close-schednone.js => test-cluster-worker-wait-server-close.js} (97%) diff --git a/test/parallel/test-cluster-worker-wait-server-close-schedrr.js b/test/parallel/test-cluster-worker-wait-server-close-schedrr.js deleted file mode 100644 index dfa679043c75a7..00000000000000 --- a/test/parallel/test-cluster-worker-wait-server-close-schedrr.js +++ /dev/null @@ -1,68 +0,0 @@ -var common = require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); -var net = require('net'); - -if (cluster.isWorker) { - net.createServer(function(socket) { - // Wait for any data, then close connection - socket.on('data', socket.end.bind(socket)); - }).listen(common.PORT, common.localhostIPv4); -} else if (cluster.isMaster) { - - cluster.schedulingPolicy = cluster.SCHED_RR; - - var connectionDone; - var checks = { - disconnectedOnClientsEnd: false, - workerDied: false - }; - - // helper function to check if a process is alive - var alive = function(pid) { - try { - process.kill(pid, 0); - return true; - } catch (e) { - return false; - } - }; - - // start worker - var worker = cluster.fork(); - - // Disconnect worker when it is ready - worker.once('listening', function() { - net.createConnection(common.PORT, common.localhostIPv4, function() { - var socket = this; - // If no timeout here, connection will not be accepted by worker - // cause' it will receive 'newconn' message after 'disconnect' - // and connection will not get accepted - setTimeout(function() { - worker.disconnect(); - setImmediate(function() { - socket.write('.'); - connectionDone = true; - }, 1000); - }, 1000); - }); - }); - - // Check worker events and properties - worker.once('disconnect', function() { - checks.disconnectedOnClientsEnd = connectionDone; - }); - - // Check that the worker died - worker.once('exit', function() { - checks.workerDied = !alive(worker.process.pid); - process.nextTick(function() { - process.exit(0); - }); - }); - - process.once('exit', function() { - assert.ok(checks.disconnectedOnClientsEnd, 'The worker disconnected before all clients are ended'); - assert.ok(checks.workerDied, 'The worker did not die'); - }); -} diff --git a/test/parallel/test-cluster-worker-wait-server-close-schednone.js b/test/parallel/test-cluster-worker-wait-server-close.js similarity index 97% rename from test/parallel/test-cluster-worker-wait-server-close-schednone.js rename to test/parallel/test-cluster-worker-wait-server-close.js index db900e7a1d217e..a04d5429d57af1 100644 --- a/test/parallel/test-cluster-worker-wait-server-close-schednone.js +++ b/test/parallel/test-cluster-worker-wait-server-close.js @@ -10,8 +10,6 @@ if (cluster.isWorker) { }).listen(common.PORT, common.localhostIPv4); } else if (cluster.isMaster) { - cluster.schedulingPolicy = cluster.SCHED_NONE; - var connectionDone; var checks = { disconnectedOnClientsEnd: false,