WIP Moving back towards using named runs.
* Rename artifactsRepo -> buildDataDir to be more explicit about the fact that it holds more than just the artifacts. * Revert removal of run ids. * Move Worker definition into core as part of making the core responsible for accepting run requests. * Make the core module more responsible for internal details of data structure and storage. External callers should not need to construct paths to artifacts, versions, etc. but should be able to call method in the core module to do this work for them. * The working directory no longer contains anything but the checked-out code. All StrawBoss-specific data is stored by StrawBoss elsewhere. * Add a regular maintenance cycle to the server module.
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
{
|
||||
"runId": "90843e0c-6113-4462-af33-a89ff9731031",
|
||||
"state": "failed",
|
||||
"details": "some very good reason"
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ let TIMEOUT = 2.minutes
|
||||
# configuration and working files.
|
||||
template keepEnv(): untyped =
|
||||
preserveEnv = true
|
||||
echo "artifacts dir: " & tempArtifactsDir
|
||||
echo "artifacts dir: " & tempBuildDataDir
|
||||
echo "strawboss serve -c " & tempCfgPath
|
||||
|
||||
suite "strawboss server":
|
||||
@ -30,13 +30,13 @@ suite "strawboss server":
|
||||
|
||||
# per-test setup: spin up a fresh strawboss instance
|
||||
setup:
|
||||
let tempArtifactsDir = mkdtemp()
|
||||
let tempBuildDataDir = mkdtemp()
|
||||
let (_, tempCfgPath) = mkstemp()
|
||||
var preserveEnv = false
|
||||
|
||||
# copy our test config
|
||||
var newCfg = cfg
|
||||
newCfg.artifactsRepo = tempArtifactsDir
|
||||
newCfg.buildDataDir = tempBuildDataDir
|
||||
|
||||
# update the repo string for the extracted test project
|
||||
var testProjDef = newCfg.findProject(testProjName)
|
||||
@ -55,7 +55,7 @@ suite "strawboss server":
|
||||
discard newAsyncHttpClient().post(apiBase & "/service/debug/stop")
|
||||
|
||||
if not preserveEnv:
|
||||
removeDir(tempArtifactsDir)
|
||||
removeDir(tempBuildDataDir)
|
||||
removeFile(tempCfgPath)
|
||||
|
||||
# give the server time to spin down but kill it after that
|
||||
@ -73,14 +73,14 @@ suite "strawboss server":
|
||||
check resp.status.startsWith("404")
|
||||
|
||||
test "GET /api/project/@projectName/versions":
|
||||
let projArtifactsDir = tempArtifactsDir & "/" & testProjName
|
||||
let cachedConfsDir = tempBuildDataDir & "/" & testProjName & "/configurations"
|
||||
let expectedVersions = @["alpha", "beta", "1.0.0", "1.0.1"]
|
||||
|
||||
# Touch configuration files
|
||||
createDir(projArtifactsDir)
|
||||
createDir(cachedConfsDir)
|
||||
for v in expectedVersions:
|
||||
var f: File
|
||||
check open(f, projArtifactsDir & "/configuration." & v & ".json", fmWrite)
|
||||
check open(f, cachedConfsDir & "/" & v & ".json", fmWrite)
|
||||
close(f)
|
||||
|
||||
let http = newAuthenticatedHttpClient(apibase, "bob@builder.com", "password")
|
||||
@ -96,12 +96,13 @@ suite "strawboss server":
|
||||
# give the filesystem time to create stuff
|
||||
sleep(100)
|
||||
|
||||
# check that the run request has been
|
||||
# check that the project directory has been created in the artifacts repo
|
||||
let runArtifactsDir = tempArtifactsDir & "/" & testProjName & "/build/0.1.0"
|
||||
let runArtifactsDir = tempBuildDataDir & "/" & testProjName & "/artifacts/build/0.1.0"
|
||||
check existsDir(runArtifactsDir)
|
||||
|
||||
# check that the run status file has been created in the artifacts repo
|
||||
let statusFile = runArtifactsDir & "/status.json"
|
||||
let statusFile = tempBuildDataDir & "/" & testProjName & "/status/0.1.0.json"
|
||||
check fileExists(statusFile)
|
||||
|
||||
# check that the run status is not failed
|
||||
|
@ -21,6 +21,7 @@ suite "load and save configuration objects":
|
||||
|
||||
test "parseRunRequest":
|
||||
let rr1 = RunRequest(
|
||||
id: genUUID(),
|
||||
projectName: testProjDef.name,
|
||||
stepName: "build",
|
||||
buildRef: "master",
|
||||
@ -85,7 +86,7 @@ suite "load and save configuration objects":
|
||||
envVars: newStringTable(modeCaseSensitive))]
|
||||
|
||||
check:
|
||||
cfg.artifactsRepo == "artifacts"
|
||||
cfg.buildDataDir == "build-data"
|
||||
cfg.authSecret == "change me"
|
||||
cfg.pwdCost == 11
|
||||
sameContents(expectedUsers, cfg.users)
|
||||
@ -141,5 +142,6 @@ suite "load and save configuration objects":
|
||||
let st = loadBuildStatus("src/test/json/test-status.json")
|
||||
|
||||
check:
|
||||
st.runId == "90843e0c-6113-4462-af33-a89ff9731031"
|
||||
st.state == "failed"
|
||||
st.details == "some very good reason"
|
||||
|
Reference in New Issue
Block a user