diff options
| author | Christopher Baines <mail@cbaines.net> | 2017-08-19 12:56:07 +0100 |
|---|---|---|
| committer | Christopher Baines <mail@cbaines.net> | 2017-08-23 12:48:11 +0100 |
| commit | c075c8fd0c79293a1461f78c7f7b141af23fa7bf (patch) | |
| tree | ae9135e0a7417d90a4c51b7369b38720648d5e61 /gnu/tests/virtualization.scm | |
| parent | e6051057ab926daa19a00a2d8dbd678ecb9be95c (diff) | |
tests: Add 'libvirt-service-type' test.
* gnu/tests/virtualization.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
Diffstat (limited to 'gnu/tests/virtualization.scm')
| -rw-r--r-- | gnu/tests/virtualization.scm | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/gnu/tests/virtualization.scm b/gnu/tests/virtualization.scm new file mode 100644 index 00000000000..c2939355b25 --- /dev/null +++ b/gnu/tests/virtualization.scm | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | ||
| 2 | ;;; Copyright © 2017 Christopher Baines <mail@cbaines.net> | ||
| 3 | ;;; | ||
| 4 | ;;; This file is part of GNU Guix. | ||
| 5 | ;;; | ||
| 6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | ||
| 7 | ;;; under the terms of the GNU General Public License as published by | ||
| 8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | ||
| 9 | ;;; your option) any later version. | ||
| 10 | ;;; | ||
| 11 | ;;; GNU Guix is distributed in the hope that it will be useful, but | ||
| 12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | ;;; GNU General Public License for more details. | ||
| 15 | ;;; | ||
| 16 | ;;; You should have received a copy of the GNU General Public License | ||
| 17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | (define-module (gnu tests virtualization) | ||
| 20 | #:use-module (gnu tests) | ||
| 21 | #:use-module (gnu system) | ||
| 22 | #:use-module (gnu system file-systems) | ||
| 23 | #:use-module (gnu system vm) | ||
| 24 | #:use-module (gnu services) | ||
| 25 | #:use-module (gnu services dbus) | ||
| 26 | #:use-module (gnu services networking) | ||
| 27 | #:use-module (gnu services virtualization) | ||
| 28 | #:use-module (gnu packages virtualization) | ||
| 29 | #:use-module (guix gexp) | ||
| 30 | #:use-module (guix store) | ||
| 31 | #:export (%test-libvirt)) | ||
| 32 | |||
| 33 | (define %libvirt-os | ||
| 34 | (simple-operating-system | ||
| 35 | (dhcp-client-service) | ||
| 36 | (dbus-service) | ||
| 37 | (polkit-service) | ||
| 38 | (service libvirt-service-type))) | ||
| 39 | |||
| 40 | (define (run-libvirt-test) | ||
| 41 | "Run tests in %LIBVIRT-OS." | ||
| 42 | (define os | ||
| 43 | (marionette-operating-system | ||
| 44 | %libvirt-os | ||
| 45 | #:imported-modules '((gnu services herd) | ||
| 46 | (guix combinators)))) | ||
| 47 | |||
| 48 | (define vm | ||
| 49 | (virtual-machine | ||
| 50 | (operating-system os) | ||
| 51 | (port-forwardings '()))) | ||
| 52 | |||
| 53 | (define test | ||
| 54 | (with-imported-modules '((gnu build marionette)) | ||
| 55 | #~(begin | ||
| 56 | (use-modules (srfi srfi-11) (srfi srfi-64) | ||
| 57 | (gnu build marionette)) | ||
| 58 | |||
| 59 | (define marionette | ||
| 60 | (make-marionette (list #$vm))) | ||
| 61 | |||
| 62 | (mkdir #$output) | ||
| 63 | (chdir #$output) | ||
| 64 | |||
| 65 | (test-begin "libvirt") | ||
| 66 | |||
| 67 | (test-assert "service running" | ||
| 68 | (marionette-eval | ||
| 69 | '(begin | ||
| 70 | (use-modules (gnu services herd)) | ||
| 71 | (match (start-service 'libvirtd) | ||
| 72 | (#f #f) | ||
| 73 | (('service response-parts ...) | ||
| 74 | (match (assq-ref response-parts 'running) | ||
| 75 | ((pid) (number? pid)))))) | ||
| 76 | marionette)) | ||
| 77 | |||
| 78 | (test-eq "fetch version" | ||
| 79 | 0 | ||
| 80 | (marionette-eval | ||
| 81 | `(begin | ||
| 82 | (system* ,(string-append #$libvirt "/bin/virsh") | ||
| 83 | "-c" "qemu:///system" "version")) | ||
| 84 | marionette)) | ||
| 85 | |||
| 86 | (test-end) | ||
| 87 | (exit (= (test-runner-fail-count (test-runner-current)) 0))))) | ||
| 88 | |||
| 89 | (gexp->derivation "libvirt-test" test)) | ||
| 90 | |||
| 91 | (define %test-libvirt | ||
| 92 | (system-test | ||
| 93 | (name "libvirt") | ||
| 94 | (description "Connect to the running LIBVIRT service.") | ||
| 95 | (value (run-libvirt-test)))) | ||
