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