From 7fa788be911887a8fd59626dc9e85932ba672def Mon Sep 17 00:00:00 2001 From: Bas van Rossem Date: Mon, 27 Jan 2025 14:13:58 +0100 Subject: [PATCH 1/5] removed tests that check memory usage --- test/e2e/misc/misc.sh | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/test/e2e/misc/misc.sh b/test/e2e/misc/misc.sh index d54a4ac05..50daf64d6 100644 --- a/test/e2e/misc/misc.sh +++ b/test/e2e/misc/misc.sh @@ -14,29 +14,6 @@ $pm2 stop push.json $pm2 list -# -# Max memory auto restart option -# -# --max-memory-restart option && maxMemoryRestart (via JSON file) -# -$pm2 kill -PM2_WORKER_INTERVAL=1000 $pm2 start big-array.js --max-memory-restart="20M" -sleep 3 -$pm2 list -should 'process should have been restarted' 'restart_time: 0' 0 - -$pm2 delete all - -# -# Via JSON -# -$pm2 start json-reload/max-mem.json -sleep 3 -$pm2 list -should 'process should been restarted' 'restart_time: 0' 0 - -$pm2 delete all - $pm2 start env.js OUT_LOG=`$pm2 prettylist | grep -m 1 -E "pm_out_log_path:" | sed "s/.*'\([^']*\)',/\1/"` From cf1a6753ec253e723698181969daa7cc8885a291 Mon Sep 17 00:00:00 2001 From: Bas van Rossem Date: Mon, 27 Jan 2025 15:00:40 +0100 Subject: [PATCH 2/5] remove memory checker tests --- test/programmatic/max_memory_limit.js | 89 --------------------------- 1 file changed, 89 deletions(-) delete mode 100644 test/programmatic/max_memory_limit.js diff --git a/test/programmatic/max_memory_limit.js b/test/programmatic/max_memory_limit.js deleted file mode 100644 index df17d69f4..000000000 --- a/test/programmatic/max_memory_limit.js +++ /dev/null @@ -1,89 +0,0 @@ - -process.env.NODE_ENV = 'test'; -process.env.PM2_WORKER_INTERVAL = 1000; - -var PM2 = require('../..'); -var should = require('should'); -var path = require('path'); - -// Change to current folder - -describe('Max memory restart programmatic', function() { - var proc1 = null; - var procs = []; - var pm2 = new PM2.custom({ - cwd : __dirname + '/../fixtures/json-reload/' - }); - - after(function(done) { - pm2.kill(done) - }); - - afterEach(function(done) { - pm2.delete('all', function() { - setTimeout(done, 300); - }); - }); - - before(function(done) { - pm2.connect(function() { - done(); - }); - }); - - describe('Max memory limit', function() { - it('should restart process based on memory limit (UGLY WAY)', function(done) { - pm2.start('./big-array.js', { - maxMemoryRestart : '10M' - }, function(err, data) { - should(err).be.null(); - - setTimeout(function() { - pm2.list(function(err, ret) { - should(err).be.null(); - ret[0].pm2_env.restart_time.should.not.eql(0); - done(); - }); - }, 3000); - }); - }); - - it('should restart process based on memory limit (JSON WAY)', function(done) { - pm2.start({ - script : './big-array.js', - max_memory_restart : '10M' - }, function(err, data) { - should(err).be.null(); - - setTimeout(function() { - pm2.list(function(err, ret) { - should(err).be.null(); - ret[0].pm2_env.restart_time.should.not.eql(0); - done(); - }); - }, 3000); - }); - }); - - it('should restart CLUSTER process based on memory limit (JSON WAY)', function(done) { - pm2.start({ - script : './../big-array-listen.js', - max_memory_restart : '10M', - exec_mode : 'cluster' - }, function(err, data) { - should(err).be.null(); - - setTimeout(function() { - pm2.list(function(err, ret) { - should(err).be.null(); - ret[0].pm2_env.restart_time.should.not.eql(0); - done(); - }); - }, 3000); - }); - }); - - - }); - -}); From f6ffeb1984a29f2aa225be4ee0cc3b0cbad1a9c1 Mon Sep 17 00:00:00 2001 From: Bas van Rossem Date: Mon, 27 Jan 2025 15:21:16 +0100 Subject: [PATCH 3/5] truly remove tests --- test/unit.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unit.sh b/test/unit.sh index e363644f6..61417cf37 100644 --- a/test/unit.sh +++ b/test/unit.sh @@ -68,7 +68,6 @@ runUnitTest $D/api.backward.compatibility.mocha.js runUnitTest $D/custom_action.mocha.js runUnitTest $D/logs.js runUnitTest $D/watcher.js -runUnitTest $D/max_memory_limit.js runUnitTest $D/cluster.mocha.js runUnitTest $D/graceful.mocha.js runUnitTest $D/inside.mocha.js From a12fe91c5871f1faeaba71c73395bc4a06141db6 Mon Sep 17 00:00:00 2001 From: Bas van Rossem Date: Mon, 27 Jan 2025 15:51:53 +0100 Subject: [PATCH 4/5] expect empty values --- test/programmatic/god.mocha.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/programmatic/god.mocha.js b/test/programmatic/god.mocha.js index 683f7c558..9a2995405 100644 --- a/test/programmatic/god.mocha.js +++ b/test/programmatic/god.mocha.js @@ -255,7 +255,7 @@ describe('God', function() { }); }); - it('should get monitor data', function(done) { + it('should get empty monitor data', function(done) { var f = require('child_process').fork('../fixtures/echo.js') var processes = [ @@ -295,10 +295,11 @@ describe('God', function() { g.getMonitorData({}, function(err, procs) { should(err).be.null(); procs.length.should.be.equal(processes.length); + // Monitoring memory and CPU no longer works procs[0].monit.should.be.deepEqual({memory: 0, cpu: 0}); - procs[1].monit.memory.should.be.greaterThan(0); + procs[1].monit.memory.be.deepEqual({memory: 0, cpu: 0}); procs[2].monit.should.be.deepEqual({memory: 0, cpu: 0}); - procs[3].monit.memory.should.be.greaterThan(0); + procs[3].monit.memory.be.deepEqual({memory: 0, cpu: 0}); f.kill() done() }) From 217c2cf4cc47537949c5de9dae33ba91c43685ab Mon Sep 17 00:00:00 2001 From: Bas van Rossem Date: Mon, 27 Jan 2025 16:30:32 +0100 Subject: [PATCH 5/5] check correct field --- test/programmatic/god.mocha.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/programmatic/god.mocha.js b/test/programmatic/god.mocha.js index 9a2995405..e61d18826 100644 --- a/test/programmatic/god.mocha.js +++ b/test/programmatic/god.mocha.js @@ -297,9 +297,9 @@ describe('God', function() { procs.length.should.be.equal(processes.length); // Monitoring memory and CPU no longer works procs[0].monit.should.be.deepEqual({memory: 0, cpu: 0}); - procs[1].monit.memory.be.deepEqual({memory: 0, cpu: 0}); + procs[1].monit.should.be.deepEqual({memory: 0, cpu: 0}); procs[2].monit.should.be.deepEqual({memory: 0, cpu: 0}); - procs[3].monit.memory.be.deepEqual({memory: 0, cpu: 0}); + procs[3].monit.should.be.deepEqual({memory: 0, cpu: 0}); f.kill() done() })