Explicitly kill server processes after tests if they don't die gracefully.

This commit is contained in:
Jonathan Bernard 2017-05-08 12:36:34 -05:00
parent 411379cb8d
commit a6c6bcf37d

View File

@ -25,7 +25,8 @@ let testuser = UserRef( # note: needs to correspond to an actual user
suite "strawboss server": suite "strawboss server":
# suite setup code # suite setup code
discard startProcess("./strawboss", ".", @["serve", "-c", cfgFilePath], loadEnv(), {poUsePath}) let serverProcess = startProcess("./strawboss", ".",
@["serve", "-c", cfgFilePath], loadEnv(), {poUsePath})
let http = newHttpClient() let http = newHttpClient()
@ -89,7 +90,11 @@ suite "strawboss server":
check sameContents(projects, cfg.projects) check sameContents(projects, cfg.projects)
# suite tear-down # suite tear-down
# give the server time to spin down but kill it after that
discard newAsyncHttpClient().post(apiBase & "/service/debug/stop") discard newAsyncHttpClient().post(apiBase & "/service/debug/stop")
sleep(100)
if serverProcess.running: kill(serverProcess)
suite "strawboss server continued": suite "strawboss server continued":
@ -99,13 +104,20 @@ suite "strawboss server continued":
var newCfg = cfg var newCfg = cfg
newCfg.artifactsRepo = tmpArtifactsDir newCfg.artifactsRepo = tmpArtifactsDir
writeFile(tmpCfgPath, $newCfg) writeFile(tmpCfgPath, $newCfg)
discard startProcess("./strawboss", ".", @["serve", "-c", tmpCfgPath], loadEnv(), {poUsePath}) let serverProcess = startProcess("./strawboss", ".",
@["serve", "-c", tmpCfgPath], loadEnv(), {poUsePath})
# give the server time to spin up # give the server time to spin up
sleep(100) sleep(100)
teardown: teardown:
discard newAsyncHttpClient().post(apiBase & "/service/debug/stop") discard newAsyncHttpClient().post(apiBase & "/service/debug/stop")
removeDir(tmpArtifactsDir)
removeFile(tmpCfgPath)
# give the server time to spin down but kill it after that
sleep(100)
if serverProcess.running: kill(serverProcess)
test "handle missing project configuration": test "handle missing project configuration":
let http = newAuthenticatedHttpClient(apibase, "bob@builder.com", "password") let http = newAuthenticatedHttpClient(apibase, "bob@builder.com", "password")