1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2017, 2018, 2019, 2020, 2021 Christopher Baines <mail@cbaines.net>
4 ;;; Copyright © 2017, 2018 Clément Lassieur <clement@lassieur.org>
5 ;;; Copyright © 2018 Pierre-Antoine Rouby <pierre-antoine.rouby@inria.fr>
6 ;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com>
8 ;;; This file is part of GNU Guix.
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23 (define-module (gnu tests ci)
24 #:use-module (gnu tests)
25 #:use-module (gnu system)
26 #:use-module (gnu system file-systems)
27 #:use-module (gnu system shadow)
28 #:use-module (gnu system vm)
29 #:use-module (gnu services)
30 #:use-module (gnu services ci)
31 #:use-module (gnu services web)
32 #:use-module (gnu services networking)
33 #:use-module (guix gexp)
34 #:use-module (guix store)
35 #:export (%test-laminar))
39 ;; Operating system under test.
40 (simple-operating-system
41 (service dhcp-client-service-type)
42 (service laminar-service-type)))
44 (define* (run-laminar-test #:optional (http-port 8080))
45 "Run tests in %LAMINAR-OS, which has laminar running and listening on
48 (marionette-operating-system
50 #:imported-modules '((gnu services herd)
56 (port-forwardings `((,http-port . 8080)))))
59 (with-imported-modules '((gnu build marionette))
61 (use-modules (srfi srfi-11) (srfi srfi-64)
63 (gnu build marionette)
69 ;; Forward the guest's HTTP-PORT, where laminar is listening, to
70 ;; port 8080 in the host.
71 (make-marionette (list #$vm)))
76 (test-begin "laminar")
78 (test-assert "service running"
81 (use-modules (gnu services herd))
82 (start-service 'laminar))
85 (define* (retry-on-error f #:key times delay)
86 (let loop ((attempt 1))
98 (if (>= attempt times)
102 (loop (+ 1 attempt))))))))
104 (test-equal "http-get"
108 (let-values (((response text)
111 "http://localhost:~A/"
113 ;; TODO: Why does decoding fail?
115 (response-code response)))
120 (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
122 (gexp->derivation "laminar-test" test))
124 (define %test-laminar
127 (description "Connect to a running Laminar server.")
128 (value (run-laminar-test))))