database: Add db-restart-build! support.

* src/cuirass/database.scm (db-restart-build!): New procedure.
* tests/database.scm (db-restart-build!): New test.
This commit is contained in:
Mathieu Othacehe 2021-02-17 19:11:38 +01:00
parent 860fffa260
commit 31342ff80f
No known key found for this signature in database
GPG Key ID: 8354763531769CA6
2 changed files with 14 additions and 0 deletions

View File

@ -69,6 +69,7 @@
db-register-builds
db-update-build-status!
db-update-build-worker!
db-restart-build!
db-get-build-products
db-get-builds-by-search
db-get-builds
@ -833,6 +834,13 @@ UPDATE Builds SET stoptime =" now
(exec-query/bind db "UPDATE Builds SET worker=" worker
"WHERE derivation=" drv ";")))
(define (db-restart-build! build-id)
"Restart the build with BUILD-ID id."
(with-db-worker-thread db
(exec-query/bind db "UPDATE Builds SET status="
(build-status scheduled)
"WHERE id=" build-id ";")))
(define (query->bind-arguments query-string)
"Return a list of keys to query strings by parsing QUERY-STRING."
(define status-values

View File

@ -490,6 +490,12 @@ timestamp, checkouttime, evaltime) VALUES ('guix', 0, 0, 0, 0);")
(db-update-build-status! "/new-build.drv" 1)
(assq-ref (db-get-build "/new-build.drv") #:weather)))
(test-assert "db-restart-build!"
(let ((build (db-get-build "/new-build.drv")))
(db-restart-build! (assq-ref build #:id))
(eq? (assq-ref (db-get-build "/new-build.drv") #:status)
(build-status scheduled))))
(test-assert "db-close"
(begin
(exec-query (%db) (format #f "DROP OWNED BY CURRENT_USER;"))