Skip to content

Commit

Permalink
refactor: parallelize bash test
Browse files Browse the repository at this point in the history
  • Loading branch information
Unitech committed Feb 26, 2018
1 parent beb6e48 commit d4b4375
Show file tree
Hide file tree
Showing 81 changed files with 197 additions and 215 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ os:
- linux
before_install:
- sudo apt-get -qq update
- sudo apt-get install python3
- sudo apt-get install php5-cli
- sudo apt-get install parallel
services:
- docker
notifications:
slack: pm2-nodejs:5Lolyw2LMnwy8fziqOGILQxG
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"main": "index.js",
"types": "types/index.d.ts",
"scripts": {
"test": "NODE_ENV=test bash test/pm2_check_dependencies.sh && NODE_ENV=test bash test/pm2_programmatic_tests.sh && NODE_ENV=test bash test/pm2_behavior_tests.sh",
"test": "bash test/docker_parallel_test.sh",
"bench-pmx": "pm2 delete all; pm2 install pm2-probe; node examples/pmx/app.js; pm2 ls"
},
"keywords": [
Expand Down
5 changes: 4 additions & 1 deletion test/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
FROM node:9
FROM node:alpine

RUN mkdir -p /var/pm2

WORKDIR /var/pm2

ENV NODE_ENV test
RUN apk update && apk add bash git curl python3 php5 && rm -rf /var/cache/apk/*
RUN ln -s /usr/bin/php5 /usr/bin/php
RUN npm install -g mocha@3.5

CMD ["mocha", "./test/programmatic/api.mocha.js"]
File renamed without changes.
16 changes: 14 additions & 2 deletions test/bash/pm2-dev.sh → test/bash/binaries/pm2-dev.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

pm2dev="`type -P node` `pwd`/bin/pm2-dev"

pm2_path=`pwd`/bin/pm2-dev

if [ ! -f $pm2_path ];
then
pm2_path=`pwd`/../bin/pm2-dev
if [ ! -f $pm2_path ];
then
pm2_path=`pwd`/../../bin/pm2-dev
fi
fi

pm2dev="`type -P node` $pm2_path"

export PM2_HOME=$HOME'/.pm2-dev'

Expand Down
16 changes: 14 additions & 2 deletions test/bash/pm2-runtime.sh → test/bash/binaries/pm2-runtime.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

pm2_runtime="`type -P node` `pwd`/bin/pm2-runtime"

pm2_path=`pwd`/bin/pm2-runtime

if [ ! -f $pm2_path ];
then
pm2_path=`pwd`/../bin/pm2-runtime
if [ ! -f $pm2_path ];
then
pm2_path=`pwd`/../../bin/pm2-runtime
fi
fi

pm2_runtime="`type -P node` $pm2_path"

export PM2_RUNTIME_DEBUG='true'

Expand Down
24 changes: 0 additions & 24 deletions test/bash/cli-ux.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

export PM2_GRACEFUL_TIMEOUT=1000
export PM2_GRACEFUL_LISTEN_TIMEOUT=1000
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

echo -e "\033[1mRunning tests:\033[0m"

Expand Down
2 changes: 1 addition & 1 deletion test/bash/args.sh → test/bash/cli/args.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

cd $file_path/args

Expand Down
2 changes: 1 addition & 1 deletion test/bash/attach.sh → test/bash/cli/attach.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

echo -e "\033[1mRunning tests:\033[0m"

Expand Down
2 changes: 1 addition & 1 deletion test/bash/binary.sh → test/bash/cli/binary.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

echo -e "\033[1mRunning tests:\033[0m"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

cd $file_path

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

cd $file_path

Expand Down
2 changes: 1 addition & 1 deletion test/bash/env-refresh.sh → test/bash/cli/env-refresh.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"
cd $file_path

echo -e "\033[1mENV REFRESH\033[0m"
Expand Down
2 changes: 1 addition & 1 deletion test/bash/extra-lang.sh → test/bash/cli/extra-lang.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

cd $file_path/extra-lang

Expand Down
2 changes: 1 addition & 1 deletion test/bash/fork.sh → test/bash/cli/fork.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

cd $file_path

Expand Down
2 changes: 1 addition & 1 deletion test/bash/harmony.sh → test/bash/cli/harmony.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

cd $file_path

Expand Down
68 changes: 34 additions & 34 deletions test/bash/interpreter.sh → test/bash/cli/interpreter.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

cd $file_path/interpreter

Expand Down Expand Up @@ -41,36 +41,36 @@ should 'process should be online' "status: 'online'" 1

########## LIVESCRIPT

$pm2 delete all
$pm2 start echo.ls
sleep 1
should 'process should be errored without livescript installed' "status: 'errored'" 1
# $pm2 delete all
# $pm2 start echo.ls
# sleep 1
# should 'process should be errored without livescript installed' "status: 'errored'" 1

########### Install
# ########### Install

$pm2 install livescript
# $pm2 install livescript

########### livescript fork test
$pm2 delete all
# ########### livescript fork test
# $pm2 delete all

>livescript.log
# >livescript.log

$pm2 start echo.ls -o livescript.log --merge-logs
# $pm2 start echo.ls -o livescript.log --merge-logs

sleep 1.5
grep "Hello Livescript!" livescript.log
spec "Should work on Livescript files in fork mode"
# sleep 1.5
# grep "Hello Livescript!" livescript.log
# spec "Should work on Livescript files in fork mode"

########### livescript cluster test
$pm2 delete all
# ########### livescript cluster test
# $pm2 delete all

>livescript.log
# >livescript.log

$pm2 start echo.ls -i 1 -o livescript.log --merge-logs
# $pm2 start echo.ls -i 1 -o livescript.log --merge-logs

sleep 1.5
grep "Hello Livescript!" livescript.log
spec "Should work on Livescript files in cluster mode"
# sleep 1.5
# grep "Hello Livescript!" livescript.log
# spec "Should work on Livescript files in cluster mode"

########### TYPESCRIPT

Expand All @@ -81,27 +81,27 @@ should 'process should be errored without typescript installed' "status: 'errore

########### Install

# $pm2 install typescript
$pm2 install typescript

########### typescript fork test
# $pm2 delete all
$pm2 delete all

# >typescript.log
>typescript.log

# $pm2 start echo.ts -o typescript.log --merge-logs
$pm2 start echo.ts -o typescript.log --merge-logs

# sleep 1.5
sleep 1.5

# grep "Hello Typescript!" typescript.log
# spec "Should work on Typescript files in fork mode"
grep "Hello Typescript!" typescript.log
spec "Should work on Typescript files in fork mode"

########### typescript cluster test
# $pm2 delete all
$pm2 delete all

# >typescript.log
>typescript.log

# $pm2 start echo.ts -i 1 -o typescript.log --merge-logs
$pm2 start echo.ts -i 1 -o typescript.log --merge-logs

# sleep 1.5
# grep "Hello Typescript!" typescript.log
# spec "Should work on Typescript files in cluster mode"
sleep 1.5
grep "Hello Typescript!" typescript.log
spec "Should work on Typescript files in cluster mode"
2 changes: 1 addition & 1 deletion test/bash/mjs.sh → test/bash/cli/mjs.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

cd $file_path/mjs

Expand Down
2 changes: 1 addition & 1 deletion test/bash/monit.sh → test/bash/cli/monit.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

cd $file_path

Expand Down
2 changes: 1 addition & 1 deletion test/bash/multiparam.sh → test/bash/cli/multiparam.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

cd $file_path

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

cd $file_path

Expand All @@ -24,4 +24,3 @@ should 'should have stopped 1 apps' 'online' 0
$pm2 restart /echo-[1,2]/

should 'should have restarted 2 apps' 'online' 2

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

cd $file_path

Expand Down
2 changes: 1 addition & 1 deletion test/bash/reset.sh → test/bash/cli/reset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

cd $file_path

Expand Down
2 changes: 1 addition & 1 deletion test/bash/resurrect.sh → test/bash/cli/resurrect.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"
cd $file_path

$pm2 start echo.js -i 4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
source "${SRC}/../include.sh"

cd $file_path

Expand Down
Loading

0 comments on commit d4b4375

Please sign in to comment.