(tests) add test for operate with regex #2564 + changelog

This commit is contained in:
vmarchaud 2017-02-03 16:05:41 +01:00
parent c09a8aba55
commit e4586e8fcf
4 changed files with 32 additions and 2 deletions

View File

@ -10,6 +10,7 @@
- #2663 allow to directly output json when logging (via log_type for JSON and --log-type via CLI)
- #2675 fix path when installing language module like typescript
- #2674 increase restart timeout for systemd startup
- #2564 allow to operate process (restart/reload/stop/delete) with regex
## 2.3.0

View File

@ -1311,7 +1311,7 @@ API.prototype._operate = function(action_name, process_name, envs, cb) {
}
// operate using regex
else if (isNaN(process_name) && process_name[0] === '/' && process_name[process_name.length - 1] === '/') {
var regex = new RegExp(process_name);
var regex = new RegExp(process_name.replace(/\//g, ''));
that.Client.executeRemote('getMonitorData', {}, function(err, list) {
if (err) {
@ -1324,7 +1324,7 @@ API.prototype._operate = function(action_name, process_name, envs, cb) {
found_proc.push(proc.pm_id);
}
});
if (found_proc.length === 0) {
Common.printError(conf.PREFIX_MSG_WARNING + 'No process found');
return cb ? cb(new Error('process name not found')) : that.exitCli(conf.ERROR_EXIT);

View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
cd $file_path
$pm2 start echo.js --name "echo-3"
$pm2 start echo.js --name "echo-1"
$pm2 start echo.js --name "echo-2"
sleep 0.5
should 'should have started 3 apps' 'online' 3
$pm2 stop /echo-[1,2]/
should 'should have stopped 2 apps' 'stopped' 2
should 'only one app should still be online' 'online' 1
$pm2 stop /echo-3/
should 'should have stopped 1 apps' 'online' 0
$pm2 restart /echo-[1,2]/
should 'should have restarted 2 apps' 'online' 2

View File

@ -121,6 +121,8 @@ bash ./test/bash/log-null.sh
spec "Logging path set to null"
bash ./test/bash/log-json.sh
spec "Logging directly to file in json"
bash ./test/bash/operate-regex.sh
spec "Operate process that match regex"
# Issues related
bash ./test/bash/issues/2337.sh