Add functional tests for docker-based build configurations.
This commit is contained in:
@ -142,6 +142,61 @@ suite "strawboss server":
|
||||
let status = loadBuildStatus(statusFile)
|
||||
check status.state == step[1]
|
||||
|
||||
test "run a build in docker":
|
||||
let http = newAuthenticatedHttpClient(apibase, "bob@builder.com", "password")
|
||||
|
||||
# Run the "build-docker" step
|
||||
var resp = http.post(apiBase & "/project/" & testProjName & "/step/build-docker/run/0.3.0")
|
||||
check resp.status.startsWith("200")
|
||||
|
||||
let queuedRun = parseRun(parseJson(resp.body))
|
||||
check queuedRun.status.state == BuildState.queued
|
||||
|
||||
# Wait for the build to complete
|
||||
let completedRun = http.waitForBuild(apiBase, testProjName, $queuedRun.id)
|
||||
|
||||
# check that the run directory, run request, status, and output logs exist
|
||||
let runsDir = tempBuildDataDir & "/" & testProjName & "/runs"
|
||||
let runId = $completedRun.id
|
||||
check existsDir(runsDir)
|
||||
for suffix in [".request.json", ".status.json", ".stdout.log", ".stderr.log"]:
|
||||
check existsFile(runsDir & "/" & runId & suffix)
|
||||
|
||||
# check that the project directory has been created in the artifacts repo
|
||||
let runArtifactsDir = tempBuildDataDir & "/" & testProjName & "/artifacts/build-docker/0.3.0"
|
||||
check existsDir(runArtifactsDir)
|
||||
|
||||
# check that the build step status file has been created
|
||||
let statusFile = tempBuildDataDir & "/" & testProjName & "/status/build-docker/0.3.0.json"
|
||||
check fileExists(statusFile)
|
||||
|
||||
# check that the status is complete
|
||||
var status = loadBuildStatus(statusFile)
|
||||
check status.state == BuildState.complete
|
||||
|
||||
# check that the artifacts we expect are present
|
||||
let binFile = runArtifactsDir & "/test_project"
|
||||
check existsFile(binFile)
|
||||
|
||||
test "run a multi-step docker-based build":
|
||||
let http = newAuthenticatedHttpClient(apibase, "bob@builder.com", "password")
|
||||
|
||||
# Run the "test" step (depends on "build")
|
||||
var resp = http.post(apiBase & "/project/" & testProjname & "/step/test-docker/run/0.3.0")
|
||||
check resp.status.startsWith("200")
|
||||
|
||||
let queuedRun = parseRun(parseJson(resp.body))
|
||||
let completedRun = http.waitForBuild(apiBase, testProjName, $queuedRun.id)
|
||||
|
||||
# there should be successful status files for both the build and test steps
|
||||
for step in [("build-docker", BuildState.stepComplete), ("test-docker", BuildState.complete)]:
|
||||
let statusFile = tempBuildDataDir & "/" & testProjName & "/status/" & step[0] & "/0.3.0.json"
|
||||
check fileExists(statusFile)
|
||||
|
||||
let status = loadBuildStatus(statusFile)
|
||||
check status.state == step[1]
|
||||
|
||||
# TODO
|
||||
#test "already completed steps should not be rebuilt":
|
||||
# let http = newAuthenticatedHttpClient(apibase, "bob@builder.com", "password")
|
||||
# let runArtifactsDir = tempBuildDataDir & "/" & testProjName & "/artifacts/build/0.2.1"
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user