Archived
1
0
Fork 0

tests: nfs: Improve "nfs-root-fs".

Follow-up to a1a39ed5a4.

* gnu/tests/nfs.scm (run-nfs-root-fs-test): Improve tests.
This commit is contained in:
Danny Milosavljevic 2020-09-07 18:54:00 +02:00
parent a1a39ed5a4
commit c4fe53bd11
No known key found for this signature in database
GPG key ID: E71A35542C30BAA5

View file

@ -264,13 +264,13 @@
directories can be mounted.") directories can be mounted.")
(value (run-nfs-server-test)))) (value (run-nfs-server-test))))
(define (run-nfs-root-fs-test) (define (run-nfs-root-fs-test)
"Run a test of an OS mounting its root file system via NFS." "Run a test of an OS mounting its root file system via NFS."
(define nfs-root-server-os (define nfs-root-server-os
(marionette-operating-system (marionette-operating-system
(operating-system (operating-system
(inherit %nfs-os) (inherit %nfs-os)
(file-systems %base-file-systems)
(services (services
(modify-services (operating-system-user-services %nfs-os) (modify-services (operating-system-user-services %nfs-os)
(nfs-service-type (nfs-service-type
@ -315,13 +315,15 @@ directories can be mounted.")
(mkdir #$output) (mkdir #$output)
(chdir #$output) (chdir #$output)
(test-begin "start-nfs-root-server") (test-begin "start-nfs-boot-test")
(marionette-eval (marionette-eval
'(begin '(begin
(use-modules (gnu services herd)) (use-modules (gnu services herd))
(current-output-port (current-output-port
(open-file "/dev/console" "w0")) (open-file "/dev/console" "w0"))
;; FIXME: Instead statfs "/" and "/export" and wait until they
;; are different file systems.
(sleep 10)
(chmod "/export" #o777) (chmod "/export" #o777)
(symlink "/gnu" "/export/gnu") (symlink "/gnu" "/export/gnu")
(start-service 'nscd) (start-service 'nscd)
@ -333,23 +335,30 @@ directories can be mounted.")
(test-assert "nfs services are running" (test-assert "nfs services are running"
(wait-for-file "/var/run/rpc.statd.pid" server-marionette)) (wait-for-file "/var/run/rpc.statd.pid" server-marionette))
(test-begin "boot-nfs-root-client")
(marionette-eval (marionette-eval
'(begin '(begin
(use-modules (gnu services herd)) (use-modules (gnu services herd))
(use-modules (rnrs io ports))
(current-output-port (current-output-port
(open-file "/dev/console" "w0")) (open-file "/dev/console" "w0"))
(with-output-to-file "/var/run/mounts" (let ((content (call-with-input-file "/proc/mounts" get-string-all)))
(lambda () (system* "mount"))) (call-with-output-file "/mounts.new"
(chmod "/var/run/mounts" #o777)) (lambda (port)
(display content port))))
(chmod "/mounts.new" #o777)
(rename-file "/mounts.new" "/mounts"))
client-marionette) client-marionette)
(test-assert "nfs-root-client booted") (test-assert "nfs-root-client booted")
(test-assert "nfs client deposited file"
(wait-for-file "/export/mounts" server-marionette))
(marionette-eval (marionette-eval
'(begin '(begin
(and (file-exists? "/export/var/run/mounts") (current-output-port
(system* "cat" "/export/var/run/mounts"))) (open-file "/dev/console" "w0"))
(call-with-input-file "/export/mounts" display))
server-marionette) server-marionette)
(test-end) (test-end)