tests: Remove outdated comment.
[jackhill/guix/guix.git] / gnu / tests / nfs.scm
CommitLineData
7d73b2c6 1;;; GNU Guix --- Functional package management for GNU
8b113790 2;;; Copyright © 2016, 2017 Ludovic Courtès <ludo@gnu.org>
7d73b2c6 3;;; Copyright © 2016 John Darrington <jmd@gnu.org>
b09a8da4 4;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
fdfdecdb 5;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
7d73b2c6
JD
6;;;
7;;; This file is part of GNU Guix.
8;;;
9;;; GNU Guix is free software; you can redistribute it and/or modify it
10;;; under the terms of the GNU General Public License as published by
11;;; the Free Software Foundation; either version 3 of the License, or (at
12;;; your option) any later version.
13;;;
14;;; GNU Guix is distributed in the hope that it will be useful, but
15;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;;; GNU General Public License for more details.
18;;;
19;;; You should have received a copy of the GNU General Public License
20;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22(define-module (gnu tests nfs)
23 #:use-module (gnu tests)
fdfdecdb 24 #:use-module (gnu bootloader)
b09a8da4 25 #:use-module (gnu bootloader grub)
7d73b2c6 26 #:use-module (gnu system)
7d73b2c6
JD
27 #:use-module (gnu system file-systems)
28 #:use-module (gnu system shadow)
29 #:use-module (gnu system vm)
30 #:use-module (gnu services)
31 #:use-module (gnu services base)
32 #:use-module (gnu services nfs)
33 #:use-module (gnu services networking)
34 #:use-module (gnu packages onc-rpc)
35 #:use-module (guix gexp)
36 #:use-module (guix store)
37 #:use-module (guix monads)
38 #:export (%test-nfs))
39
40(define %base-os
41 (operating-system
42 (host-name "olitupmok")
43 (timezone "Europe/Berlin")
44 (locale "en_US.UTF-8")
45
fdfdecdb
TGR
46 (bootloader (bootloader-configuration
47 (bootloader grub-bootloader)
48 (target "/dev/sdX")))
7d73b2c6
JD
49 (file-systems %base-file-systems)
50 (users %base-user-accounts)
51 (packages (cons*
52 rpcbind
53 %base-packages))
54 (services (cons*
55 (service rpcbind-service-type
56 (rpcbind-configuration))
57 (dhcp-client-service)
58 %base-services))))
59
60(define (run-nfs-test name socket)
61 "Run a test of an OS running RPC-SERVICE, which should create SOCKET."
8b113790
LC
62 (define os
63 (marionette-operating-system
64 %base-os
65 #:imported-modules '((gnu services herd)
66 (guix combinators))))
67
68 (define test
69 (with-imported-modules '((gnu build marionette))
70 #~(begin
71 (use-modules (gnu build marionette)
72 (srfi srfi-64))
73
74 (define marionette
75 (make-marionette (list #$(virtual-machine os))))
76
77 (define (wait-for-socket file)
78 ;; Wait until SOCKET exists in the guest
79 (marionette-eval
80 `(let loop ((i 10))
81 (cond ((and (file-exists? ,file)
82 (eq? 'socket (stat:type (stat ,file))))
83 #t)
84 ((> i 0)
85 (sleep 1)
86 (loop (- i 1)))
87 (else
88 (error "Socket didn't show up: " ,file))))
89 marionette))
90
91 (mkdir #$output)
92 (chdir #$output)
93
94 (test-begin "rpc-daemon")
95
96 ;; Wait for the rpcbind daemon to be up and running.
97 (test-eq "RPC service running"
98 'running!
99 (marionette-eval
100 '(begin
101 (use-modules (gnu services herd))
102 (start-service 'rpcbind-daemon)
103 'running!)
104 marionette))
105
106 ;; Check the socket file and that the service is still running.
107 (test-assert "RPC socket exists"
108 (and
109 (wait-for-socket #$socket)
110 (marionette-eval
111 '(begin
112 (use-modules (gnu services herd)
113 (srfi srfi-1))
114
115 (live-service-running
116 (find (lambda (live)
117 (memq 'rpcbind-daemon
118 (live-service-provision live)))
119 (current-services))))
120 marionette)))
121
122 (test-assert "Probe RPC daemon"
123 (marionette-eval
124 '(zero? (system* "rpcinfo" "-p"))
125 marionette))
126
127 (test-end)
128 (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
129
130 (gexp->derivation name test))
7d73b2c6
JD
131
132(define %test-nfs
133 (system-test
134 (name "nfs")
135 (description "Test some things related to NFS.")
136 (value (run-nfs-test name "/var/run/rpcbind.sock"))))