mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
Add resurrection tests for a backup
This commit is contained in:
parent
1c9b2c0b0d
commit
829d95dd2f
@ -6,13 +6,23 @@ cd $file_path
|
||||
|
||||
$pm2 start echo.js -i 4
|
||||
spec "should start 4 processes"
|
||||
should 'should have 4 apps started' 'online' 4
|
||||
|
||||
$pm2 save
|
||||
spec "should save process list"
|
||||
ls ~/.pm2/dump.pm2
|
||||
spec "should dump file exists"
|
||||
$pm2 resurrect
|
||||
spec "should resurrect"
|
||||
spec "should resurrect from dump"
|
||||
should 'should have still 4 apps started' 'online' 4
|
||||
|
||||
$pm2 save
|
||||
$pm2 delete all
|
||||
echo "[{" > ~/.pm2/dump.pm2
|
||||
$pm2 resurrect
|
||||
spec "should resurrect from backup if dump is broken"
|
||||
ls ~/.pm2/dump.pm2
|
||||
ispec "should delete broken dump"
|
||||
should 'should have still 4 apps started' 'online' 4
|
||||
|
||||
$pm2 delete all
|
||||
$pm2 resurrect
|
||||
spec "should resurrect from backup if dump is missing"
|
||||
should 'should have still 4 apps started' 'online' 4
|
||||
|
||||
@ -117,7 +117,7 @@ describe('Misc commands', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should resurrect previous processes', function(done) {
|
||||
it('should resurrect previous processes from dump', function(done) {
|
||||
pm2.resurrect(function(err, data) {
|
||||
should(err).be.null();
|
||||
|
||||
@ -129,5 +129,62 @@ describe('Misc commands', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should resurrect previous processes from backup if dump is broken', function(done) {
|
||||
fs.writeFileSync(cst.DUMP_FILE_PATH, '[{');
|
||||
|
||||
pm2.resurrect(function(err, data) {
|
||||
should(err).be.null();
|
||||
|
||||
pm2.list(function(err, procs) {
|
||||
should(err).be.null();
|
||||
procs.length.should.eql(4);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete broken dump', function() {
|
||||
should(fs.existsSync(cst.DUMP_FILE_PATH)).be.false();
|
||||
});
|
||||
|
||||
it('should resurrect previous processes from backup if dump is missing', function(done) {
|
||||
if (fs.existsSync(cst.DUMP_FILE_PATH)) {
|
||||
fs.unlinkSync(cst.DUMP_FILE_PATH);
|
||||
}
|
||||
|
||||
pm2.resurrect(function(err, data) {
|
||||
should(err).be.null();
|
||||
|
||||
pm2.list(function(err, procs) {
|
||||
should(err).be.null();
|
||||
procs.length.should.eql(4);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should resurrect no processes if dump and backup are broken', function() {
|
||||
fs.writeFileSync(cst.DUMP_FILE_PATH, '[{');
|
||||
fs.writeFileSync(cst.DUMP_BACKUP_FILE_PATH, '[{');
|
||||
|
||||
should(pm2.resurrect()).be.false();
|
||||
});
|
||||
|
||||
it('should delete broken dump and backup', function() {
|
||||
should(fs.existsSync(cst.DUMP_FILE_PATH)).be.false();
|
||||
should(fs.existsSync(cst.DUMP_BACKUP_FILE_PATH)).be.false();
|
||||
});
|
||||
|
||||
it('should resurrect no processes if dump and backup are missing', function() {
|
||||
if (fs.existsSync(cst.DUMP_FILE_PATH)) {
|
||||
fs.unlinkSync(cst.DUMP_FILE_PATH);
|
||||
}
|
||||
|
||||
if (fs.existsSync(cst.DUMP_BACKUP_FILE_PATH)) {
|
||||
fs.unlinkSync(cst.DUMP_BACKUP_FILE_PATH);
|
||||
}
|
||||
|
||||
should(pm2.resurrect()).be.false();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user