guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/02: tests: databases: Add a simple test for MySQL.


From: Christopher Baines
Subject: 02/02: tests: databases: Add a simple test for MySQL.
Date: Sun, 8 Oct 2017 12:32:12 -0400 (EDT)

cbaines pushed a commit to branch master
in repository guix.

commit 02bc41c4cedd15c6a76ecd5218f9b5848de8baea
Author: Christopher Baines <address@hidden>
Date:   Sat Sep 9 15:31:38 2017 +0100

    tests: databases: Add a simple test for MySQL.
    
    Previously, the activation phase for this service caused some systems using 
it
    to not boot. This test checks that it's possible to boot a system using it,
    and at least start the service.
    
    * gnu/tests/databases.scm (%mysql-os, %test-mysql): New variables.
      (run-mysql-test): New procedure.
---
 gnu/tests/databases.scm | 61 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 60 insertions(+), 1 deletion(-)

diff --git a/gnu/tests/databases.scm b/gnu/tests/databases.scm
index 9e335b2..e709769 100644
--- a/gnu/tests/databases.scm
+++ b/gnu/tests/databases.scm
@@ -29,7 +29,8 @@
   #:use-module (guix gexp)
   #:use-module (guix store)
   #:export (%test-memcached
-            %test-mongodb))
+            %test-mongodb
+            %test-mysql))
 
 (define %memcached-os
   (simple-operating-system
@@ -205,3 +206,61 @@
    (name "mongodb")
    (description "Connect to a running MONGODB server.")
    (value (run-mongodb-test))))
+
+
+;;;
+;;; The MySQL service.
+;;;
+
+(define %mysql-os
+  (simple-operating-system
+   (mysql-service)))
+
+(define* (run-mysql-test)
+  "Run tests in %MYSQL-OS."
+  (define os
+    (marionette-operating-system
+     %mysql-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-11) (srfi srfi-64)
+                       (gnu build marionette))
+
+          (define marionette
+            (make-marionette (list #$vm)))
+
+          (mkdir #$output)
+          (chdir #$output)
+
+          (test-begin "mysql")
+
+          (test-assert "service running"
+            (marionette-eval
+             '(begin
+                (use-modules (gnu services herd))
+                (match (start-service 'mysql)
+                  (#f #f)
+                  (('service response-parts ...)
+                   (match (assq-ref response-parts 'running)
+                     ((pid) (number? pid))))))
+             marionette))
+
+          (test-end)
+          (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
+
+  (gexp->derivation "mysql-test" test))
+
+(define %test-mysql
+  (system-test
+   (name "mysql")
+   (description "Start the MySQL service.")
+   (value (run-mysql-test))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]