2014-02-19 13:14:08 +00:00
|
|
|
|
|
|
|
|
cp = require 'child_process'
|
|
|
|
|
path = require 'path'
|
|
|
|
|
|
|
|
|
|
# exports.setUp = ( cb ) =>
|
|
|
|
|
# cb()
|
|
|
|
|
|
|
|
|
|
# exports.tearDown = ( cb ) =>
|
|
|
|
|
# @engine.send('die')
|
|
|
|
|
# cb()
|
|
|
|
|
|
2014-02-19 16:04:49 +00:00
|
|
|
# TODO test http shutdown command
|
|
|
|
|
# TODO test wrong/invalid config file
|
2014-02-19 13:14:08 +00:00
|
|
|
|
|
|
|
|
exports.testShutDown = ( test ) =>
|
|
|
|
|
test.expect 1
|
|
|
|
|
|
|
|
|
|
isRunning = true
|
|
|
|
|
pth = path.resolve 'js-coffee', 'webapi-eca'
|
2014-02-20 09:17:06 +00:00
|
|
|
engine = cp.fork pth, [ '-n', '-w', '8640' ] # [ '-i' , 'warn' ]
|
2014-02-19 13:14:08 +00:00
|
|
|
|
2014-02-20 09:17:06 +00:00
|
|
|
engine.on 'error', ( err ) ->
|
|
|
|
|
console.log err
|
2014-02-19 13:14:08 +00:00
|
|
|
engine.on 'exit', ( code, signal ) ->
|
|
|
|
|
test.ok true, 'Engine stopped'
|
|
|
|
|
isRunning = false
|
|
|
|
|
test.done()
|
|
|
|
|
|
|
|
|
|
fWaitForStartup = () ->
|
|
|
|
|
engine.send 'die'
|
|
|
|
|
setTimeout fWaitForDeath, 5000
|
|
|
|
|
|
|
|
|
|
# Garbage collect eventually still running process
|
|
|
|
|
fWaitForDeath = () ->
|
|
|
|
|
if isRunning
|
2014-02-19 14:09:12 +00:00
|
|
|
test.ok false, '"testShutDown" Engine didn\'t shut down!'
|
2014-02-19 13:14:08 +00:00
|
|
|
engine.kill()
|
|
|
|
|
test.done()
|
|
|
|
|
|
|
|
|
|
setTimeout fWaitForStartup, 1000
|
|
|
|
|
|
|
|
|
|
exports.testKill = ( test ) =>
|
|
|
|
|
test.expect 1
|
|
|
|
|
|
|
|
|
|
pth = path.resolve 'js-coffee', 'webapi-eca'
|
2014-02-20 09:17:06 +00:00
|
|
|
engine = cp.fork pth, [ '-n', '-w', '8641' ] # [ '-i' , 'warn' ]
|
|
|
|
|
engine.on 'error', ( err ) ->
|
|
|
|
|
console.log err
|
|
|
|
|
|
2014-02-19 13:14:08 +00:00
|
|
|
fWaitForStartup = () ->
|
|
|
|
|
engine.kill()
|
|
|
|
|
setTimeout fWaitForDeath, 1000
|
|
|
|
|
|
|
|
|
|
# Garbage collect eventually still running process
|
|
|
|
|
fWaitForDeath = () ->
|
2014-02-19 14:09:12 +00:00
|
|
|
test.ok engine.killed, '"testKill" Engine didn\'t shut down!'
|
2014-02-19 13:14:08 +00:00
|
|
|
test.done()
|
|
|
|
|
|
|
|
|
|
setTimeout fWaitForStartup, 1000
|
|
|
|
|
|
|
|
|
|
exports.testHttpPortAlreadyUsed = ( test ) =>
|
|
|
|
|
test.expect 1
|
|
|
|
|
isRunning = true
|
|
|
|
|
pth = path.resolve 'js-coffee', 'webapi-eca'
|
2014-02-20 09:17:06 +00:00
|
|
|
@engine_one = cp.fork pth, [ '-n', '-w', '8642' ] # [ '-i' , 'warn' ]
|
|
|
|
|
@engine_one.on 'error', ( err ) ->
|
|
|
|
|
console.log err
|
2014-02-19 13:14:08 +00:00
|
|
|
|
|
|
|
|
fWaitForFirstStartup = () =>
|
2014-02-20 09:17:06 +00:00
|
|
|
@engine_two = cp.fork pth, [ '-n', '-w', '8642' ] # [ '-i' , 'warn' ]
|
|
|
|
|
@engine_two.on 'error', ( err ) ->
|
|
|
|
|
console.log err
|
2014-02-19 13:14:08 +00:00
|
|
|
|
|
|
|
|
@engine_two.on 'exit', ( code, signal ) ->
|
|
|
|
|
test.ok true, 'Engine stopped'
|
|
|
|
|
isRunning = false
|
|
|
|
|
test.done()
|
|
|
|
|
|
2014-02-19 14:09:12 +00:00
|
|
|
setTimeout fWaitForDeath, 1000
|
2014-02-19 13:14:08 +00:00
|
|
|
|
|
|
|
|
# Garbage collect eventually still running process
|
|
|
|
|
fWaitForDeath = () =>
|
|
|
|
|
if isRunning
|
2014-02-19 14:09:12 +00:00
|
|
|
test.ok false, '"testHttpPortAlreadyUsed" Engine didn\'t shut down!'
|
2014-02-19 13:14:08 +00:00
|
|
|
test.done()
|
|
|
|
|
|
|
|
|
|
@engine_one.kill()
|
|
|
|
|
@engine_two.kill()
|
|
|
|
|
|
|
|
|
|
setTimeout fWaitForFirstStartup, 1000
|
|
|
|
|
|
|
|
|
|
exports.testHttpPortInvalid = ( test ) =>
|
|
|
|
|
test.expect 1
|
|
|
|
|
|
|
|
|
|
isRunning = true
|
|
|
|
|
pth = path.resolve 'js-coffee', 'webapi-eca'
|
2014-02-20 09:17:06 +00:00
|
|
|
engine = cp.fork pth, [ '-n', '-w', '1' ] # [ '-i' , 'warn' ]
|
2014-02-19 13:14:08 +00:00
|
|
|
engine.on 'exit', ( code, signal ) ->
|
|
|
|
|
test.ok true, 'Engine stopped'
|
|
|
|
|
isRunning = false
|
|
|
|
|
test.done()
|
2014-02-20 09:17:06 +00:00
|
|
|
engine.on 'error', ( err ) ->
|
|
|
|
|
console.log err
|
2014-02-19 13:14:08 +00:00
|
|
|
|
|
|
|
|
# Garbage collect eventually still running process
|
|
|
|
|
fWaitForDeath = () =>
|
|
|
|
|
if isRunning
|
2014-02-19 14:09:12 +00:00
|
|
|
test.ok false, '"testHttpPortInvalid" Engine didn\'t shut down!'
|
2014-02-19 13:14:08 +00:00
|
|
|
test.done()
|
2014-02-20 09:17:06 +00:00
|
|
|
# engine.kill()
|
2014-02-19 13:14:08 +00:00
|
|
|
|
2014-02-19 16:04:49 +00:00
|
|
|
setTimeout fWaitForDeath, 1000
|
|
|
|
|
|
|
|
|
|
exports.testDbPortInvalid = ( test ) =>
|
|
|
|
|
test.expect 1
|
|
|
|
|
|
|
|
|
|
isRunning = true
|
|
|
|
|
pth = path.resolve 'js-coffee', 'webapi-eca'
|
2014-02-20 09:17:06 +00:00
|
|
|
engine = cp.fork pth, [ '-n', '-d', '10'] # [ '-i' , 'warn' ]
|
|
|
|
|
engine.on 'error', ( err ) ->
|
|
|
|
|
console.log err
|
2014-02-19 16:04:49 +00:00
|
|
|
engine.on 'exit', ( code, signal ) ->
|
|
|
|
|
test.ok true, 'Engine stopped'
|
|
|
|
|
isRunning = false
|
|
|
|
|
test.done()
|
|
|
|
|
|
|
|
|
|
# Garbage collect eventually still running process
|
|
|
|
|
fWaitForDeath = () =>
|
|
|
|
|
engine.kill()
|
|
|
|
|
if isRunning
|
|
|
|
|
test.ok false, '"testHttpPortInvalid" Engine didn\'t shut down!'
|
|
|
|
|
test.done()
|
2014-02-19 13:14:08 +00:00
|
|
|
|
|
|
|
|
setTimeout fWaitForDeath, 1000
|