aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-01-23 23:37:13 +0100
committerLudovic Courtès <ludo@gnu.org>2018-01-23 23:40:07 +0100
commit496b624dda0f78cdc531726d515f57ea1854d89a (patch)
treed80abc2075fd177fab672f4d3b7a7eb2be6fcad7 /tests
parentdd30a1a25cd419614656a70b98adbe26e181458f (diff)
downloadcuirass-496b624dda0f78cdc531726d515f57ea1854d89a.tar
cuirass-496b624dda0f78cdc531726d515f57ea1854d89a.tar.gz
http: Implement /api/queue.
* src/cuirass/http.scm (url-handler): Add /api/queue handler. * tests/http.scm ("http"): Add a BUILD2 and DERIVATION2, and rename BUILD and DERIVATION accordingly. ("/build/2", "/build/2/log/raw"): Rename to /42. ("/api/queue?nr=100"): New test.
Diffstat (limited to 'tests')
-rw-r--r--tests/http.scm101
1 files changed, 65 insertions, 36 deletions
diff --git a/tests/http.scm b/tests/http.scm
index 2c53fad..c136c47 100644
--- a/tests/http.scm
+++ b/tests/http.scm
@@ -27,7 +27,8 @@
(web response)
(rnrs bytevectors)
(srfi srfi-1)
- (srfi srfi-64))
+ (srfi srfi-64)
+ (ice-9 match))
(define (hash-table-keys table)
(hash-fold (lambda (key value rest)
@@ -128,37 +129,54 @@
(wait-until-ready 6688))
(test-assert "fill-db"
- (let ((build
- `((#:derivation . "/gnu/store/fake.drv")
- (#:eval-id . 1)
- (#:log . "unused so far")
- (#:status . 0)
- (#:outputs . (("out" . "/gnu/store/fake-1.0")))
- (#:timestamp . 1501347493)
- (#:starttime . 1501347493)
- (#:stoptime . 1501347493)))
- (derivation
- '((#:derivation . "/gnu/store/fake.drv")
- (#:job-name . "fake-job")
- (#:system . "x86_64-linux")
- (#:nix-name . "fake-1.0")
- (#:eval-id . 1)))
- (specification
- '((#:name . "guix")
- (#:url . "git://git.savannah.gnu.org/guix.git")
- (#:load-path . ".")
- (#:file . "/tmp/gnu-system.scm")
- (#:proc . hydra-jobs)
- (#:arguments (subset . "hello"))
- (#:branch . "master")
- (#:tag . #f)
- (#:commit . #f)
- (#:no-compile? . #f)))
- (evaluation
- '((#:specification . "guix")
- (#:revision . 1))))
- (db-add-build (%db) build)
- (db-add-derivation (%db) derivation)
+ (let* ((build1
+ `((#:derivation . "/gnu/store/fake.drv")
+ (#:eval-id . 1)
+ (#:log . "unused so far")
+ (#:status . ,(build-status succeeded))
+ (#:outputs . (("out" . "/gnu/store/fake-1.0")))
+ (#:timestamp . 1501347493)
+ (#:starttime . 1501347493)
+ (#:stoptime . 1501347493)))
+ (build2
+ `((#:derivation . "/gnu/store/fake2.drv")
+ (#:eval-id . 1)
+ (#:log . "unused so far")
+ (#:status . ,(build-status scheduled))
+ (#:outputs . (("out" . "/gnu/store/fake-2.0")))
+ (#:timestamp . 1501347493)
+ (#:starttime . 0)
+ (#:stoptime . 0)))
+ (derivation1
+ '((#:derivation . "/gnu/store/fake.drv")
+ (#:job-name . "fake-job")
+ (#:system . "x86_64-linux")
+ (#:nix-name . "fake-1.0")
+ (#:eval-id . 1)))
+ (derivation2
+ '((#:derivation . "/gnu/store/fake2.drv")
+ (#:job-name . "fake-job")
+ (#:system . "x86_64-linux")
+ (#:nix-name . "fake-2.0")
+ (#:eval-id . 1)))
+ (specification
+ '((#:name . "guix")
+ (#:url . "git://git.savannah.gnu.org/guix.git")
+ (#:load-path . ".")
+ (#:file . "/tmp/gnu-system.scm")
+ (#:proc . hydra-jobs)
+ (#:arguments (subset . "hello"))
+ (#:branch . "master")
+ (#:tag . #f)
+ (#:commit . #f)
+ (#:no-compile? . #f)))
+ (evaluation
+ '((#:specification . "guix")
+ (#:revision . 1))))
+ (db-add-build (%db) build1)
+ (db-add-build (%db) build2)
+ (db-add-derivation (%db) derivation1)
+ (db-add-derivation (%db) derivation2)
(db-add-specification (%db) specification)
(db-add-evaluation (%db) evaluation)))
@@ -178,13 +196,13 @@
(list (response-code response)
(response-location response))))
- (test-equal "/build/2"
+ (test-equal "/build/42"
404
- (response-code (http-get (test-cuirass-uri "/build/2"))))
+ (response-code (http-get (test-cuirass-uri "/build/42"))))
- (test-equal "/build/2/log/raw"
+ (test-equal "/build/42/log/raw"
404
- (response-code (http-get (test-cuirass-uri "/build/2/log/raw"))))
+ (response-code (http-get (test-cuirass-uri "/build/42/log/raw"))))
(test-equal "/api/latestbuilds"
500
@@ -216,6 +234,17 @@
json->scm)))
(= (length hash-list) 0)))
+ (test-equal "/api/queue?nr=100"
+ `("fake-2.0" ,(build-status scheduled))
+ (match (call-with-input-string
+ (utf8->string
+ (http-get-body
+ (test-cuirass-uri "/api/queue?nr=100")))
+ json->scm)
+ ((dictionary)
+ (list (hash-ref dictionary "nixname")
+ (hash-ref dictionary "buildstatus")))))
+
(test-assert "db-close"
(db-close (%db)))