diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2018-03-14 17:37:20 +0100 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2018-03-14 17:37:20 +0100 |
commit | 8c72ed923d77ee55989965bb02628043799b9548 (patch) | |
tree | 802e6eb910719a98fa09bf7c2bd884097f649adc /gnu/tests | |
parent | 189be331acfda1c242a9c85fca8d2a0356742f48 (diff) | |
parent | aac6cbbfede0bbfafdbbeeb460f00a244333895d (diff) | |
download | guix-8c72ed923d77ee55989965bb02628043799b9548.tar.gz |
Merge branch 'master' into core-updates
Diffstat (limited to 'gnu/tests')
-rw-r--r-- | gnu/tests/databases.scm | 55 | ||||
-rw-r--r-- | gnu/tests/install.scm | 11 | ||||
-rw-r--r-- | gnu/tests/mail.scm | 120 | ||||
-rw-r--r-- | gnu/tests/version-control.scm | 3 |
4 files changed, 181 insertions, 8 deletions
diff --git a/gnu/tests/databases.scm b/gnu/tests/databases.scm index e7097690a0..5c8ca85c13 100644 --- a/gnu/tests/databases.scm +++ b/gnu/tests/databases.scm @@ -30,6 +30,7 @@ #:use-module (guix store) #:export (%test-memcached %test-mongodb + %test-postgresql %test-mysql)) (define %memcached-os @@ -209,6 +210,60 @@ ;;; +;;; The PostgreSQL service. +;;; + +(define %postgresql-os + (simple-operating-system + (service postgresql-service-type))) + +(define (run-postgresql-test) + "Run tests in %POSTGRESQL-OS." + (define os + (marionette-operating-system + %postgresql-os + #:imported-modules '((gnu services herd) + (guix combinators)))) + + (define vm + (virtual-machine + (operating-system os) + (memory-size 512))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (srfi srfi-64) + (gnu build marionette)) + + (define marionette + (make-marionette (list #$vm))) + + (mkdir #$output) + (chdir #$output) + + (test-begin "postgresql") + + (test-assert "service running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'postgres)) + marionette)) + + (test-end) + (exit (= (test-runner-fail-count (test-runner-current)) 0))))) + + (gexp->derivation "postgresql-test" test)) + +(define %test-postgresql + (system-test + (name "postgresql") + (description "Start the PostgreSQL service.") + (value (run-postgresql-test)))) + + +;;; ;;; The MySQL service. ;;; diff --git a/gnu/tests/install.scm b/gnu/tests/install.scm index 3ac4a579da..e3bb1b46af 100644 --- a/gnu/tests/install.scm +++ b/gnu/tests/install.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2016, 2017 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr> ;;; ;;; This file is part of GNU Guix. @@ -565,11 +565,10 @@ where /gnu lives on a separate partition.") (bootloader grub-bootloader) (target "/dev/vdb"))) (kernel-arguments '("console=ttyS0")) - (initrd (lambda (file-systems . rest) - ;; Add a kernel module for RAID-0 (aka. "stripe"). - (apply base-initrd file-systems - #:extra-modules '("raid0") - rest))) + + ;; Add a kernel module for RAID-0 (aka. "stripe"). + (initrd-modules (cons "raid0" %base-initrd-modules)) + (mapped-devices (list (mapped-device (source (list "/dev/vda2" "/dev/vda3")) (target "/dev/md0") diff --git a/gnu/tests/mail.scm b/gnu/tests/mail.scm index 312df9b1cd..4de13b8684 100644 --- a/gnu/tests/mail.scm +++ b/gnu/tests/mail.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2016 Sou Bunnbu <iyzsong@member.fsf.org> ;;; Copyright © 2017 Carlo Zancanaro <carlo@zancanaro.id.au> ;;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -29,7 +30,8 @@ #:use-module (guix store) #:use-module (ice-9 ftw) #:export (%test-opensmtpd - %test-exim)) + %test-exim + %test-dovecot)) (define %opensmtpd-os (simple-operating-system @@ -279,3 +281,119 @@ acl_check_data: (name "exim") (description "Send an email to a running an Exim server.") (value (run-exim-test)))) + +(define %dovecot-os + (simple-operating-system + (dhcp-client-service) + (dovecot-service #:config + (dovecot-configuration + (disable-plaintext-auth? #f) + (ssl? "no") + (auth-mechanisms '("anonymous")) + (auth-anonymous-username "alice") + (mail-location + (string-append "maildir:~/Maildir" + ":INBOX=~/Maildir/INBOX" + ":LAYOUT=fs")))))) + +(define (run-dovecot-test) + "Return a test of an OS running Dovecot service." + (define vm + (virtual-machine + (operating-system (marionette-operating-system + %dovecot-os + #:imported-modules '((gnu services herd)))) + (port-forwardings '((8143 . 143))))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (gnu build marionette) + (ice-9 iconv) + (ice-9 rdelim) + (rnrs base) + (rnrs bytevectors) + (srfi srfi-64)) + + (define marionette + (make-marionette '(#$vm))) + + (define* (message-length message #:key (encoding "iso-8859-1")) + (bytevector-length (string->bytevector message encoding))) + + (define message "From: test@example.com\n\ +Subject: Hello Nice to meet you!") + + (mkdir #$output) + (chdir #$output) + + (test-begin "dovecot") + + ;; Wait for dovecot to be up and running. + (test-eq "dovecot running" + 'running! + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'dovecot) + 'running!) + marionette)) + + ;; Check Dovecot service's PID. + (test-assert "service process id" + (let ((pid + (number->string (wait-for-file "/var/run/dovecot/master.pid" + marionette)))) + (marionette-eval `(file-exists? (string-append "/proc/" ,pid)) + marionette))) + + (test-assert "accept an email" + (let ((imap (socket AF_INET SOCK_STREAM 0)) + (addr (make-socket-address AF_INET INADDR_LOOPBACK 8143))) + (connect imap addr) + ;; Be greeted. + (read-line imap) ;OK + ;; Authenticate + (write-line "a AUTHENTICATE ANONYMOUS" imap) + (read-line imap) ;+ + (write-line "c2lyaGM=" imap) + (read-line imap) ;OK + ;; Create a TESTBOX mailbox + (write-line "a CREATE TESTBOX" imap) + (read-line imap) ;OK + ;; Append a message to a TESTBOX mailbox + (write-line (format #f "a APPEND TESTBOX {~a}" + (number->string (message-length message))) + imap) + (read-line imap) ;+ + (write-line message imap) + (read-line imap) ;OK + ;; Logout + (write-line "a LOGOUT" imap) + (close imap) + #t)) + + (test-equal "mail arrived" + message + (marionette-eval + '(begin + (use-modules (ice-9 ftw) + (ice-9 match)) + (let ((TESTBOX/new "/home/alice/Maildir/TESTBOX/new/")) + (match (scandir TESTBOX/new) + (("." ".." message-file) + (call-with-input-file + (string-append TESTBOX/new message-file) + get-string-all))))) + marionette)) + + (test-end) + (exit (= (test-runner-fail-count (test-runner-current)) 0))))) + + (gexp->derivation "dovecot-test" test)) + +(define %test-dovecot + (system-test + (name "dovecot") + (description "Connect to a running Dovecot server.") + (value (run-dovecot-test)))) diff --git a/gnu/tests/version-control.scm b/gnu/tests/version-control.scm index 9882cdbe28..8024739734 100644 --- a/gnu/tests/version-control.scm +++ b/gnu/tests/version-control.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2017 Oleg Pykhalov <go.wigust@gmail.com> +;;; Copyright © 2017, 2018 Oleg Pykhalov <go.wigust@gmail.com> ;;; Copyright © 2017, 2018 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org> ;;; @@ -26,6 +26,7 @@ #:use-module (gnu system vm) #:use-module (gnu services) #:use-module (gnu services version-control) + #:use-module (gnu services cgit) #:use-module (gnu services web) #:use-module (gnu services networking) #:use-module (gnu packages version-control) |