Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
deac844d02 | |||
80a3ba4621 | |||
|
774d0b446f |
@ -180,7 +180,9 @@ proc start*(cfg: StrawBossConfig): void =
|
|||||||
try:
|
try:
|
||||||
let authToken = makeAuthToken(cfg, uname, pwd)
|
let authToken = makeAuthToken(cfg, uname, pwd)
|
||||||
resp($(%authToken), JSON)
|
resp($(%authToken), JSON)
|
||||||
except: jsonResp(Http401, getCurrentExceptionMsg())
|
except:
|
||||||
|
jsonResp(Http401, getCurrentExceptionMsg())
|
||||||
|
if ctx.cfg.debug: echo getStackTrace()
|
||||||
|
|
||||||
get "/verify-auth":
|
get "/verify-auth":
|
||||||
checkAuth()
|
checkAuth()
|
||||||
@ -266,17 +268,16 @@ proc start*(cfg: StrawBossConfig): void =
|
|||||||
|
|
||||||
checkAuth()
|
checkAuth()
|
||||||
|
|
||||||
|
var details = ""
|
||||||
try:
|
try:
|
||||||
let activeRuns = workers
|
let activeRuns = workers
|
||||||
.filterIt(it.process.running and it.projectName == @"projectName")
|
.filterIt(it.process.running and it.projectName == @"projectName")
|
||||||
.mapIt(cfg.getRun(@"projecName", $it.runId));
|
.mapIt(cfg.getRun(@"projectName", $it.runId));
|
||||||
resp($(%activeRuns), JSON)
|
resp($(%activeRuns), JSON)
|
||||||
|
except NotFoundException:
|
||||||
|
jsonResp(Http404, getCurrentExceptionMsg())
|
||||||
except:
|
except:
|
||||||
try: raise getCurrentException()
|
json500Resp(getCurrentException(), "problem loading active runs")
|
||||||
except NotFoundException:
|
|
||||||
jsonResp(Http404, getCurrentExceptionMsg())
|
|
||||||
except:
|
|
||||||
json500Resp(getCurrentException(), "problem loading active runs")
|
|
||||||
|
|
||||||
get "/project/@projectName/run/@runId":
|
get "/project/@projectName/run/@runId":
|
||||||
## Details for a specific run
|
## Details for a specific run
|
||||||
@ -446,7 +447,7 @@ proc start*(cfg: StrawBossConfig): void =
|
|||||||
|
|
||||||
|
|
||||||
get re".*":
|
get re".*":
|
||||||
jsonResp(Http404)
|
jsonResp(Http404, "URL [" & request.path & "] is not present on this server.")
|
||||||
|
|
||||||
post re".*":
|
post re".*":
|
||||||
jsonResp(Http404)
|
jsonResp(Http404)
|
||||||
|
@ -2,6 +2,7 @@ import cliutils, httpclient, json, os, osproc, sequtils, strutils, tempfile,
|
|||||||
times, unittest, untar, uuids
|
times, unittest, untar, uuids
|
||||||
|
|
||||||
from langutils import sameContents
|
from langutils import sameContents
|
||||||
|
from algorithm import sorted
|
||||||
|
|
||||||
import ../testutil
|
import ../testutil
|
||||||
import ../../../main/nim/strawbosspkg/configuration
|
import ../../../main/nim/strawbosspkg/configuration
|
||||||
@ -205,9 +206,40 @@ suite "strawboss server":
|
|||||||
# Run the "build" step
|
# Run the "build" step
|
||||||
# Kick off a build that depends on "build" (which was run in the last test)
|
# Kick off a build that depends on "build" (which was run in the last test)
|
||||||
|
|
||||||
# TODO
|
test "kick off multiple runs and check the list of active runs via the API":
|
||||||
#test "kick off multiple runs and check the list of active runs via the API":
|
let http = newAuthenticatedHttpClient(apiBase, "bob@builder.com", "password")
|
||||||
# check false
|
|
||||||
|
# Kick off multiple runs of the "long-running" job
|
||||||
|
let queuedRuns = toSeq((1..3)).map(proc (idx: int): Run =
|
||||||
|
let resp = http.post(apiBase & "/project/" & testProjName & "/step/long-running/run/0.3.1")
|
||||||
|
check resp.status.startsWith("200")
|
||||||
|
|
||||||
|
return parseRun(parseJson(resp.body)))
|
||||||
|
|
||||||
|
# Collect run ids.
|
||||||
|
let runIds = queuedRuns.mapIt($(it.id)).sorted(cmpIgnoreCase)
|
||||||
|
|
||||||
|
# Check on the runs
|
||||||
|
let getActiveResp = http.get(apiBase & "/project/" & testProjName & "/runs/active")
|
||||||
|
check getActiveResp.status.startsWith("200")
|
||||||
|
|
||||||
|
let activeRuns = parseJson(getActiveResp.body).getElems().mapIt(parseRun(it))
|
||||||
|
let activeRunIds = activeRuns.mapIt($(it.id)).sorted(cmpIgnoreCase)
|
||||||
|
|
||||||
|
# Make sure we see all runs in the active state.
|
||||||
|
check runIds == activeRunIds
|
||||||
|
|
||||||
|
let completedRuns = runIds.map(proc (runId: string): Run =
|
||||||
|
return http.waitForBuild(apiBase, testProjName, runId))
|
||||||
|
|
||||||
|
# Make sure all are completed and all are accounted for
|
||||||
|
check completedRuns.allIt(it.status.state == BuildState.complete)
|
||||||
|
check completedRuns.mapIt($(it.id)).sorted(cmpIgnoreCase) == runIds;
|
||||||
|
|
||||||
|
# Check that there are no more active runs
|
||||||
|
let getActiveResp2 = http.get(apiBase & "/project/" & testProjName & "/runs/active")
|
||||||
|
let remainingActiveRuns = parseJson(getActiveResp2.body).getElems().mapIt(parseRun(it))
|
||||||
|
check remainingActiveRuns.len == 0
|
||||||
|
|
||||||
# Last-chance catch to kill the server in case some test err'ed and didn't
|
# Last-chance catch to kill the server in case some test err'ed and didn't
|
||||||
# reach it's teardown handler
|
# reach it's teardown handler
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 127be8f66fcc6d4d223acf56668d42ff9c37bfb0
|
Subproject commit ab883bd9602a1373347a23c8bee4ed28dd475aec
|
Binary file not shown.
@ -48,4 +48,4 @@ task test, "Runs both the unit and functional test suites.":
|
|||||||
task dist, "Creates distributable package.":
|
task dist, "Creates distributable package.":
|
||||||
exec "nimble build"
|
exec "nimble build"
|
||||||
mkdir "dist"
|
mkdir "dist"
|
||||||
exec "cp strawboss strawboss.config.json dist/."
|
exec "cp strawboss strawboss.config.json example.json dist/."
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
"steps": {
|
"steps": {
|
||||||
"compile": {
|
"compile": {
|
||||||
"artifacts": ["strawboss"],
|
"artifacts": ["strawboss"],
|
||||||
"containerImage": "nimlang/nim:0.19.0",
|
|
||||||
"stepCmd": "nimble build"
|
"stepCmd": "nimble build"
|
||||||
},
|
},
|
||||||
"unittest": {
|
"unittest": {
|
||||||
|
11
test-spec.txt
Normal file
11
test-spec.txt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
Run a build. Look for:
|
||||||
|
- Run request archived
|
||||||
|
- Output logs archived with the run request
|
||||||
|
- Artifacts archived in the build-data directory.
|
||||||
|
- Configuration for that version archived in configurations directory.
|
||||||
|
- Status for that version archived in the status directory
|
||||||
|
|
||||||
|
Run the build again for the same project and build ref:
|
||||||
|
- Build should be skipped.
|
||||||
|
- Run request should be archived.
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user