-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
191 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ WORKDIR /var/pm2 | |
ENV NODE_ENV test | ||
ENV PM2_DISCRETE_MODE true | ||
|
||
RUN apk update && apk add bash git curl python3 php5 && rm -rf /var/cache/apk/* | ||
RUN apk update && apk add bash git curl python python3 php5 && rm -rf /var/cache/apk/* | ||
RUN ln -s /usr/bin/php5 /usr/bin/php | ||
RUN npm install -g [email protected] | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env bash | ||
|
||
# | ||
# LSOF check | ||
# | ||
|
||
SRC=$(cd $(dirname "$0"); pwd) | ||
source "${SRC}/../include.sh" | ||
|
||
cd $file_path | ||
|
||
echo "################## RELOAD ###################" | ||
|
||
# lsof -c PM2 > /tmp/no_pm2_out.dat | ||
|
||
# $pm2 list | ||
|
||
# sleep 1 | ||
# lsof -c PM2 > /tmp/empty_pm2_out.dat | ||
|
||
# $pm2 start echo.js -i 3 | ||
# $pm2 start killtoofast.js -i 3 | ||
# $pm2 delete all | ||
|
||
# sleep 3 | ||
# lsof -c PM2 > /tmp/empty_pm2_out2.dat | ||
|
||
# OUT1=`cat /tmp/empty_pm2_out.dat | wc -l` | ||
# OUT2=`cat /tmp/empty_pm2_out2.dat | wc -l` | ||
|
||
# if [ $OUT1 -eq $OUT2 ]; then | ||
# success "All file descriptors have been closed" | ||
# else | ||
# fail "Some file descriptors are still open" | ||
# fi | ||
|
||
# $pm2 start killtoofast.js -i 6 | ||
# $pm2 kill | ||
|
||
# rm /tmp/no_pm2_out.dat | ||
# rm /tmp/no_pm2_out2.dat | ||
# rm /tmp/empty_pm2_out.dat | ||
# rm /tmp/empty_pm2_out2.dat | ||
|
||
# sleep 6 | ||
> /tmp/no_pm_pm2_out.dat | ||
> /tmp/no_pm_pm2_out2.dat | ||
|
||
lsof -c PM2 > /tmp/no_pm2_out2.dat | ||
diff /tmp/no_pm2_out.dat /tmp/no_pm2_out2.dat | ||
|
||
if [ $? == "0" ]; then | ||
success "All file descriptors have been closed" | ||
else | ||
fail "Some file descriptors are still open" | ||
fi | ||
|
||
rm /tmp/no_pm2_out.dat | ||
rm /tmp/no_pm2_out2.dat | ||
rm /tmp/empty_pm2_out.dat | ||
rm /tmp/empty_pm2_out2.dat |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
|
||
const async = require('async') | ||
const fs = require('fs') | ||
const exec = require('child_process').exec | ||
const path = require('path') | ||
const chalk = require('chalk') | ||
const Table = require('cli-table-redemption'); | ||
|
||
const testFolder = './test/e2e/' | ||
|
||
const CONCURRENT_TEST = 6 | ||
const DOCKER_IMAGE_NAME = 'pm2-test' | ||
|
||
var timings = {}; | ||
|
||
function run(cmd, cb) { | ||
exec(cmd, function(err, stdout, stderr) { | ||
if (err) { | ||
console.log(`Retrying ${cmd}`) | ||
return exec(cmd, function(err, stdout, stderr) { | ||
if (err) return cb(stdout.split('\n')); | ||
return cb(null); | ||
}) | ||
} | ||
return cb(null) | ||
}) | ||
} | ||
|
||
function buildContainer(cb) { | ||
exec(`docker build -t ${DOCKER_IMAGE_NAME} -f test/Dockerfile .`, cb) | ||
} | ||
|
||
function listAllTest(cb) { | ||
var test_suite = [] | ||
|
||
fs.readdir(testFolder, (err, folders) => { | ||
async.forEachLimit(folders, 4, (folder, next) => { | ||
var fold = path.join(testFolder, folder) | ||
fs.readdir(fold, (err, files) => { | ||
if (err) return next() | ||
files.forEach((file) => { | ||
test_suite.push(path.join(fold, file)) | ||
}) | ||
next() | ||
}) | ||
}, function() { | ||
launchTestSuite(test_suite, cb) | ||
}) | ||
}) | ||
} | ||
|
||
function launchTestSuite(files, cb) { | ||
async.forEachLimit(files, CONCURRENT_TEST, function(file, next) { | ||
var cmd = `docker run -v ${path.resolve(__dirname, '..')}:/var/pm2 ${DOCKER_IMAGE_NAME} bash ${file}` | ||
|
||
console.log(chalk.bold(`Running test ${file}`)) | ||
timings[file] = new Date().getTime() | ||
|
||
run(cmd, function(err) { | ||
if (err) { | ||
// Display Error | ||
console.error(chalk.bold.red(`${'='.repeat(25)} Test File ${file} has failed ${'='.repeat(25)}`)) | ||
console.error(chalk.bold('Output (stderr):')) | ||
err.forEach(function(line) { | ||
console.error(line) | ||
}) | ||
console.error(chalk.bold.red(`${'='.repeat(80)}`)) | ||
return next(err) | ||
} | ||
|
||
timings[file] = new Date().getTime() - timings[file] | ||
|
||
console.log(chalk.bold.green(`✓ Test ${file} success`)) | ||
return next(); | ||
}) | ||
}, (err) => { | ||
if (err) { | ||
console.log('Test Suite has failed') | ||
cb(err) | ||
} | ||
console.log('Test Suite passed succesfully') | ||
cb() | ||
}) | ||
} | ||
|
||
buildContainer(function(err) { | ||
if (err) { | ||
console.error(err) | ||
process.exit(1) | ||
} | ||
console.log(`Container ${DOCKER_IMAGE_NAME} has been built`) | ||
|
||
return listAllTest(function(err) { | ||
|
||
var table = new Table({ | ||
head: ['Test', 'Duration'], | ||
style : {'padding-left' : 1, head : ['cyan', 'bold'], compact : true} | ||
}); | ||
|
||
Object.keys(timings).forEach(function(test) { | ||
table.push(test, timings[test]) | ||
}) | ||
|
||
console.log(table.toString()); | ||
|
||
if (err) { | ||
return console.error(chalk.bold.red('Test suite failed')) | ||
} | ||
console.log(chalk.bold.blue('Test suite succeeded')) | ||
}) | ||
}) |