aboutsummaryrefslogtreecommitdiff
path: root/gnu/tests/web.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-06-01 23:41:40 +0200
committerLudovic Courtès <ludo@gnu.org>2018-06-01 23:41:40 +0200
commita13c1bf4ca0b15fa53235c2bd6aa53e4a75c7d0f (patch)
tree8a19fb07861c685199beb9b8beb4f7d8f2a3d22a /gnu/tests/web.scm
parentbabeea3f9f46c1f1f812e590f46283e91684f327 (diff)
parent1a3e3162acafd32ff2fb675f2f780d986692c52d (diff)
downloadpatches-a13c1bf4ca0b15fa53235c2bd6aa53e4a75c7d0f.tar
patches-a13c1bf4ca0b15fa53235c2bd6aa53e4a75c7d0f.tar.gz
Merge branch 'master' into core-updates
Diffstat (limited to 'gnu/tests/web.scm')
-rw-r--r--gnu/tests/web.scm82
1 files changed, 81 insertions, 1 deletions
diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm
index 1912f8f79d..a6bf6efcfe 100644
--- a/gnu/tests/web.scm
+++ b/gnu/tests/web.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017 Christopher Baines <mail@cbaines.net>
;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
+;;; Copyright © 2018 Pierre-Antoine Rouby <pierre-antoine.rouby@inria.fr>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -31,7 +32,8 @@
#:use-module (guix store)
#:export (%test-httpd
%test-nginx
- %test-php-fpm))
+ %test-php-fpm
+ %test-hpcguix-web))
(define %index.html-contents
;; Contents of the /index.html file.
@@ -281,3 +283,81 @@ HTTP-PORT, along with php-fpm."
(name "php-fpm")
(description "Test PHP-FPM through nginx.")
(value (run-php-fpm-test))))
+
+
+;;;
+;;; hpcguix-web
+;;;
+
+(define* (run-hpcguix-web-server-test name test-os)
+ "Run tests in %HPCGUIX-WEB-OS, which has hpcguix-web running."
+ (define os
+ (marionette-operating-system
+ test-os
+ #:imported-modules '((gnu services herd)
+ (guix combinators))))
+
+ (define vm
+ (virtual-machine
+ (operating-system os)
+ (port-forwardings '((8080 . 5000)))))
+
+ (define test
+ (with-imported-modules '((gnu build marionette))
+ #~(begin
+ (use-modules (srfi srfi-11) (srfi srfi-64)
+ (gnu build marionette)
+ (web uri)
+ (web client)
+ (web response))
+
+ (define marionette
+ (make-marionette (list #$vm)))
+
+ (mkdir #$output)
+ (chdir #$output)
+
+ (test-begin #$name)
+
+ (test-assert "hpcguix-web running"
+ (marionette-eval
+ '(begin
+ (use-modules (gnu services herd))
+ (match (start-service 'hpcguix-web)
+ (#f #f)
+ (('service response-parts ...)
+ (match (assq-ref response-parts 'running)
+ ((pid) (number? pid))))))
+ marionette))
+
+ (test-equal "http-get"
+ 200
+ (begin
+ (wait-for-tcp-port 5000 marionette)
+ (let-values (((response text)
+ (http-get "http://localhost:8080")))
+ (response-code response))))
+
+ (test-end)
+ (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
+
+ (gexp->derivation (string-append name "-test") test))
+
+(define %hpcguix-web-specs
+ ;; Server config gexp.
+ #~(define site-config
+ (hpcweb-configuration
+ (title-prefix "[TEST] HPCGUIX-WEB"))))
+
+(define %hpcguix-web-os
+ (simple-operating-system
+ (dhcp-client-service)
+ (service hpcguix-web-service-type
+ (hpcguix-web-configuration
+ (specs %hpcguix-web-specs)))))
+
+(define %test-hpcguix-web
+ (system-test
+ (name "hpcguix-web")
+ (description "Connect to a running hpcguix-web server.")
+ (value (run-hpcguix-web-server-test name %hpcguix-web-os))))