all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Rouby Pierre-Antoine <pierre-antoine.rouby@inria.fr>
To: 31621@debbugs.gnu.org
Cc: Rouby Pierre-Antoine <pierre-antoine.rouby@inria.fr>
Subject: [bug#31621] [PATCH 3/3] gnu: tests: Add hpcguix-web.
Date: Mon, 28 May 2018 15:28:19 +0200	[thread overview]
Message-ID: <20180528132819.12534-1-pierre-antoine.rouby@inria.fr> (raw)
In-Reply-To: <20180528132450.12442-1-pierre-antoine.rouby@inria.fr>

* gnu/tests/web.scm (run-hpcguix-web-server-test): New procedure.
  (%hpcguix-web-specs, %hpcguix-web-os, %test-hpcguix-web): New variable.
---
 gnu/tests/web.scm | 83 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 82 insertions(+), 1 deletion(-)

diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm
index 1912f8f79..474a5bdb5 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,82 @@ HTTP-PORT, along with php-fpm."
    (name "php-fpm")
    (description "Test PHP-FPM through nginx.")
    (value (run-php-fpm-test))))
+
+\f
+;;;
+;;; 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
+            (let-values
+                (((response text)
+                  (begin
+                    (sleep 3)           ; HACK wait service available
+                    (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))))
-- 
2.17.0

  parent reply	other threads:[~2018-05-28 13:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-28 13:24 [bug#31621] [PATCH 1/3] gnu: Add hpcguix-web Rouby Pierre-Antoine
2018-05-28 13:28 ` [bug#31621] [PATCH 2/3] gnu: service: " Rouby Pierre-Antoine
2018-05-29  8:31   ` Rouby Pierre-Antoine
2018-05-29  8:52   ` Nils Gillmann
2018-05-30  7:25     ` Pierre-Antoine Rouby
2018-05-30  9:47     ` Rouby Pierre-Antoine
2018-05-31 16:12       ` Ludovic Courtès
2018-05-28 13:28 ` Rouby Pierre-Antoine [this message]
2018-05-29  8:57 ` [bug#31621] [PATCH 1/3] gnu: " Nils Gillmann
2018-05-30  9:41   ` Rouby Pierre-Antoine
2018-05-31 16:09     ` Ludovic Courtès
2018-05-31 22:38       ` Roel Janssen
2018-06-01  8:05 ` bug#31621: [PATCH 2/3] gnu: service: " Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180528132819.12534-1-pierre-antoine.rouby@inria.fr \
    --to=pierre-antoine.rouby@inria.fr \
    --cc=31621@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.