all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#30868: test-suite fails: publish.scm
@ 2018-03-19 23:48 Martin Castillo
  2018-03-22 11:56 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Castillo @ 2018-03-19 23:48 UTC (permalink / raw)
  To: 30868


[-- Attachment #1.1.1: Type: text/plain, Size: 129 bytes --]

make check TESTS=tests/publish.scm
results in the attached log

-- 
GPG: 7FDE 7190 2F73 2C50 236E  403D CC13 48F1 E644 08EC

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: test-suite.log --]
[-- Type: text/x-log; name="test-suite.log", Size: 27844 bytes --]

==================================================
   GNU Guix 0.14.0.3450-be5ed: ./test-suite.log
==================================================

# TOTAL: 18
# PASS:  17
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

FAIL: tests/publish
===================

test-name: /nix-cache-info
location: /home/mcd/guix/tests/publish.scm:128
source:
+ (test-equal
+   "/nix-cache-info"
+   (format
+     #f
+     "StoreDir: ~a\nWantMassQuery: 0\nPriority: 100\n"
+     %store-directory)
+   (http-get-body (publish-uri "/nix-cache-info")))
expected-value: "StoreDir: /home/mcd/guix/test-tmp/store\nWantMassQuery: 0\nPriority: 100\n"
actual-value: "StoreDir: /home/mcd/guix/test-tmp/store\nWantMassQuery: 0\nPriority: 100\n"
result: PASS

test-name: /*.narinfo
location: /home/mcd/guix/tests/publish.scm:133
source:
+ (test-equal
+   "/*.narinfo"
+   (let* ((info (query-path-info %store %item))
+          (unsigned-info
+            (format
+              #f
+              "StorePath: ~a\nURL: nar/~a\nCompression: none\nNarHash: sha256:~a\nNarSize: ~d\nReferences: ~a\nFileSize: ~a~%"
+              %item
+              (basename %item)
+              (bytevector->nix-base32-string
+                (path-info-hash info))
+              (path-info-nar-size info)
+              (basename (first (path-info-references info)))
+              (path-info-nar-size info)))
+          (signature
+            (base64-encode
+              (string->utf8
+                (canonical-sexp->string
+                  ((@@ (guix scripts publish) signed-string)
+                   unsigned-info))))))
+     (format
+       #f
+       "~aSignature: 1;~a;~a~%"
+       unsigned-info
+       (gethostname)
+       signature))
+   (utf8->string
+     (http-get-body
+       (publish-uri
+         (string-append
+           "/"
+           (store-path-hash-part %item)
+           ".narinfo")))))
expected-value: "StorePath: /home/mcd/guix/test-tmp/store/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item\nURL: nar/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item\nCompression: none\nNarHash: sha256:1xngcmsdkdvaycaqjfzvq4gr3gib56p2l8illglnsqzhpss47pxz\nNarSize: 120\nReferences: dlrzhcp38i3rglimlc5sd9cfv7sv6ybn-ref\nFileSize: 120\nSignature: 1;komputilo;KHNpZ25hdHVyZSAKIChkYXRhIAogIChmbGFncyBwa2NzMSkKICAoaGFzaCBzaGEyNTYgI0M5NUVBNEI2NzdERDgwMDFCNDkyNjlGMzA5MUY0QTg3OEVDRUVCNzRFMjFEQzdBMjVENUIyNDM5QzQ4MUJEQjYjKQogICkKIChzaWctdmFsIAogIChyc2EgCiAgIChzICM1MkQzN0RDQUZCNkFCMEZBMTY2OENFNDlGRDkwMTBCN0MyOUI1QjkwNDE3OTU5NzcxQTVDRUQyNTI5MUIxQUY3OEYzRTEzQkFDN0U1M0VCRjRDNUE5Q0VCMDg4MEU3RjYyMzlFODJBQUNGMTUwNkQ5NjdGQjNDREM3QjFGNEEyQTYzMEQwMjEzQTE5RTM0MjI1QjJDNjI1MzhBNkU2RDRCNjhGMjI5QTQ2NDVFQTI1OTBDQkZGREVEM0Q3RjM1QTQ4QUE2MDYxMDc4NDBDRDc1N0I4RTlFRTEzN0IzOTEyQzBCQTBDMzNCRUZBMjgwMzZCMUNGQTdDNjBGQjAxRTg0IykKICAgKQogICkKIChwdWJsaWMta2V5IAogIChyc2EgCiAgIChuICMwMEMxRjc2NDA2OUY1NEZGRTkzQTEyNkIwMjMyODkwM0U5ODRFNEFFM0FGNkRGNDAyQjVCNkIzOTA3OTExQjg4QzM4NUYxQkE3NkEwMDJFQzlERUExMDlBNTIyOEVGMEU2MkVFMzFBMDZEMUE1ODYxQ0FCNDc0RjZDODU3QUM2NkVCNjVBMTkwNUYyNUJCQTE4Njk1NzlFNzNBM0I3RkVEMTNBRjVBMTY2NzMyNkY4OENERkMyRkYyNEIwM0MxNEZEMTM4NEFBN0U3M0NBODk1NzI4ODBCNjA2RTNBOTc0RTE1MzQ3OTYzRkM3QjYzNzg1NzQ5MzZBNDc1ODBEQkNCNDUjKQogICAoZSAjMDEwMDAxIykKICAgKQogICkKICkK\n"
actual-value: "StorePath: /home/mcd/guix/test-tmp/store/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item\nURL: nar/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item\nCompression: none\nNarHash: sha256:1xngcmsdkdvaycaqjfzvq4gr3gib56p2l8illglnsqzhpss47pxz\nNarSize: 120\nReferences: dlrzhcp38i3rglimlc5sd9cfv7sv6ybn-ref\nFileSize: 120\nSignature: 1;komputilo;KHNpZ25hdHVyZSAKIChkYXRhIAogIChmbGFncyBwa2NzMSkKICAoaGFzaCBzaGEyNTYgI0M5NUVBNEI2NzdERDgwMDFCNDkyNjlGMzA5MUY0QTg3OEVDRUVCNzRFMjFEQzdBMjVENUIyNDM5QzQ4MUJEQjYjKQogICkKIChzaWctdmFsIAogIChyc2EgCiAgIChzICM1MkQzN0RDQUZCNkFCMEZBMTY2OENFNDlGRDkwMTBCN0MyOUI1QjkwNDE3OTU5NzcxQTVDRUQyNTI5MUIxQUY3OEYzRTEzQkFDN0U1M0VCRjRDNUE5Q0VCMDg4MEU3RjYyMzlFODJBQUNGMTUwNkQ5NjdGQjNDREM3QjFGNEEyQTYzMEQwMjEzQTE5RTM0MjI1QjJDNjI1MzhBNkU2RDRCNjhGMjI5QTQ2NDVFQTI1OTBDQkZGREVEM0Q3RjM1QTQ4QUE2MDYxMDc4NDBDRDc1N0I4RTlFRTEzN0IzOTEyQzBCQTBDMzNCRUZBMjgwMzZCMUNGQTdDNjBGQjAxRTg0IykKICAgKQogICkKIChwdWJsaWMta2V5IAogIChyc2EgCiAgIChuICMwMEMxRjc2NDA2OUY1NEZGRTkzQTEyNkIwMjMyODkwM0U5ODRFNEFFM0FGNkRGNDAyQjVCNkIzOTA3OTExQjg4QzM4NUYxQkE3NkEwMDJFQzlERUExMDlBNTIyOEVGMEU2MkVFMzFBMDZEMUE1ODYxQ0FCNDc0RjZDODU3QUM2NkVCNjVBMTkwNUYyNUJCQTE4Njk1NzlFNzNBM0I3RkVEMTNBRjVBMTY2NzMyNkY4OENERkMyRkYyNEIwM0MxNEZEMTM4NEFBN0U3M0NBODk1NzI4ODBCNjA2RTNBOTc0RTE1MzQ3OTYzRkM3QjYzNzg1NzQ5MzZBNDc1ODBEQkNCNDUjKQogICAoZSAjMDEwMDAxIykKICAgKQogICkKICkK\n"
result: PASS

test-name: /*.narinfo with properly encoded '+' sign
location: /home/mcd/guix/tests/publish.scm:163
source:
+ (test-equal
+   "/*.narinfo with properly encoded '+' sign"
+   (let* ((item (add-text-to-store
+                  %store
+                  "fake-gtk+"
+                  "Congrats!"))
+          (info (query-path-info %store item))
+          (unsigned-info
+            (format
+              #f
+              "StorePath: ~a\nURL: nar/~a\nCompression: none\nNarHash: sha256:~a\nNarSize: ~d\nReferences: ~%FileSize: ~a~%"
+              item
+              (uri-encode (basename item))
+              (bytevector->nix-base32-string
+                (path-info-hash info))
+              (path-info-nar-size info)
+              (path-info-nar-size info)))
+          (signature
+            (base64-encode
+              (string->utf8
+                (canonical-sexp->string
+                  ((@@ (guix scripts publish) signed-string)
+                   unsigned-info))))))
+     (format
+       #f
+       "~aSignature: 1;~a;~a~%"
+       unsigned-info
+       (gethostname)
+       signature))
+   (let ((item (add-text-to-store
+                 %store
+                 "fake-gtk+"
+                 "Congrats!")))
+     (utf8->string
+       (http-get-body
+         (publish-uri
+           (string-append
+             "/"
+             (store-path-hash-part item)
+             ".narinfo"))))))
expected-value: "StorePath: /home/mcd/guix/test-tmp/store/zyrwqbnww52cg9l22d8hjn2apqx95jgb-fake-gtk+\nURL: nar/zyrwqbnww52cg9l22d8hjn2apqx95jgb-fake-gtk%2B\nCompression: none\nNarHash: sha256:1ysbwi8icaw2g5qmwjf9k0qd4d9gazd91kf1djycpk5ahwh4kmlp\nNarSize: 128\nReferences: \nFileSize: 128\nSignature: 1;komputilo;KHNpZ25hdHVyZSAKIChkYXRhIAogIChmbGFncyBwa2NzMSkKICAoaGFzaCBzaGEyNTYgI0UyMUEyOEM3QzREMjQxMjk2Qjk0OUJCMEZCODFFM0U4RjRCQTEwNzg1MkExNTdFQjkxQUQ3RTkwQTJGREY3OUYjKQogICkKIChzaWctdmFsIAogIChyc2EgCiAgIChzICM1MTY3RkRCRUNDNjU3MjgyMkIyQTRCQzE4NkNGMjc0MUI0N0ExNjdBMjJDMzI4OTgzM0Q4ODZCRkVBODdDNjE3QUYwRjU2MEFDOUM3MUVDOTlFQjVGOTlGMEU0RDU0QTVDMkM2QTI2MThBRTUzQkJERDk5NzcyQUIyODk4ODYyQzcwMzRGMDdCMkNFQzAzMDQ4NTU4Qjg1N0NBNjNCRDY3MzA0MkM2Mzk4QjJCRURFMEZDMjgyMUMwNTQ5MEJGNzA5RkFCMThCQjdGRTlENzE2MUIzREJEN0MzN0FGNzNBQjQxMjVGRjg4RTNEMERFMzg5REEyRThBMkZGRTBBQjZBIykKICAgKQogICkKIChwdWJsaWMta2V5IAogIChyc2EgCiAgIChuICMwMEMxRjc2NDA2OUY1NEZGRTkzQTEyNkIwMjMyODkwM0U5ODRFNEFFM0FGNkRGNDAyQjVCNkIzOTA3OTExQjg4QzM4NUYxQkE3NkEwMDJFQzlERUExMDlBNTIyOEVGMEU2MkVFMzFBMDZEMUE1ODYxQ0FCNDc0RjZDODU3QUM2NkVCNjVBMTkwNUYyNUJCQTE4Njk1NzlFNzNBM0I3RkVEMTNBRjVBMTY2NzMyNkY4OENERkMyRkYyNEIwM0MxNEZEMTM4NEFBN0U3M0NBODk1NzI4ODBCNjA2RTNBOTc0RTE1MzQ3OTYzRkM3QjYzNzg1NzQ5MzZBNDc1ODBEQkNCNDUjKQogICAoZSAjMDEwMDAxIykKICAgKQogICkKICkK\n"
actual-value: "StorePath: /home/mcd/guix/test-tmp/store/zyrwqbnww52cg9l22d8hjn2apqx95jgb-fake-gtk+\nURL: nar/zyrwqbnww52cg9l22d8hjn2apqx95jgb-fake-gtk%2B\nCompression: none\nNarHash: sha256:1ysbwi8icaw2g5qmwjf9k0qd4d9gazd91kf1djycpk5ahwh4kmlp\nNarSize: 128\nReferences: \nFileSize: 128\nSignature: 1;komputilo;KHNpZ25hdHVyZSAKIChkYXRhIAogIChmbGFncyBwa2NzMSkKICAoaGFzaCBzaGEyNTYgI0UyMUEyOEM3QzREMjQxMjk2Qjk0OUJCMEZCODFFM0U4RjRCQTEwNzg1MkExNTdFQjkxQUQ3RTkwQTJGREY3OUYjKQogICkKIChzaWctdmFsIAogIChyc2EgCiAgIChzICM1MTY3RkRCRUNDNjU3MjgyMkIyQTRCQzE4NkNGMjc0MUI0N0ExNjdBMjJDMzI4OTgzM0Q4ODZCRkVBODdDNjE3QUYwRjU2MEFDOUM3MUVDOTlFQjVGOTlGMEU0RDU0QTVDMkM2QTI2MThBRTUzQkJERDk5NzcyQUIyODk4ODYyQzcwMzRGMDdCMkNFQzAzMDQ4NTU4Qjg1N0NBNjNCRDY3MzA0MkM2Mzk4QjJCRURFMEZDMjgyMUMwNTQ5MEJGNzA5RkFCMThCQjdGRTlENzE2MUIzREJEN0MzN0FGNzNBQjQxMjVGRjg4RTNEMERFMzg5REEyRThBMkZGRTBBQjZBIykKICAgKQogICkKIChwdWJsaWMta2V5IAogIChyc2EgCiAgIChuICMwMEMxRjc2NDA2OUY1NEZGRTkzQTEyNkIwMjMyODkwM0U5ODRFNEFFM0FGNkRGNDAyQjVCNkIzOTA3OTExQjg4QzM4NUYxQkE3NkEwMDJFQzlERUExMDlBNTIyOEVGMEU2MkVFMzFBMDZEMUE1ODYxQ0FCNDc0RjZDODU3QUM2NkVCNjVBMTkwNUYyNUJCQTE4Njk1NzlFNzNBM0I3RkVEMTNBRjVBMTY2NzMyNkY4OENERkMyRkYyNEIwM0MxNEZEMTM4NEFBN0U3M0NBODk1NzI4ODBCNjA2RTNBOTc0RTE1MzQ3OTYzRkM3QjYzNzg1NzQ5MzZBNDc1ODBEQkNCNDUjKQogICAoZSAjMDEwMDAxIykKICAgKQogICkKICkK\n"
result: PASS

test-name: /nar/*
location: /home/mcd/guix/tests/publish.scm:196
source:
+ (test-equal
+   "/nar/*"
+   "bar"
+   (call-with-temporary-output-file
+     (lambda (temp port)
+       (let ((nar (utf8->string
+                    (http-get-body
+                      (publish-uri
+                        (string-append "/nar/" (basename %item)))))))
+         (call-with-input-string
+           nar
+           (cut restore-file <> temp)))
+       (call-with-input-file temp read-string))))
expected-value: "bar"
actual-value: "bar"
result: PASS

test-name: /nar/gzip/*
location: /home/mcd/guix/tests/publish.scm:209
source:
+ (test-equal
+   "/nar/gzip/*"
+   "bar"
+   (call-with-temporary-output-file
+     (lambda (temp port)
+       (let ((nar (http-get-port
+                    (publish-uri
+                      (string-append "/nar/gzip/" (basename %item))))))
+         (call-with-gzip-input-port
+           nar
+           (cut restore-file <> temp)))
+       (call-with-input-file temp read-string))))
expected-value: "bar"
actual-value: "bar"
result: PASS

test-name: /nar/gzip/* is really gzip
location: /home/mcd/guix/tests/publish.scm:222
source:
+ (test-equal
+   "/nar/gzip/* is really gzip"
+   %gzip-magic-bytes
+   (let ((nar (http-get-port
+                (publish-uri
+                  (string-append "/nar/gzip/" (basename %item))))))
+     (get-bytevector-n
+       nar
+       (bytevector-length %gzip-magic-bytes))))
expected-value: #vu8(31 139)
actual-value: #vu8(31 139)
result: PASS

test-name: /*.narinfo with compression
location: /home/mcd/guix/tests/publish.scm:234
source:
+ (test-equal
+   "/*.narinfo with compression"
+   `(("StorePath" unquote %item)
+     ("URL"
+      unquote
+      (string-append "nar/gzip/" (basename %item)))
+     ("Compression" . "gzip"))
+   (let ((thread
+           (with-separate-output-ports
+             (call-with-new-thread
+               (lambda () (guix-publish "--port=6799" "-C5"))))))
+     (wait-until-ready 6799)
+     (let* ((url (string-append
+                   "http://localhost:6799/"
+                   (store-path-hash-part %item)
+                   ".narinfo"))
+            (body (http-get-port url)))
+       (filter
+         (lambda (item)
+           (match item
+                  (("Compression" . _) #t)
+                  (("StorePath" . _) #t)
+                  (("URL" . _) #t)
+                  (_ #f)))
+         (recutils->alist body)))))
expected-value: (("StorePath" . "/home/mcd/guix/test-tmp/store/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item") ("URL" . "nar/gzip/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item") ("Compression" . "gzip"))
actual-value: (("StorePath" . "/home/mcd/guix/test-tmp/store/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item") ("URL" . "nar/gzip/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item") ("Compression" . "gzip"))
result: PASS

test-name: /*.narinfo for a compressed file
location: /home/mcd/guix/tests/publish.scm:256
source:
+ (test-equal
+   "/*.narinfo for a compressed file"
+   '("none" "nar")
+   (let* ((item (add-text-to-store
+                  %store
+                  "fake.tar.gz"
+                  "This is a fake compressed file."))
+          (url (string-append
+                 "http://localhost:6799/"
+                 (store-path-hash-part item)
+                 ".narinfo"))
+          (body (http-get-port url))
+          (info (recutils->alist body)))
+     (list (assoc-ref info "Compression")
+           (dirname (assoc-ref info "URL")))))
expected-value: ("none" "nar")
actual-value: ("none" "nar")
result: PASS

test-name: custom nar path
location: /home/mcd/guix/tests/publish.scm:268
source:
+ (test-equal
+   "custom nar path"
+   (list `(("StorePath" unquote %item)
+           ("URL"
+            unquote
+            (string-append
+              "foo/bar/chbouib/"
+              (basename %item)))
+           ("Compression" . "none"))
+         200
+         404)
+   (let ((thread
+           (with-separate-output-ports
+             (call-with-new-thread
+               (lambda ()
+                 (guix-publish
+                   "--port=6798"
+                   "-C0"
+                   "--nar-path=///foo/bar//chbouib/"))))))
+     (wait-until-ready 6798)
+     (let* ((base "http://localhost:6798/")
+            (part (store-path-hash-part %item))
+            (url (string-append base part ".narinfo"))
+            (nar-url
+              (string-append
+                base
+                "foo/bar/chbouib/"
+                (basename %item)))
+            (body (http-get-port url)))
+       (list (filter
+               (lambda (item)
+                 (match item
+                        (("Compression" . _) #t)
+                        (("StorePath" . _) #t)
+                        (("URL" . _) #t)
+                        (_ #f)))
+               (recutils->alist body))
+             (response-code (http-get nar-url))
+             (response-code
+               (http-get
+                 (string-append base "nar/" (basename %item))))))))
expected-value: ((("StorePath" . "/home/mcd/guix/test-tmp/store/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item") ("URL" . "foo/bar/chbouib/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item") ("Compression" . "none")) 200 404)
actual-value: ((("StorePath" . "/home/mcd/guix/test-tmp/store/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item") ("URL" . "foo/bar/chbouib/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item") ("Compression" . "none")) 200 404)
result: PASS

test-name: /nar/ with properly encoded '+' sign
location: /home/mcd/guix/tests/publish.scm:298
source:
+ (test-equal
+   "/nar/ with properly encoded '+' sign"
+   "Congrats!"
+   (let ((item (add-text-to-store
+                 %store
+                 "fake-gtk+"
+                 "Congrats!")))
+     (call-with-temporary-output-file
+       (lambda (temp port)
+         (let ((nar (utf8->string
+                      (http-get-body
+                        (publish-uri
+                          (string-append
+                            "/nar/"
+                            (uri-encode (basename item))))))))
+           (call-with-input-string
+             nar
+             (cut restore-file <> temp)))
+         (call-with-input-file temp read-string)))))
expected-value: "Congrats!"
actual-value: "Congrats!"
result: PASS

test-name: /nar/invalid
location: /home/mcd/guix/tests/publish.scm:310
source:
+ (test-equal
+   "/nar/invalid"
+   404
+   (begin
+     (call-with-output-file
+       (string-append (%store-prefix) "/invalid")
+       (lambda (port)
+         (display
+           "This file is not a valid store item."
+           port)))
+     (response-code
+       (http-get
+         (publish-uri (string-append "/nar/invalid"))))))
expected-value: 404
actual-value: 404
result: PASS

test-name: /file/NAME/sha256/HASH
location: /home/mcd/guix/tests/publish.scm:318
source:
+ (test-equal
+   "/file/NAME/sha256/HASH"
+   "Hello, Guix world!"
+   (let* ((data "Hello, Guix world!")
+          (hash (call-with-input-string data port-sha256))
+          (drv (run-with-store
+                 %store
+                 (gexp->derivation
+                   "the-file.txt"
+                   (gexp (call-with-output-file
+                           (ungexp output)
+                           (lambda (port) (display (ungexp data) port))))
+                   #:hash-algo
+                   'sha256
+                   #:hash
+                   hash)))
+          (out (build-derivations %store (list drv))))
+     (utf8->string
+       (http-get-body
+         (publish-uri
+           (string-append
+             "/file/the-file.txt/sha256/"
+             (bytevector->nix-base32-string hash)))))))
expected-value: "Hello, Guix world!"
actual-value: "Hello, Guix world!"
result: PASS

test-name: /file/NAME/sha256/INVALID-NIX-BASE32-STRING
location: /home/mcd/guix/tests/publish.scm:336
source:
+ (test-equal
+   "/file/NAME/sha256/INVALID-NIX-BASE32-STRING"
+   404
+   (let ((uri (publish-uri
+                "/file/the-file.txt/sha256/not-a-nix-base32-string")))
+     (response-code (http-get uri))))
expected-value: 404
actual-value: 404
result: PASS

test-name: /file/NAME/sha256/INVALID-HASH
location: /home/mcd/guix/tests/publish.scm:342
source:
+ (test-equal
+   "/file/NAME/sha256/INVALID-HASH"
+   404
+   (let ((uri (publish-uri
+                (string-append
+                  "/file/the-file.txt/sha256/"
+                  (bytevector->nix-base32-string
+                    (call-with-input-string "" port-sha256))))))
+     (response-code (http-get uri))))
expected-value: 404
actual-value: 404
result: PASS

test-name: with cache
location: /home/mcd/guix/tests/publish.scm:352
source:
+ (test-equal
+   "with cache"
+   (list #t
+         `(("StorePath" unquote %item)
+           ("URL"
+            unquote
+            (string-append "nar/gzip/" (basename %item)))
+           ("Compression" . "gzip"))
+         200
+         #t
+         #t
+         404)
+   (call-with-temporary-directory
+     (lambda (cache)
+       (let ((thread
+               (with-separate-output-ports
+                 (call-with-new-thread
+                   (lambda ()
+                     (guix-publish
+                       "--port=6797"
+                       "-C2"
+                       (string-append "--cache=" cache)))))))
+         (wait-until-ready 6797)
+         (let* ((base "http://localhost:6797/")
+                (part (store-path-hash-part %item))
+                (url (string-append base part ".narinfo"))
+                (nar-url
+                  (string-append base "nar/gzip/" (basename %item)))
+                (cached
+                  (string-append
+                    cache
+                    "/gzip/"
+                    (basename %item)
+                    ".narinfo"))
+                (nar (string-append
+                       cache
+                       "/gzip/"
+                       (basename %item)
+                       ".nar"))
+                (response (http-get url)))
+           (and (= 404 (response-code response))
+                (match (assq-ref
+                         (response-headers response)
+                         'cache-control)
+                       ((((quote max-age) . ttl)) (< ttl 3600)))
+                (wait-for-file cached)
+                (let* ((body (http-get-port url))
+                       (compressed (http-get nar-url))
+                       (uncompressed
+                         (http-get
+                           (string-append base "nar/" (basename %item))))
+                       (narinfo (recutils->alist body)))
+                  (list (file-exists? nar)
+                        (filter
+                          (lambda (item)
+                            (match item
+                                   (("Compression" . _) #t)
+                                   (("StorePath" . _) #t)
+                                   (("URL" . _) #t)
+                                   (_ #f)))
+                          narinfo)
+                        (response-code compressed)
+                        (= (response-content-length compressed)
+                           (stat:size (stat nar)))
+                        (= (string->number (assoc-ref narinfo "FileSize"))
+                           (stat:size (stat nar)))
+                        (response-code uncompressed)))))))))

;;; (wait-for-file "/tmp/guix-directory.kSJWSp/gzip/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item.narinfo")
expected-value: (#t (("StorePath" . "/home/mcd/guix/test-tmp/store/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item") ("URL" . "nar/gzip/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item") ("Compression" . "gzip")) 200 #t #t 404)
actual-value: (#t (("StorePath" . "/home/mcd/guix/test-tmp/store/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item") ("URL" . "nar/gzip/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item") ("Compression" . "gzip")) 200 #t #t 404)
result: PASS

test-name: with cache, uncompressed
location: /home/mcd/guix/tests/publish.scm:412
source:
+ (test-equal
+   "with cache, uncompressed"
+   (list #t
+         `(("StorePath" unquote item)
+           ("URL"
+            unquote
+            (string-append "nar/" (basename item)))
+           ("Compression" . "none"))
+         200
+         (path-info-nar-size
+           (query-path-info %store item))
+         404)
+   (call-with-temporary-directory
+     (lambda (cache)
+       (let ((thread
+               (with-separate-output-ports
+                 (call-with-new-thread
+                   (lambda ()
+                     (guix-publish
+                       "--port=6796"
+                       "-C2"
+                       (string-append "--cache=" cache)))))))
+         (wait-until-ready 6796)
+         (let* ((base "http://localhost:6796/")
+                (part (store-path-hash-part item))
+                (url (string-append base part ".narinfo"))
+                (cached
+                  (string-append
+                    cache
+                    "/none/"
+                    (basename item)
+                    ".narinfo"))
+                (nar (string-append
+                       cache
+                       "/none/"
+                       (basename item)
+                       ".nar"))
+                (response (http-get url)))
+           (and (= 404 (response-code response))
+                (wait-for-file cached)
+                (let* ((body (http-get-port url))
+                       (compressed
+                         (http-get
+                           (string-append base "nar/gzip/" (basename item))))
+                       (uncompressed
+                         (http-get
+                           (string-append base "nar/" (basename item))))
+                       (narinfo (recutils->alist body)))
+                  (list (file-exists? nar)
+                        (filter
+                          (lambda (item)
+                            (match item
+                                   (("Compression" . _) #t)
+                                   (("StorePath" . _) #t)
+                                   (("URL" . _) #t)
+                                   (_ #f)))
+                          narinfo)
+                        (response-code uncompressed)
+                        (string->number (assoc-ref narinfo "FileSize"))
+                        (response-code compressed)))))))))

;;; (wait-for-file "/tmp/guix-directory.0r8OhR/none/knwzp6rysyr1i13jhdn2g8v2lg7qrb47-fake-compressed-thing.tar.gz.narinfo")
expected-value: (#t (("StorePath" . "/home/mcd/guix/test-tmp/store/knwzp6rysyr1i13jhdn2g8v2lg7qrb47-fake-compressed-thing.tar.gz") ("URL" . "nar/knwzp6rysyr1i13jhdn2g8v2lg7qrb47-fake-compressed-thing.tar.gz") ("Compression" . "none")) 200 176 404)
actual-value: (#t (("StorePath" . "/home/mcd/guix/test-tmp/store/knwzp6rysyr1i13jhdn2g8v2lg7qrb47-fake-compressed-thing.tar.gz") ("URL" . "nar/knwzp6rysyr1i13jhdn2g8v2lg7qrb47-fake-compressed-thing.tar.gz") ("Compression" . "none")) 200 176 404)
result: PASS

test-name: /log/NAME
location: /home/mcd/guix/tests/publish.scm:459
source:
+ (test-equal
+   "/log/NAME"
+   `(200 #t application/x-bzip2)
+   (let ((drv (run-with-store
+                %store
+                (gexp->derivation
+                  "with-log"
+                  (gexp (call-with-output-file
+                          (ungexp output)
+                          (lambda (port)
+                            (display
+                              "Hello, build log!"
+                              (current-error-port))
+                            (display "" port))))))))
+     (build-derivations %store (list drv))
+     (let* ((response
+              (http-get
+                (publish-uri
+                  (string-append
+                    "/log/"
+                    (basename (derivation->output-path drv))))
+                #:decode-body?
+                #f))
+            (base (basename (derivation-file-name drv)))
+            (log (string-append
+                   (dirname %state-directory)
+                   "/log/guix/drvs/"
+                   (string-take base 2)
+                   "/"
+                   (string-drop base 2)
+                   ".bz2")))
+       (list (response-code response)
+             (= (response-content-length response)
+                (stat:size (stat log)))
+             (first (response-content-type response))))))
expected-value: (200 #t application/x-bzip2)
actual-value: #f
actual-error:
+ (system-error
+   "stat"
+   "~A: ~S"
+   ("No such file or directory"
+    "/home/mcd/guix/test-tmp/var/log/guix/drvs/b7/nz0wvppdyr4n5sgs3b89j682sksqcb-with-log.drv.bz2")
+   (2))
result: FAIL

test-name: /log/NAME not found
location: /home/mcd/guix/tests/publish.scm:481
source:
+ (test-equal
+   "/log/NAME not found"
+   404
+   (let ((uri (publish-uri "/log/does-not-exist")))
+     (response-code (http-get uri))))
expected-value: 404
actual-value: 404
result: PASS

publishing /home/mcd/guix/test-tmp/store on 0.0.0.0, port 6799
GET /9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp.narinfo
GET /cjmf4m1ss1c2jskxcvr643rgj1ca976l.narinfo
publishing /home/mcd/guix/test-tmp/store on 0.0.0.0, port 6789
GET /nix-cache-info
GET /9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp.narinfo
GET /zyrwqbnww52cg9l22d8hjn2apqx95jgb.narinfo
GET /nar/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item
GET /nar/gzip/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item
GET /nar/gzip/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item
GET /nar/zyrwqbnww52cg9l22d8hjn2apqx95jgb-fake-gtk%2B
GET /nar/invalid
GET /file/the-file.txt/sha256/0halvvmzqz6wvp0g8sa9hda5g04j4hpnc5gd314npgarmbc2iw5f
GET /file/the-file.txt/sha256/not-a-nix-base32-string
GET /file/the-file.txt/sha256/0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
GET /log/4l2yqrd74m2xi8n5l4r1zlj8x0nzzxw9-with-log
GET /log/does-not-exist
publishing /home/mcd/guix/test-tmp/store on 0.0.0.0, port 6796
GET /knwzp6rysyr1i13jhdn2g8v2lg7qrb47.narinfo
GET /knwzp6rysyr1i13jhdn2g8v2lg7qrb47.narinfo
GET /nar/gzip/knwzp6rysyr1i13jhdn2g8v2lg7qrb47-fake-compressed-thing.tar.gz
GET /nar/knwzp6rysyr1i13jhdn2g8v2lg7qrb47-fake-compressed-thing.tar.gz
publishing /home/mcd/guix/test-tmp/store on 0.0.0.0, port 6797
GET /9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp.narinfo
GET /9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp.narinfo
GET /nar/gzip/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item
GET /nar/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item
random seed for tests: 1521502894
publishing /home/mcd/guix/test-tmp/store on 0.0.0.0, port 6798
GET /9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp.narinfo
GET /foo/bar/chbouib/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item
GET /nar/9qcfwy1pkzc6jgl4ql997g2fxd6mkrnp-item


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#30868: test-suite fails: publish.scm
  2018-03-19 23:48 bug#30868: test-suite fails: publish.scm Martin Castillo
@ 2018-03-22 11:56 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2018-03-22 11:56 UTC (permalink / raw)
  To: Martin Castillo; +Cc: 30868-done

Hello Martin,

Martin Castillo <castilma@uni-bremen.de> skribis:

> test-name: /log/NAME
> location: /home/mcd/guix/tests/publish.scm:459
> source:
> + (test-equal
> +   "/log/NAME"
> +   `(200 #t application/x-bzip2)
> +   (let ((drv (run-with-store
> +                %store
> +                (gexp->derivation
> +                  "with-log"
> +                  (gexp (call-with-output-file
> +                          (ungexp output)
> +                          (lambda (port)
> +                            (display
> +                              "Hello, build log!"
> +                              (current-error-port))
> +                            (display "" port))))))))
> +     (build-derivations %store (list drv))
> +     (let* ((response
> +              (http-get
> +                (publish-uri
> +                  (string-append
> +                    "/log/"
> +                    (basename (derivation->output-path drv))))
> +                #:decode-body?
> +                #f))
> +            (base (basename (derivation-file-name drv)))
> +            (log (string-append
> +                   (dirname %state-directory)
> +                   "/log/guix/drvs/"
> +                   (string-take base 2)
> +                   "/"
> +                   (string-drop base 2)
> +                   ".bz2")))
> +       (list (response-code response)
> +             (= (response-content-length response)
> +                (stat:size (stat log)))
> +             (first (response-content-type response))))))
> expected-value: (200 #t application/x-bzip2)
> actual-value: #f
> actual-error:
> + (system-error
> +   "stat"
> +   "~A: ~S"
> +   ("No such file or directory"
> +    "/home/mcd/guix/test-tmp/var/log/guix/drvs/b7/nz0wvppdyr4n5sgs3b89j682sksqcb-with-log.drv.bz2")
> +   (2))
> result: FAIL

Should be fixed in 04d2a16c4ffd2f3ddfbaf3848093424228e7d918.

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-22 11:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-19 23:48 bug#30868: test-suite fails: publish.scm Martin Castillo
2018-03-22 11:56 ` Ludovic Courtès

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.