2
0
Fork 0
mirror of git://git.savannah.gnu.org/guix/guix-cuirass.git synced 2023-12-14 06:03:04 +01:00
Commit graph

125 commits

Author SHA1 Message Date
Mathieu Othacehe cb1b713e0a
Delete temporary mail file. 2021-03-22 18:29:06 +01:00
Mathieu Othacehe 8f9b791e5b
Fix tests. 2021-03-20 17:18:21 +01:00
Mathieu Othacehe 6438742f99
Improve worker status page queries. 2021-03-12 17:07:52 +01:00
Mathieu Othacehe 5c9003b41d
Fix build products creation. 2021-03-12 08:35:56 +01:00
Mathieu Othacehe 82b8f825d8
Turn db-add-specification into db-add-or-update-specification. 2021-03-11 19:30:58 +01:00
Mathieu Othacehe aabeced62a
Send notifications in a separate thread. 2021-03-11 10:27:13 +01:00
Mathieu Othacehe e598f89445
Remove events support. 2021-03-11 10:26:36 +01:00
Mathieu Othacehe 50b423c2cd
Use EphemeralPG for the tests.
* README: Update dependencies.
* tests/common.scm (pg-tmp): New procedure.
(test-init-db!): Use it.
* tests/database.scm ("db-close"): Do not drop database content.
* tests/http.scm: Ditto.
* tests/metrics.scm: Ditto.
2021-03-10 07:46:17 +01:00
Mathieu Othacehe 6c5da97d46
Add evaluation retry & cancel support.
* src/cuirass/http.scm (url-handler): Add "/admin/evaluation/<id>/cancel" and
"admin/evaluation/<id>/retry" routes.
* src/cuirass/templates.scm (evaluation-info-table): Add "Cancel pending
builds" and "Retry" buttons.
2021-03-09 18:57:07 +01:00
Mathieu Othacehe d116dc36c3
database: Add db-cancel-pending-builds!.
* src/cuirass/database.scm (db-cancel-pending-builds!): New procedure.
* tests/database.scm ("db-cancel-pending-builds!"): New test.
2021-03-09 18:45:47 +01:00
Mathieu Othacehe 70394149af
database: Add db-retry-evaluation!.
* src/cuirass/database.scm (db-retry-evaluation!): New procedure.
* tests/database.scm ("db-retry-evaluation"): New test.
2021-03-09 18:31:18 +01:00
Mathieu Othacehe d13314d02d
tests: Add a common module.
* tests/common.scm: New file.
* tests/database.scm: Use it.
* tests/http.scm: Ditto.
* tests/metrics.scm: Ditto.
2021-03-09 18:06:57 +01:00
Mathieu Othacehe 870fe8a9b5
Fix tests.
* tests/database.scm ("db-register-builds"): Fix it.
2021-03-08 07:47:54 +01:00
Mathieu Othacehe 325edf2ffa
Rewrite evaluation. 2021-03-05 09:08:15 +01:00
Mathieu Othacehe 0b19e82adc
Restart the builds on unresponsive workers.
* src/cuirass/database.scm (db-remove-unresponsive-workers): Restart the
builds that are started on unresponsive workers.
* tests/database.scm ("db-remove-unresponsive-workers"): Test it.
2021-02-24 12:42:29 +01:00
Mathieu Othacehe 543e26addc
Move mu-debug to parameters module.
* src/cuirass/mail.scm (mu-debug): Remove it.
* src/cuirass/utils.scm (mu-debug): Ditto.
* src/cuirass/parameters.scm (mu-debug): New variable.
* src/cuirass/remote-server.scm (start-fetch-worker): Force parameters module
load.
* tests/database.scm: Load parameters module.
2021-02-22 14:14:15 +01:00
Mathieu Othacehe 27917657dd
Move mu-debug definition.
* tests/database.scm (mu-debug): Move to ...
* src/cuirass/utils.scm: ... here.
2021-02-22 11:52:24 +01:00
Mathieu Othacehe 4495e08542
Add notifications support.
* src/cuirass/mail.scm: New file.
* src/cuirass/notification.scm: New file.
* src/sql/upgrade-5.sql: New file.
* Makefile.am (dist_pkgmodule_DATA, dist_sql_DATA): Add them.
* src/schema.sql (Specifications)[notifications]: New field.
* bin/cuirass.in: Wrap inside the "with-notification" macro.
* src/cuirass/remote-server.scm (remote-server): Ditto.
* src/cuirass/database.scm (db-add-specification): Add notifications field.
(db-get-specifications): Ditto.
(db-update-build-status!): Send notifications.
* tests/mail.sh: New file.
* tests/database.scm (mu-debug, tmp-mail): New variables.
(mailer): New procedure.
(example-spec): Add an email notification.
("mail-notification"): New test case.
2021-02-21 09:55:41 +01:00
Mathieu Othacehe 4a0cea2245
database: Add "db-restart-evaluation!" support.
* src/cuirass/database.scm (db-restart-evaluation!): New procedure.
* tests/database.scm (db-restart-evaluation!): New test.
2021-02-18 15:12:54 +01:00
Mathieu Othacehe 31342ff80f
database: Add db-restart-build! support.
* src/cuirass/database.scm (db-restart-build!): New procedure.
* tests/database.scm (db-restart-build!): New test.
2021-02-17 19:11:38 +01:00
Mathieu Othacehe 6b59c251c6
Fix tests.
* tests/database.scm (%dummy-worker): Fix tests.
2021-02-14 15:32:09 +01:00
Mathieu Othacehe 8bdc7ee535
Fix weather value.
* src/cuirass/database.scm (db-get-builds): Fix weather value.
* tests/http.scm (build-query-result): Adapt it.
2021-02-02 14:29:16 +01:00
Mathieu Othacehe 4f4d7ff7db
Move weather field to database.
* src/sql/upgrade-4.sql: New file.
* Makefile.am (dist_sql_DATA): Add it.
* src/schema.sql (Builds)[weather]: New field.
(Builds_weather_evaluation): New index.
* src/cuirass/database.scm (db-get-last-status): New procedure.
(db-update-build-status!): Use it and update the new weather field.
(db-get-builds): Adapt it.
* tests/http.scm (build-query-result): Ditto.
2021-02-02 11:56:28 +01:00
Mathieu Othacehe d7282c05c0
Add build weather support.
* src/cuirass/database.scm (build-weather): New macro.
(build-status->weather): New procedure.
(db-get-builds): Return the build weather using the new procedure.
* src/cuirass/http.scm (build->hydra-build): Also return the weather.
* src/cuirass/templates.scm (weather-class, weather-title): New procedures.
(build-eval-table): Display the weather.
* tests/database.scm ("db-get-build weather"): New tests.
* tests/http.scm (build-query-result): Adapt it.
2021-02-01 14:27:24 +01:00
Mathieu Othacehe 74c1a94a4d
Introduce build "last_status" field.
* src/sql/upgrade-3.sql: New file.
* Makefile.am (dist_sql_DATA): Add it.
* src/schema.sql (Builds)[last_status]: New field.
* src/cuirass/database.scm (db-update-build-status!): Honor it.
(db-get-builds): Return it.
* tests/database.scm ("db-update-build-status!"): New test.
2021-02-01 11:45:10 +01:00
Mathieu Othacehe e9e0943945
Remove workers hash table.
* src/cuirass/database.scm (db-add-worker): Rename ...
(db-add-or-update-worker): ... into this new procedure.
(db-get-worker, db-remove-unresponsive-workers): New procedures.
* src/cuirass/remote-server.scm (%workers): Remove it.
(pop-build): Adapt it.
(remove-unresponsive-workers!): Remove it.
(read-worker-exp): Adapt it.
(zmq-start-proxy): Ditto.
* tests/database.scm ("db-add-worker"): Rename ...
("db-add-or-update-worker"): ... into this new test.
("db-get-worker", "db-remove-unresponsive-workers"): New tests.
2021-01-31 10:31:01 +01:00
Mathieu Othacehe 213683ad27
database: Add "db-get-build-percentage".
* src/cuirass/database.scm (db-get-build-percentage): New procedure.
* tests/database.scm ("db-get-build-percentage"): New test.
2021-01-30 14:23:29 +01:00
Mathieu Othacehe 1271b11725
Add machine field to Worker table.
* src/sql/upgrade-2.sql: New file.
* Makefile.am (dist_sql_DATA): Add it.
* src/schema.sql (Workers): Add "machine field".
* src/cuirass/database.scm (db-get-builds): Return "worker" field.
(db-add-worker): Honor new "machine" field.
(db-get-workers): Ditto.
* src/cuirass/remote-worker.scm (remote-worker): Adapt it.
* src/cuirass/remote.scm (<worker>)[machine]: New field.
(worker-machine): New procedure.
(worker->sexp, sexp->worker): Adapt accordingly.
(generate-worker-name): Ditto.
* tests/database.scm (%dummy-worker): Add "machine" field.
2021-01-30 14:18:59 +01:00
Mathieu Othacehe e61e7a5ca4
Fix tests.
* tests/database.scm (db-init): Force database creation.
* tests/http.scm (db-init): Ditto.
* tests/metrics (db-init): Ditto.
2021-01-17 12:05:31 +01:00
Mathieu Othacehe 5982316c5c
Fix tests.
* tests/database.scm: Fix tests.
2021-01-13 14:55:22 +01:00
Mathieu Othacehe cbc462679d
Switch to PostegreSQL. 2021-01-11 12:28:13 +01:00
Mathieu Othacehe ca7a7ca989
Add remote build support.
* src/cuirass/remote.scm: New file.
* src/cuirass/remote-server.scm: New file.
* src/cuirass/remote-worker.scm: New file.
* bin/remote-server.in: New file.
* bin/remote-worker.in: New file.
* Makefile.am (bin_SCRIPTS): Add new binaries,
(dist_pkgmodule_DATA): add new files,
(EXTRA_DIST): add new binaries,
(bin/remote-server, bin/remote-worker): new targets.
* .gitignore: Add new binaries.
* bin/cuirass.in (%options): Add "--build-remote" option,
(show-help): document it,
(main): honor it.
* src/cuirass/base.scm (with-build-offload-thread): New macro,
(%build-remote?, %build-offload-channel): new parameters,
(make-build-offload-thread): new procedure,
(build-derivations/offload): new procedure,
(restart-builds): use it to offload builds when %build-remote? is set,
(build-packages): ditto.
2021-01-06 21:06:04 +01:00
Mathieu Othacehe ab30c2284f
Fix tests.
This is a follow-up of ad44a9bb02.

* tests/http.scm (build-query-result): Add "evaluation" field.
2020-12-07 16:28:14 +01:00
Mathieu Othacehe df2d13621f
Use the writer worker for all write queries.
* .dir-locals.el: Add "with-queue-writer-worker".
* bin/cuirass.in: Modify "with-queue-writer-worker" scope to include the
web-server operations.
* src/cuirass/database.scm (with-db-writer-worker-thread): Export it.
(with-db-writer-worker-thread/force): New macro.
(db-add-input, db-add-checkout, db-add-specification, db-remove-specification,
db-add-evaluation, db-abort-pending-evaluations, db-set-evaluation-status,
db-set-evaluation-time, db-add-output, db-add-build-product, db-add-event,
db-delete-events-with-ids-<=-to): Use "with-db-writer-worker-thread" or
"with-db-writer-worker-thread/force" instead of "with-db-worker-thread".
* src/cuirass/metrics.scm (db-update-metrics): Ditto.
* tests/database.scm ("db-init"): Set "%db-writer-channel".
* tests/http.scm ("db-init"): Ditto.
* tests/metrics.scm ("db-init"): Ditto.
2020-10-15 09:53:53 +02:00
Mathieu Othacehe 38ee2c5b5b
Fix tests.
This is a follow-up of b67f38a7b9.

* src/cuirass/database.scm (catch-sqlite-error): New macro.
(SQLITE_CONSTRAINT_PRIMARYKEY, SQLITE_CONSTRAINT_UNIQUE, %db-writer-channel):
New variables.
* tests/database.scm (with-temporary-database): Set "%db-writer-channel".
(db-add-build-with-fixed-output): Catch sqlite error.
(db-get-pending-derivations): Do not add builds with duplicated outputs.
2020-10-14 16:28:59 +02:00
Mathieu Othacehe d22ffdfa2a
metrics: Fix tests.
* tests/metrics.scm ("builds-per-day", "new-derivations-per-day"): Fix tests
results that were depending of the local time.
("evaluation-completion-speed"): Adapt to new unit.
2020-09-17 10:39:25 +02:00
Mathieu Othacehe 78de0da831
metrics: Add evaluation related metrics.
* src/cuirass/metrics.scm (db-average-build-start-time-per-eval,
db-average-build-complete-time-per-eval, db-evaluation-completion-speed,
db-latest-evaluations): New procedures.
(%metrics): Add 'average-eval-build-start-time,
'average-eval-build-complete-time, 'evaluation-completion-speed.
(db-update-metrics): Update evaluation related metrics for the evaluations
added the past three days.
* tests/metrics.scm ("average-eval-build-start-time",
"average-eval-build-complete-time", "evaluation-completion-speed"): Add new
tests.
2020-09-16 15:58:54 +02:00
Mathieu Othacehe 8fc4794b30
tests: Improve metrics testing.
* tests/metrics.scm (nearest-exact-integer): Remove as unused.
("db-update-metrics"): Test that 'pending-builds metric is updated on
"db-update-metrics" call.
2020-09-15 17:52:18 +02:00
Mathieu Othacehe 7642748398
Add metrics testing.
* tests/metrics.scm: New file.
* Makefile.am (TESTS): Add it.
2020-09-15 17:40:05 +02:00
Mathieu Othacehe 00c7b4bb44
tests: Fix HTTP tests.
This is a follow-up of 154232bc76.

* tests/http.scm (evaluations-query-result): Add 'timestamp', 'checkouttime'
and 'evaltime' fields.
(fill-db): Pass a matching timestamp to "db-add-evaluation" calls.
2020-09-10 15:16:16 +02:00
Mathieu Othacehe f5b0d39328
Add a status field to Evaluation table.
The Evaluation table currently has an 'in_progress' field. Distinction between
succeeded and failed evaluations are based on the presence of Builds records
for the evaluation. It it also not possible to distinguish aborted evaluations
from failed evaluations.

Rename 'in_progress' field to 'status'. The 'status' field can be equal to
'started', 'succeeded', 'failed' or 'aborted'.

* src/cuirass/database.scm (evaluation-status): New exported enumeration.
(db-set-evaluations-done, db-set-evaluation-done): Remove them.
(db-abort-pending-evaluations, db-set-evaluation-status): New exported procedures.
(db-add-evaluation, db-get-builds, db-get-evaluations,
db-get-evaluations-build-summary, db-get-evaluation-summary): Adapt to use
'status' field instead of 'in_progress' field.
* src/cuirass/templates.scm (evaluation-badges): Ditto.
* src/schema.sql (Evaluations): Rename 'in_progress' field to 'status'.
* src/sql/upgrade-10.sql: New file.
* bin/cuirass.in (main): Use "db-abort-pending-evaluations" instead of
"db-set-evaluations-done".
* src/cuirass/base.scm (evaluate): Use "db-set-evaluation-status" instead of
"db-set-evaluations-done".
(build-packages): Use "db-set-evaluation-status" instead of
"db-set-evaluation-done".
* tests/database.scm (sqlite-exec): Adapt accordingly.
* tests/http.scm (evaluations-query-result): Ditto.
2020-09-10 15:16:15 +02:00
Mathieu Othacehe 154232bc76
Save evaluations and checkouts timestamps.
src/cuirass/base.scm (fetch-input): Add the commit timestamp to the returned
association list,
(process-specs): Pass a timestamp taken at procedure start and another one
taken after inputs are fetched to "db-add-evaluation" procedure. Once the
evaluation is over, call "db-set-evaluation-time" to save the evaluation
completion time.
src/cuirass/database.scm (db-set-evaluation-time): New procedure,
(db-add-checkout): Handle the "timestamp" field,
(db-add-evaluation): add "checkouttime" and "evaltime" arguments. Modify the
associated SQL query accordingly.
(db-get-builds): Use "Builds.timestamp" instead of "timestamp" as this field
is also part of the Evaluations table.
src/schema.sql (Checkouts): Add "timestamp" field,
(Evaluations): add "timestamp", "checkouttime" and "evaltime" fields.
src/sql/upgrade-9.sql: New file.
tests/database.scm (sqlite-exec): Adapt Evaluations table insertions to include
"timestamp", "checkouttime" and "evaltime" required fields.
2020-09-06 13:03:08 +02:00
Mathieu Othacehe b135a02bf2
Fix /specifications route.
Fixes <https://issues.guix.gnu.org/43163>.

* src/cuirass/http.scm (specification->json-object): New procedure,
(url-handler): use it for "/specifications" route to convert specification
objects into a representation suitable for json->scm.
* tests/http.scm ("/specifications"): Test the above route.
2020-09-02 10:43:22 +02:00
Mathieu Othacehe 2094d68053
http: Handle request parameters with no value.
Handle requests such as "/build/?nr" by ignoring parameters without any
associated value.

* src/cuirass/http.scm (request-parameters): Ignore silently parameters
without an associated value.
* tests/http.scm: Add a corresponding test case.
2020-08-03 15:27:00 +02:00
Mathieu Othacehe 410d386ea8
tests: http: Add some erroneous routes.
* tests/http.scm: Add new test cases covering some erroneous routes.
2020-08-03 14:48:45 +02:00
Mathieu Othacehe 17395e85d2
Fix spec reading when restarting builds.
When "spawn-builds" is called to restart builds, the spec is not known,
preventing build products from being created as reported here:

https://issues.guix.gnu.org/42523

Fix this issue by reading the specification in database in
"set-build-successful!" procedure.

* src/cuirass/database.scm (db-get-specification): New exported procedure,
(db-get-specifications): add an optional name argument.
* tests/database.scm (db-get-specification): Add a corresponding test-case.
* src/cuirass/base.scm (set-build-successful!): Remove spec argument and read
it directly from database instead,
(update-build-statuses!): also remove spec argument, adapt
set-build-successful! call accordingly,
(spawn-builds): remove spec argument and adapt handle-build-event and
update-build-statuses! calls accordingly,
(handle-build-event): remove spec argument, adapt
set-build-successful! call accordingly,
(build-packages): remove spec argument, adapt spawn-builds call accordingly,
(process-specs): adapt build-packages call.
2020-07-25 14:22:20 +02:00
Mathieu Othacehe 3db603c191
http: Add build products support to the API.
* src/cuirass/http.scm (build->hydra-build)[build-products]: New variable,
added to "buildproducts" field.
* tests/http.scm (build-query-result): Adapt accordingly.
2020-06-14 18:45:38 +02:00
Mathieu Othacehe f44618fc79
Add support for build products downloading.
* src/sql/upgrade-7.sql: New file.
* Makefile.am: Add it.
* src/cuirass/base.scm (create-build-outputs): New procedure,
(build-packages): call it,
(process-spec): add the new spec argument and pass it to create-build-outputs.
* src/cuirass/database.scm (db-add-build-product, db-get-build-product-path,
db-get-build-products): New exported procedures.
* src/cuirass/http.scm (respond-static-file): Move file sending to ...
(respond-file): ... this new procedure,
(url-handler): add a new "download/<id>" route, serving the requested file
with the new respond-file procedure. Also gather build products and pass them
to "build-details" for "build/<id>/details" route.
* src/cuirass/templates.scm (build-details): Honor the new "products" argument
to display all the build products associated to the given build.
* src/schema.sql (BuildProducts): New table,
(Specifications)[build_outputs]: new field.
* tests/database.scm: Add empty build-outputs spec.
* tests/http.scm: Ditto.
* examples/guix-jobs.scm: Ditto.
* examples/hello-git.scm: Ditto.
* examples/hello-singleton.scm: Ditto.
* examples/hello-subset.scm: Ditto.
* examples/random.scm: Ditto.
* doc/cuirass.texi (overview): Document it.
2020-06-10 16:42:21 +02:00
Christopher Baines e34d773faf Adjust make-worker-thread-channel to take an initializer.
While this is a generic method, and initializer function will give the
flexibility required to create multiple worker threads for performing SQLite
queries, each with it's own database connection (as a result of calling the
initializer once for each thread). Without this change, they'd all have to use
the same connection, which would not work.

* src/cuirass/utils.scm (make-worker-thread-channel): Change procedure to take
an initializer, rather than arguments directly.
* src/cuirass/database.scm (with-database): Adjust to call
make-worker-thread-channel with an initializer.
* tests/database.scm (db-init): Change to use make-worker-thread-channel
initializer.
* tests/http.scm (db-init): Change to use make-worker-thread-channel
initializer.
2020-01-25 22:32:09 +00:00
Christopher Baines 0d23a6d374 utils: Change critical section terminology to worker threads.
As far as I'm aware, it's necessary to use a separate thread for interacting
with SQLite as one of the threads used for fibers will be blocked while the
SQLite query is running.

This doesn't mean all queries have to be executed one at a time though,
providing the queries are executed outside the threads used by fibers, and a
single connection isn't used in multiple threads.

These changes start to move in this direction, first by just changing the
terminology.

* src/cuirass/base.scm (clear-build-queue, cancel-old-builds): Change
with-db-critical-section to with-db-worker-thread.
* src/cuirass/database.scm (with-db-critical-section): Rename syntax rule to
with-db-worker-thread.
(db-add-input, db-add-checkout, db-add-specification, db-remove-specification,
db-get-inputs, db-get-specification, db-add-evaluation,
db-set-evaluations-done, db-set-evaluation-done, db-add-derivation-output,
db-add-build, db-update-build-status!, db-get-output, db-get-outputs,
db-get-builds-by-search, db-get-builds, db-get-build derivation-or-id,
db-add-event, db-get-events, db-delete-events-with-ids-<=-to,
db-get-pending-derivations, db-get-checkouts, db-get-evaluations,
db-get-evaluations-build-summary, db-get-evaluations-id-max,
db-get-evaluation-summary, db-get-builds-query-min, db-get-builds-query-max,
db-get-builds-min, db-get-builds-max, db-get-evaluation-specification): Change
from using with-db-critical-section to
with-db-worker-thread.
(with-database): Change syntax rule to use make-worker-thread-channel,
renaming from make-critical-section.
* src/cuirass/utils.scm (%critical-section-args): Rename parameter to
%worker-thread-args.
(make-critical-section): Rename to make-worker-thread-channel, and adjust
parameter and docstring.
(call-with-critical-section): Rename to call-with-worker-thread and adjust
parameter.
(with-critical-section): Rename to with-worker-thread, and adjust to call
call-with-worker-thread.
* tests/database.scm (db-init): Use make-worker-thread-channel rather than
make-critical-section.
* tests/http.scm (db-init): Use make-worker-thread-channel rather than
make-critical-section.
2020-01-25 22:32:09 +00:00