From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56548) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daIKU-00041X-0f for guix-patches@gnu.org; Wed, 26 Jul 2017 05:10:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1daIKQ-0001BR-Qh for guix-patches@gnu.org; Wed, 26 Jul 2017 05:10:05 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:54086) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1daIKQ-0001BE-MJ for guix-patches@gnu.org; Wed, 26 Jul 2017 05:10:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1daIKQ-0007eE-I8 for guix-patches@gnu.org; Wed, 26 Jul 2017 05:10:02 -0400 Subject: [bug#27650] [PATCH 2/2] tests: Add 'tailon-service-type' test. Resent-Message-ID: From: Christopher Baines Date: Wed, 26 Jul 2017 10:08:53 +0100 Message-Id: <20170726090853.8987-2-mail@cbaines.net> In-Reply-To: <20170726090853.8987-1-mail@cbaines.net> References: <20170726090853.8987-1-mail@cbaines.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 27650@debbugs.gnu.org * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. * gnu/tests/web.scm: New file. --- gnu/local.mk | 1 + gnu/tests/admin.scm | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 gnu/tests/admin.scm diff --git a/gnu/local.mk b/gnu/local.mk index 9dfca9dbb..90dfcfeb5 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -479,6 +479,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..06373be14 --- /dev/null +++ b/gnu/tests/admin.scm @@ -0,0 +1,106 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2017 Christopher Baines +;;; +;;; 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 . + +(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 + (tailon-configuration + (config-file + (tailon-configuration-file + (bind "0.0.0.0:8080"))))))) + +(define* (run-tailon-test #:optional (http-port 8081)) + "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" + #$(simple-format + #f + "user,hostfwd=tcp::~A-:8080" + http-port)))) + + (mkdir #$output) + (chdir #$output) + + (test-begin "tailon") + + (test-eq "service running" + 'running! + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'tailon) + 'running!) + marionette)) + + ;; Wait for tailon to be up and running. + (sleep 5) + + (test-equal "http-get" + 200 + (let-values (((response text) + (http-get #$(simple-format + #f + "http://localhost:~A/" + http-port) + #: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.3