[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#27650] [PATCH] tests: Add 'tailon-service-type' test.
From: |
Christopher Baines |
Subject: |
[bug#27650] [PATCH] tests: Add 'tailon-service-type' test. |
Date: |
Sun, 16 Jul 2017 16:58:15 +0100 |
* 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 <address@hidden>
+;;;
+;;; 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
- [bug#27650] [PATCH] gnu: services: admin: Add tailon., Christopher Baines, 2017/07/11
- [bug#27650] [PATCH] gnu: services: admin: Add tailon., Ludovic Courtès, 2017/07/12
- [bug#27650] [PATCH 1/2] gnu: services: admin: Add tailon., Christopher Baines, 2017/07/26
- [bug#27650] [PATCH 2/2] tests: Add 'tailon-service-type' test., Christopher Baines, 2017/07/26
- [bug#27650] [PATCH 2/2] tests: Add 'tailon-service-type' test., Ludovic Courtès, 2017/07/26
- [bug#27650] [PATCH 2/2] tests: Add 'tailon-service-type' test., Christopher Baines, 2017/07/27
- [bug#27650] [PATCH] gnu: services: admin: Add tailon., Christopher Baines, 2017/07/27
- [bug#27650] [PATCH] gnu: services: admin: Add tailon., Ludovic Courtès, 2017/07/28
- [bug#27650] [PATCH] gnu: services: admin: Add tailon., Christopher Baines, 2017/07/28
- bug#27650: [PATCH] gnu: services: admin: Add tailon., Christopher Baines, 2017/07/29
- [bug#27650] [PATCH] gnu: services: admin: Add tailon., Ludovic Courtès, 2017/07/29