unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Christopher Baines <mail@cbaines.net>
To: 27650@debbugs.gnu.org
Subject: [bug#27650] [PATCH] tests: Add 'tailon-service-type' test.
Date: Sun, 16 Jul 2017 16:58:15 +0100	[thread overview]
Message-ID: <20170716155815.14496-1-mail@cbaines.net> (raw)
In-Reply-To: <87shi1etui.fsf@gnu.org>

* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
* gnu/tests/web.scm: New file.
---
 gnu/local.mk        |  1 +
 gnu/tests/admin.scm | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 97 insertions(+)
 create mode 100644 gnu/tests/admin.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index 50fac3040..4bb7ce901 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -476,6 +476,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/build/vm.scm				\
 						\
   %D%/tests.scm					\
+  %D%/tests/admin.scm				\
   %D%/tests/base.scm				\
   %D%/tests/dict.scm				\
   %D%/tests/nfs.scm				\
diff --git a/gnu/tests/admin.scm b/gnu/tests/admin.scm
new file mode 100644
index 000000000..5e2424bdb
--- /dev/null
+++ b/gnu/tests/admin.scm
@@ -0,0 +1,96 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Christopher Baines <mail@cbaines.net>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu tests admin)
+  #:use-module (gnu tests)
+  #:use-module (gnu system)
+  #:use-module (gnu system file-systems)
+  #:use-module (gnu system shadow)
+  #:use-module (gnu system vm)
+  #:use-module (gnu services)
+  #:use-module (gnu services admin)
+  #:use-module (gnu services networking)
+  #:use-module (guix gexp)
+  #:use-module (guix store)
+  #:use-module (guix monads)
+  #:export (%test-tailon))
+
+(define %tailon-os
+  ;; Operating system under test.
+  (simple-operating-system
+   (dhcp-client-service)
+   (service tailon-service-type)))
+
+(define* (run-tailon-test #:optional (http-port 8042))
+  "Run tests in %TAILON-OS, which has tailon running and listening on
+HTTP-PORT."
+  (mlet* %store-monad ((os ->   (marionette-operating-system
+                                 %tailon-os
+                                 #:imported-modules '((gnu services herd)
+                                                      (guix combinators))))
+                       (command (system-qemu-image/shared-store-script
+                                 os #:graphic? #f)))
+    (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
+              ;; Forward the guest's HTTP-PORT, where tailon is listening, to
+              ;; port 8080 in the host.
+              (make-marionette (list #$command "-net"
+                                     (string-append
+                                      "user,hostfwd=tcp::8080-:"
+                                      #$(number->string http-port)))))
+
+            (mkdir #$output)
+            (chdir #$output)
+
+            (test-begin "tailon")
+
+            ;; Wait for tailon to be up and running.
+            (test-eq "service running"
+              'running!
+              (marionette-eval
+               '(begin
+                  (use-modules (gnu services herd))
+                  (start-service 'tailon)
+                  'running!)
+               marionette))
+
+            (test-equal "http-get"
+              200
+              (let-values (((response text)
+                            (http-get "http://localhost:8080/"
+                                      #:decode-body? #t)))
+                (response-code response)))
+
+            (test-end)
+            (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
+
+    (gexp->derivation "tailon-test" test)))
+
+(define %test-tailon
+  (system-test
+   (name "tailon")
+   (description "Connect to a running Tailon server.")
+   (value (run-tailon-test))))
-- 
2.13.1

  parent reply	other threads:[~2017-07-16 15:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-11  6:56 [bug#27650] [PATCH] gnu: services: admin: Add tailon Christopher Baines
2017-07-12 12:13 ` Ludovic Courtès
2017-07-16 15:51   ` Christopher Baines
2017-07-17  8:40     ` Ludovic Courtès
2017-07-16 15:52   ` Christopher Baines
2017-07-17  9:52     ` Ludovic Courtès
2017-07-26  9:50       ` Christopher Baines
2017-07-16 15:58   ` Christopher Baines [this message]
2017-07-17  9:53     ` [bug#27650] [PATCH] tests: Add 'tailon-service-type' test Ludovic Courtès
2017-07-26  9:08 ` [bug#27650] [PATCH 1/2] gnu: services: admin: Add tailon Christopher Baines
2017-07-26  9:08   ` [bug#27650] [PATCH 2/2] tests: Add 'tailon-service-type' test Christopher Baines
2017-07-26 20:46     ` Ludovic Courtès
2017-07-27 17:33       ` Christopher Baines
2017-07-27 17:35       ` [bug#27650] [PATCH] gnu: services: admin: Add tailon Christopher Baines
2017-07-28 19:36         ` Ludovic Courtès
2017-07-28 21:00           ` Christopher Baines
2017-07-29 12:00             ` bug#27650: " Christopher Baines
2017-07-29 12:10             ` [bug#27650] " Ludovic Courtès
2017-07-26 20:40   ` [bug#27650] [PATCH 1/2] " 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

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=20170716155815.14496-1-mail@cbaines.net \
    --to=mail@cbaines.net \
    --cc=27650@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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).