services: databases: Don't specify a default postgresql version.
[jackhill/guix/guix.git] / gnu / tests / docker.scm
index 3cd3a27..ea6c9a3 100644 (file)
@@ -1,6 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2019 Danny Milosavljevic <dannym@scratchpost.org>
-;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -27,7 +27,6 @@
   #:use-module (gnu services networking)
   #:use-module (gnu services docker)
   #:use-module (gnu services desktop)
-  #:use-module (gnu packages bootstrap) ; %bootstrap-guile
   #:use-module (gnu packages docker)
   #:use-module (gnu packages guile)
   #:use-module (guix gexp)
@@ -101,7 +100,7 @@ inside %DOCKER-OS."
              marionette))
 
           (test-equal "Load docker image and run it"
-            "hello world"
+            '("hello world" "hi!" "JSON!" #o1777)
             (marionette-eval
              `(begin
                 (define slurp
@@ -117,12 +116,30 @@ inside %DOCKER-OS."
                        (repository&tag (string-drop raw-line
                                                     (string-length
                                                      "Loaded image: ")))
-                       (response (slurp
-                                  ,(string-append #$docker-cli "/bin/docker")
-                                  "run" "--entrypoint" "bin/Guile"
-                                  repository&tag
-                                  "/aa.scm")))
-                  response))
+                       (response1 (slurp
+                                   ,(string-append #$docker-cli "/bin/docker")
+                                   "run" "--entrypoint" "bin/Guile"
+                                   repository&tag
+                                   "/aa.scm"))
+                       (response2 (slurp          ;default entry point
+                                   ,(string-append #$docker-cli "/bin/docker")
+                                   "run" repository&tag
+                                   "-c" "(display \"hi!\")"))
+
+                       ;; Check whether (json) is in $GUILE_LOAD_PATH.
+                       (response3 (slurp    ;default entry point + environment
+                                   ,(string-append #$docker-cli "/bin/docker")
+                                   "run" repository&tag
+                                   "-c" "(use-modules (json))
+  (display (json-string->scm (scm->json-string \"JSON!\")))"))
+
+                       ;; Check whether /tmp exists.
+                       (response4 (slurp
+                                   ,(string-append #$docker-cli "/bin/docker")
+                                   "run" repository&tag "-c"
+                                   "(display (stat:perms (lstat \"/tmp\")))")))
+                  (list response1 response2 response3
+                        (string->number response4))))
              marionette))
 
           (test-end)
@@ -140,7 +157,7 @@ inside %DOCKER-OS."
           (version "0")
           (source #f)
           (build-system trivial-build-system)
-          (arguments `(#:guile ,%bootstrap-guile
+          (arguments `(#:guile ,guile-3.0
                        #:builder
                        (let ((out (assoc-ref %outputs "out")))
                          (mkdir out)
@@ -154,13 +171,14 @@ standard output device and then enters a new line.")
           (home-page #f)
           (license license:public-domain)))
        (profile (profile-derivation (packages->manifest
-                                     (list %bootstrap-guile
+                                     (list guile-3.0 guile-json-3
                                            guest-script-package))
                                     #:hooks '()
                                     #:locales? #f))
        (tarball (docker-image "docker-pack" profile
                               #:symlinks '(("/bin/Guile" -> "bin/guile")
                                            ("aa.scm" -> "a.scm"))
+                              #:entry-point "bin/guile"
                               #:localstatedir? #t)))
     (run-docker-test tarball)))
 
@@ -188,7 +206,7 @@ inside %DOCKER-OS."
      ;; load' must be able to store the whole image into memory, hence the
      ;; huge memory requirements.  We should avoid the volatile-root setup
      ;; instead.
-     (memory-size 3000)
+     (memory-size 3500)
      (port-forwardings '())))
 
   (define test
@@ -236,7 +254,7 @@ inside %DOCKER-OS."
                 (define (wait-for-container-file container file)
                   ;; Wait for FILE to show up in CONTAINER.
                   (docker-cli "exec" container
-                              #$(file-append guile-2.2 "/bin/guile")
+                              #$(file-append guile-3.0 "/bin/guile")
                               "-c"
                               (object->string
                                `(let loop ((n 15))