;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 Christopher Baines ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (gnu tests databases) #:use-module (gnu tests) #:use-module (gnu system) #:use-module (gnu system file-systems) #:use-module (gnu system shadow) #:use-module (gnu system vm
aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 Joshua S. Grant <jgrant@parenthetical.io>
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages libffcall)
  #:use-module ((guix licenses) #:prefix l:)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix build-system gnu))

(define-public libffcall
   (package
    (name "libffcall")
    (version "2.2")
    (source
     (origin
       (method url-fetch)
       (uri (string-append
             "mirror://gnu/libffcall/libffcall-" version ".tar.gz"))
       (sha256
        (base32
         "0ixp7kbr7y8s34nsrsdfh77ig5c2zkwr6cfg9v1gm53cggwkgypb"))))
    (build-system gnu-build-system)
    (arguments
     '(#:parallel-build? #f
       #:configure-flags '("--disable-static")))
    (synopsis "Foreign function calls from interpreters")
    (description
     "GNU Libffcall is a collection of libraries that can be used to build
foreign function call interfaces in embedded interpreters.")
    (home-page "https://www.gnu.org/software/libffcall/")
    (license l:gpl2+)))
ges (cons* mongodb %base-packages)))) (define* (run-mongodb-test #:optional (port 27017)) "Run tests in %MONGODB-OS, forwarding PORT." (define os (marionette-operating-system %mongodb-os #:imported-modules '((gnu services herd) (guix combinators)))) (define vm (virtual-machine (operating-system os) (memory-size 1024) (disk-image-size (* 1024 (expt 2 20))) (port-forwardings `((27017 . ,port))))) (define test (with-imported-modules '((gnu build marionette)) #~(begin (use-modules (srfi srfi-11) (srfi srfi-64) (gnu build marionette) (ice-9 popen) (ice-9 rdelim)) (define marionette (make-marionette (list #$vm))) (mkdir #$output) (chdir #$output) (test-begin "mongodb") (test-assert "service running" (marionette-eval '(begin (use-modules (gnu services herd)) (match (start-service 'mongodb) (#f #f) (('service response-parts ...) (match (assq-ref response-parts 'running) ((pid) (number? pid)))))) marionette)) (test-eq "test insert" 0 (system* (string-append #$mongodb "/bin/mongo") "test" "--eval" "db.testCollection.insert({data: 'test-data'})")) (test-equal "test find" "test-data" (let* ((port (open-pipe* OPEN_READ (string-append #$mongodb "/bin/mongo") "test" "--quiet" "--eval" "db.testCollection.findOne().data")) (output (read-line port)) (status (close-pipe port))) output)) (test-end) (exit (= (test-runner-fail-count (test-runner-current)) 0))))) (gexp->derivation "mongodb-test" test)) (define %test-mongodb (system-test (name "mongodb") (description "Connect to a running MONGODB server.") (value (run-mongodb-test)))) ;;; ;;; 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. ;;; (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))))