Subject: Re: bug#46413: tests/publish.scm fails on berlin

From: Maxim Cournoyer <[email-masked]>
Date: Fri, 15 Jul 2022 13:12:14 -0400

Hi,

Leo Famulari <[email-masked]> writes:

> I notice that tests/publish.scm crashes consistently when run "by hand"
> with `make check` on ci.guix.gnu.org:
>
> ------
> $ make check -j1
> [...]
> PASS: tests/profiles.scm
> make[4]: *** [Makefile:5520: tests/publish.log] Error 134
> make[4]: Leaving directory '/home/lfam/guix'
> make[3]: *** [Makefile:5502: check-TESTS] Error 2
> make[3]: Leaving directory '/home/lfam/guix'
> make[2]: *** [Makefile:5751: check-am] Error 2
> make[2]: Leaving directory '/home/lfam/guix'
> make[1]: *** [Makefile:5279: check-recursive] Error 1
> make[1]: Leaving directory '/home/lfam/guix'
> make: *** [Makefile:5753: check] Error 2 
> ------
>
> Since it crashes, the remainder of the tests are not run.
>
> I've attached the log, but I'm not sure what the problem is.
>
> test-name: /nix-cache-info
> location: /home/lfam/guix/tests/publish.scm:135
> 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/lfam/guix/test-tmp/store\nWantMassQuery: 0\nPriority: 100\n"
> actual-value: "StoreDir: /home/lfam/guix/test-tmp/store\nWantMassQuery: 0\nPriority: 100\n"
> result: PASS
>
> test-name: /*.narinfo
> location: /home/lfam/guix/tests/publish.scm:140
> source:
> + (test-equal
> +   "/*.narinfo"
> +   (let* ((info (query-path-info %store %item))
> +          (unsigned-info
> +            (format
> +              #f
> +              "StorePath: ~a\nURL: nar/~a\nCompression: none\nFileSize: ~a\nNarHash: sha256:~a\nNarSize: ~d\nReferences: ~a~%"
> +              %item
> +              (basename %item)
> +              (path-info-nar-size info)
> +              (bytevector->nix-base32-string
> +                (path-info-hash info))
> +              (path-info-nar-size info)
> +              (basename (first (path-info-references info)))))
> +          (signature
> +            (base64-encode
> +              (string->utf8
> +                (canonical-sexp->string
> +                  (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/lfam/guix/test-tmp/store/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item\nURL: nar/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item\nCompression: none\nFileSize: 120\nNarHash: sha256:1xngcmsdkdvaycaqjfzvq4gr3gib56p2l8illglnsqzhpss47pxz\nNarSize: 120\nReferences: 7va9x8gzhcwxv1srdiw9jx6ia9c20s0j-ref\nSignature: 1;berlin.guix.gnu.org;KHNpZ25hdHVyZSAKIChkYXRhIAogIChmbGFncyBwa2NzMSkKICAoaGFzaCBzaGEyNTYgIzdCODIxNDAyQjZCQTI3NzQ3OTI0QTdFNDUwMDdFMzYyOUM2OTUwOTFFNjlCQTI2OTc2MUIwRDRDMkRGMUJCQ0IjKQogICkKIChzaWctdmFsIAogIChyc2EgCiAgIChzICNCREVCOEY4Mjk4QzY1MkQ4NkNCRTgwQjJEMEIzMUY0MUFBODI3ODU1RkRBNDUyNjU1REQwMUQ5Mzg2RTk2OUQ2RTlFNzdFRTNDNzI2NjEwNzY4NjlFNEFGMUQ0MEM0M0Y4RjQ5MjE2Nzc2QzVFQ0Q2NDc0QkY2MjFGNDVFOTRGOTJFOTk2Nzg5Mzg2NDI2MThFNjdGQzA5RDU1MzcyNkQ5MzM5MjZFNkQ2MkQ3QzVFQTM4Mjc4NkUyQkFDRTIxQUVFNUVCMUVDMDFGNUUxQjc1M0I2NzdDMDE1RTlBMEExNjk1MkRCQjgzQUM1MjMxQURBMzBDMTFDMjMzOTA4ODdEIykKICAgKQogICkKIChwdWJsaWMta2V5IAogIChyc2EgCiAgIChuICMwMEMxRjc2NDA2OUY1NEZGRTkzQTEyNkIwMjMyODkwM0U5ODRFNEFFM0FGNkRGNDAyQjVCNkIzOTA3OTExQjg4QzM4NUYxQkE3NkEwMDJFQzlERUExMDlBNTIyOEVGMEU2MkVFMzFBMDZEMUE1ODYxQ0FCNDc0RjZDODU3QUM2NkVCNjVBMTkwNUYyNUJCQTE4Njk1NzlFNzNBM0I3RkVEMTNBRjVBMTY2NzMyNkY4OENERkMyRkYyNEIwM0MxNEZEMTM4NEFBN0U3M0NBODk1NzI4ODBCNjA2RTNBOTc0RTE1MzQ3OTYzRkM3QjYzNzg1NzQ5MzZBNDc1ODBEQkNCNDUjKQogICAoZSAjMDEwMDAxIykKICAgKQogICkKICkK\n"
> actual-value: "StorePath: /home/lfam/guix/test-tmp/store/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item\nURL: nar/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item\nCompression: none\nFileSize: 120\nNarHash: sha256:1xngcmsdkdvaycaqjfzvq4gr3gib56p2l8illglnsqzhpss47pxz\nNarSize: 120\nReferences: 7va9x8gzhcwxv1srdiw9jx6ia9c20s0j-ref\nSignature: 1;berlin.guix.gnu.org;KHNpZ25hdHVyZSAKIChkYXRhIAogIChmbGFncyBwa2NzMSkKICAoaGFzaCBzaGEyNTYgIzdCODIxNDAyQjZCQTI3NzQ3OTI0QTdFNDUwMDdFMzYyOUM2OTUwOTFFNjlCQTI2OTc2MUIwRDRDMkRGMUJCQ0IjKQogICkKIChzaWctdmFsIAogIChyc2EgCiAgIChzICNCREVCOEY4Mjk4QzY1MkQ4NkNCRTgwQjJEMEIzMUY0MUFBODI3ODU1RkRBNDUyNjU1REQwMUQ5Mzg2RTk2OUQ2RTlFNzdFRTNDNzI2NjEwNzY4NjlFNEFGMUQ0MEM0M0Y4RjQ5MjE2Nzc2QzVFQ0Q2NDc0QkY2MjFGNDVFOTRGOTJFOTk2Nzg5Mzg2NDI2MThFNjdGQzA5RDU1MzcyNkQ5MzM5MjZFNkQ2MkQ3QzVFQTM4Mjc4NkUyQkFDRTIxQUVFNUVCMUVDMDFGNUUxQjc1M0I2NzdDMDE1RTlBMEExNjk1MkRCQjgzQUM1MjMxQURBMzBDMTFDMjMzOTA4ODdEIykKICAgKQogICkKIChwdWJsaWMta2V5IAogIChyc2EgCiAgIChuICMwMEMxRjc2NDA2OUY1NEZGRTkzQTEyNkIwMjMyODkwM0U5ODRFNEFFM0FGNkRGNDAyQjVCNkIzOTA3OTExQjg4QzM4NUYxQkE3NkEwMDJFQzlERUExMDlBNTIyOEVGMEU2MkVFMzFBMDZEMUE1ODYxQ0FCNDc0RjZDODU3QUM2NkVCNjVBMTkwNUYyNUJCQTE4Njk1NzlFNzNBM0I3RkVEMTNBRjVBMTY2NzMyNkY4OENERkMyRkYyNEIwM0MxNEZEMTM4NEFBN0U3M0NBODk1NzI4ODBCNjA2RTNBOTc0RTE1MzQ3OTYzRkM3QjYzNzg1NzQ5MzZBNDc1ODBEQkNCNDUjKQogICAoZSAjMDEwMDAxIykKICAgKQogICkKICkK\n"
> result: PASS
>
> test-name: /*.narinfo with properly encoded '+' sign
> location: /home/lfam/guix/tests/publish.scm:169
> 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\nFileSize: ~a\nNarHash: sha256:~a\nNarSize: ~d\nReferences: ~%"
> +              item
> +              (uri-encode (basename item))
> +              (path-info-nar-size info)
> +              (bytevector->nix-base32-string
> +                (path-info-hash info))
> +              (path-info-nar-size info)))
> +          (signature
> +            (base64-encode
> +              (string->utf8
> +                (canonical-sexp->string
> +                  (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/lfam/guix/test-tmp/store/r3j7lcw6x9lsmqcly3m8509ynzxk9668-fake-gtk+\nURL: nar/r3j7lcw6x9lsmqcly3m8509ynzxk9668-fake-gtk%2B\nCompression: none\nFileSize: 128\nNarHash: sha256:1ysbwi8icaw2g5qmwjf9k0qd4d9gazd91kf1djycpk5ahwh4kmlp\nNarSize: 128\nReferences: \nSignature: 1;berlin.guix.gnu.org;KHNpZ25hdHVyZSAKIChkYXRhIAogIChmbGFncyBwa2NzMSkKICAoaGFzaCBzaGEyNTYgIzZENEMwM0RFNDM1MjcyMzdGMzRBODZFQjY0NzFFQUMwRjcwRkNGNDRFNzIyRDk5QURDRUJFNkRCNzE0MDZGOEMjKQogICkKIChzaWctdmFsIAogIChyc2EgCiAgIChzICMwNkJDQjk2QzE0RUI5RkI2QTgzQUM2NkIzMEUyNTI0N0I2MEE5Rjc5RDJCNkRBQUEyMDMxRjRCRDEwNjAzMjlBMTBENkNGNjU2MUMyMEFEQTg5NENGMzM4OTAwQTA3RTREREVCQjdBNDkzQTBBNDc1RThDNTc2MTMxMzA3RkI1NzJGQTc4NTRDRTRGNDM5NTlCREFDNzA0RjYzODQ5MTAwMzM1MkYzQjAxMDZENjFCRTNEMjZDMDk0QjJDNDJFQzY3NjFGOTY1ODdDMDkzODVERTgyMzQ1Qjk1QkUyNkE0MDI3QTI1OUIxMUQ4RkYxOENGRTQyMTE5RUMyODM4RDhFIykKICAgKQogICkKIChwdWJsaWMta2V5IAogIChyc2EgCiAgIChuICMwMEMxRjc2NDA2OUY1NEZGRTkzQTEyNkIwMjMyODkwM0U5ODRFNEFFM0FGNkRGNDAyQjVCNkIzOTA3OTExQjg4QzM4NUYxQkE3NkEwMDJFQzlERUExMDlBNTIyOEVGMEU2MkVFMzFBMDZEMUE1ODYxQ0FCNDc0RjZDODU3QUM2NkVCNjVBMTkwNUYyNUJCQTE4Njk1NzlFNzNBM0I3RkVEMTNBRjVBMTY2NzMyNkY4OENERkMyRkYyNEIwM0MxNEZEMTM4NEFBN0U3M0NBODk1NzI4ODBCNjA2RTNBOTc0RTE1MzQ3OTYzRkM3QjYzNzg1NzQ5MzZBNDc1ODBEQkNCNDUjKQogICAoZSAjMDEwMDAxIykKICAgKQogICkKICkK\n"
> actual-value: "StorePath: /home/lfam/guix/test-tmp/store/r3j7lcw6x9lsmqcly3m8509ynzxk9668-fake-gtk+\nURL: nar/r3j7lcw6x9lsmqcly3m8509ynzxk9668-fake-gtk%2B\nCompression: none\nFileSize: 128\nNarHash: sha256:1ysbwi8icaw2g5qmwjf9k0qd4d9gazd91kf1djycpk5ahwh4kmlp\nNarSize: 128\nReferences: \nSignature: 1;berlin.guix.gnu.org;KHNpZ25hdHVyZSAKIChkYXRhIAogIChmbGFncyBwa2NzMSkKICAoaGFzaCBzaGEyNTYgIzZENEMwM0RFNDM1MjcyMzdGMzRBODZFQjY0NzFFQUMwRjcwRkNGNDRFNzIyRDk5QURDRUJFNkRCNzE0MDZGOEMjKQogICkKIChzaWctdmFsIAogIChyc2EgCiAgIChzICMwNkJDQjk2QzE0RUI5RkI2QTgzQUM2NkIzMEUyNTI0N0I2MEE5Rjc5RDJCNkRBQUEyMDMxRjRCRDEwNjAzMjlBMTBENkNGNjU2MUMyMEFEQTg5NENGMzM4OTAwQTA3RTREREVCQjdBNDkzQTBBNDc1RThDNTc2MTMxMzA3RkI1NzJGQTc4NTRDRTRGNDM5NTlCREFDNzA0RjYzODQ5MTAwMzM1MkYzQjAxMDZENjFCRTNEMjZDMDk0QjJDNDJFQzY3NjFGOTY1ODdDMDkzODVERTgyMzQ1Qjk1QkUyNkE0MDI3QTI1OUIxMUQ4RkYxOENGRTQyMTE5RUMyODM4RDhFIykKICAgKQogICkKIChwdWJsaWMta2V5IAogIChyc2EgCiAgIChuICMwMEMxRjc2NDA2OUY1NEZGRTkzQTEyNkIwMjMyODkwM0U5ODRFNEFFM0FGNkRGNDAyQjVCNkIzOTA3OTExQjg4QzM4NUYxQkE3NkEwMDJFQzlERUExMDlBNTIyOEVGMEU2MkVFMzFBMDZEMUE1ODYxQ0FCNDc0RjZDODU3QUM2NkVCNjVBMTkwNUYyNUJCQTE4Njk1NzlFNzNBM0I3RkVEMTNBRjVBMTY2NzMyNkY4OENERkMyRkYyNEIwM0MxNEZEMTM4NEFBN0U3M0NBODk1NzI4ODBCNjA2RTNBOTc0RTE1MzQ3OTYzRkM3QjYzNzg1NzQ5MzZBNDc1ODBEQkNCNDUjKQogICAoZSAjMDEwMDAxIykKICAgKQogICkKICkK\n"
> result: PASS
>
> test-name: /nar/*
> location: /home/lfam/guix/tests/publish.scm:201
> 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/lfam/guix/tests/publish.scm:212
> 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/lfam/guix/tests/publish.scm:223
> 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: /nar/lzip/*
> location: /home/lfam/guix/tests/publish.scm:233
> source:
> + (test-equal
> +   "/nar/lzip/*"
> +   "bar"
> +   (call-with-temporary-output-file
> +     (lambda (temp port)
> +       (let ((nar (http-get-port
> +                    (publish-uri
> +                      (string-append "/nar/lzip/" (basename %item))))))
> +         (call-with-lzip-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/zstd/*
> location: /home/lfam/guix/tests/publish.scm:245
> source:
> + (test-equal
> +   "/nar/zstd/*"
> +   "bar"
> +   (call-with-temporary-output-file
> +     (lambda (temp port)
> +       (let ((nar (http-get-port
> +                    (publish-uri
> +                      (string-append "/nar/zstd/" (basename %item))))))
> +         (call-with-zstd-input-port
> +           nar
> +           (cut restore-file <> temp)))
> +       (call-with-input-file temp read-string))))
> expected-value: "bar"
> actual-value: "bar"
> result: PASS
>
> test-name: /*.narinfo with compression
> location: /home/lfam/guix/tests/publish.scm:256
> 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/lfam/guix/test-tmp/store/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("URL" . "nar/gzip/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("Compression" . "gzip"))
> actual-value: (("StorePath" . "/home/lfam/guix/test-tmp/store/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("URL" . "nar/gzip/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("Compression" . "gzip"))
> result: PASS
>
> test-name: /*.narinfo with lzip compression
> location: /home/lfam/guix/tests/publish.scm:276
> source:
> + (test-equal
> +   "/*.narinfo with lzip compression"
> +   `(("StorePath" unquote %item)
> +     ("URL"
> +      unquote
> +      (string-append "nar/lzip/" (basename %item)))
> +     ("Compression" . "lzip"))
> +   (let ((thread
> +           (with-separate-output-ports
> +             (call-with-new-thread
> +               (lambda () (guix-publish "--port=6790" "-Clzip"))))))
> +     (wait-until-ready 6790)
> +     (let* ((url (string-append
> +                   "http://localhost:6790/"
> +                   (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/lfam/guix/test-tmp/store/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("URL" . "nar/lzip/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("Compression" . "lzip"))
> actual-value: (("StorePath" . "/home/lfam/guix/test-tmp/store/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("URL" . "nar/lzip/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("Compression" . "lzip"))
> result: PASS
>
> test-name: /*.narinfo for a compressed file
> location: /home/lfam/guix/tests/publish.scm:296
> 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: /*.narinfo with lzip + gzip
> location: /home/lfam/guix/tests/publish.scm:308
> source:
> + (test-equal
> +   "/*.narinfo with lzip + gzip"
> +   `((("StorePath" unquote %item)
> +      ("URL"
> +       unquote
> +       (string-append "nar/gzip/" (basename %item)))
> +      ("Compression" . "gzip")
> +      ("URL"
> +       unquote
> +       (string-append "nar/lzip/" (basename %item)))
> +      ("Compression" . "lzip"))
> +     200
> +     200)
> +   (call-with-temporary-directory
> +     (lambda (cache)
> +       (let ((thread
> +               (with-separate-output-ports
> +                 (call-with-new-thread
> +                   (lambda ()
> +                     (guix-publish
> +                       "--port=6793"
> +                       "-Cgzip:2"
> +                       "-Clzip:2"))))))
> +         (wait-until-ready 6793)
> +         (let* ((base "http://localhost:6793/")
> +                (part (store-path-hash-part %item))
> +                (url (string-append base part ".narinfo"))
> +                (body (http-get-port url)))
> +           (list (take (recutils->alist body) 5)
> +                 (response-code
> +                   (http-get
> +                     (string-append base "nar/gzip/" (basename %item))))
> +                 (response-code
> +                   (http-get
> +                     (string-append base "nar/lzip/" (basename %item))))))))))
> expected-value: ((("StorePath" . "/home/lfam/guix/test-tmp/store/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("URL" . "nar/gzip/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("Compression" . "gzip") ("URL" . "nar/lzip/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("Compression" . "lzip")) 200 200)
> actual-value: ((("StorePath" . "/home/lfam/guix/test-tmp/store/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("URL" . "nar/gzip/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("Compression" . "gzip") ("URL" . "nar/lzip/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("Compression" . "lzip")) 200 200)
> result: PASS
>
> test-name: custom nar path
> location: /home/lfam/guix/tests/publish.scm:335
> 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/lfam/guix/test-tmp/store/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("URL" . "foo/bar/chbouib/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("Compression" . "none")) 200 404)
> actual-value: ((("StorePath" . "/home/lfam/guix/test-tmp/store/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("URL" . "foo/bar/chbouib/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("Compression" . "none")) 200 404)
> result: PASS
>
> test-name: /nar/ with properly encoded '+' sign
> location: /home/lfam/guix/tests/publish.scm:365
> 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/lfam/guix/tests/publish.scm:377
> 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
>
> publishing /home/lfam/guix/test-tmp/store on 0.0.0.0, port 6789
> using 'none' compression method, level 0
> publishing /home/lfam/guix/test-tmp/store on 0.0.0.0, port 6799
> using 'gzip' compression method, level 5
> publishing /home/lfam/guix/test-tmp/store on 0.0.0.0, port 6790
> using 'lzip' compression method, level 3
> publishing /home/lfam/guix/test-tmp/store on 0.0.0.0, port 6793
> using 'gzip' compression method, level 2
> using 'lzip' compression method, level 2
> publishing /home/lfam/guix/test-tmp/store on 0.0.0.0, port 6798
> using 'none' compression method, level 0
> @ build-started /home/lfam/guix/test-tmp/store/lcjfvb26q7jlmbnb2zdni2sghlj993bp-the-file.txt.drv - x86_64-linux /home/lfam/guix/test-tmp/var/log/guix/drvs/lc//jfvb26q7jlmbnb2zdni2sghlj993bp-the-file.txt.drv.bz2 123820
> @ build-succeeded /home/lfam/guix/test-tmp/store/lcjfvb26q7jlmbnb2zdni2sghlj993bp-the-file.txt.drv -
> test-name: /file/NAME/sha256/HASH
> location: /home/lfam/guix/tests/publish.scm:385
> 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/lfam/guix/tests/publish.scm:403
> 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/lfam/guix/tests/publish.scm:409
> 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
>
>
> ;;; (wait-for-file "/tmp/guix-directory.9rJG3j/gzip/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item.narinfo")
> test-name: with cache
> location: /home/lfam/guix/tests/publish.scm:417
> 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)
> +                       "--cache-bypass-threshold=0"))))))
> +         (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)
> +                (= 420 (stat:perms (lstat cached)))
> +                (= 420 (stat:perms (lstat nar)))
> +                (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)))))))))
> expected-value: (#t (("StorePath" . "/home/lfam/guix/test-tmp/store/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("URL" . "nar/gzip/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("Compression" . "gzip")) 200 #t #t 404)
> actual-value: (#t (("StorePath" . "/home/lfam/guix/test-tmp/store/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("URL" . "nar/gzip/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("Compression" . "gzip")) 200 #t #t 404)
> result: PASS
>
>
> ;;; (wait-for-file "/tmp/guix-directory.m96XNk/gzip/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item.narinfo")
>
> ;;; (narinfo/gzip+lzip (("StorePath" . "/home/lfam/guix/test-tmp/store/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("URL" . "nar/gzip/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("Compression" . "gzip") ("FileSize" . "86") ("URL" . "nar/lzip/s3i2h3aw4gk9fs3d80j43sj1g9v50idf-item") ("Compression" . "lzip") ("FileSize" . "99") ("NarHash" . "sha256:1xngcmsdkdvaycaqjfzvq4gr3gib56p2l8illglnsqzhpss47pxz") ("NarSize" . "120") ("References" . "7va9x8gzhcwxv1srdiw9jx6ia9c20s0j-ref") ("Signature" . "1;berlin.guix.gnu.org;KHNpZ25hdHVyZSAKIChkYXRhIAogIChmbGFncyBwa2NzMSkKICAoaGFzaCBzaGEyNTYgI0VENDRDQjY2QjZFRUY0MzMyNjI4M0I5QkEwQjc4QTRCQjEyQjI0REFEODBDNUM2RjlCRjZCMzVDNzY5MDNCMEEjKQogICkKIChzaWctdmFsIAogIChyc2EgCiAgIChzICMyMUJFNTJCNUY3RjM0MTlBQjNENkJGMjM1RkM2NDUzRjVFMTFGNDQ2RjMzRjU3OTNBQjE5MEMwREE1MkU3QkJFMkQzMDZFMzFCNzJFNTRFREM3OEFDRDZCQzczOTJBNTI3MEFDMTIzQzU1NkI4Q0VCMUY3N0FGM0YwN0VFMzY2NzQ5QURENTE5QTU1MDk1NjRFMzFGRjkyOEJEREY1MURGM0YxOEM5Qzc1OUMzQzczQzg1RkJCNUIxMUNBRDJCQkNGNTJFRjEyMDU0MTQxQkI3NjE0QUJCMTRCOERGRUY0MjY1NzdDQzU5RDEwN0Y3QjIxN0I3M0QzNkJGNDcwMjdFIykKICAgKQogICkKIChwdWJsaWMta2V5IAogIChyc2EgCiAgIChuICMwMEMxRjc2NDA2OUY1NEZGRTkzQTEyNkIwMjMyODkwM0U5ODRFNEFFM0FGNkRGNDAyQjVCNkIzOTA3OTExQjg4QzM4NUYxQkE3NkEwMDJFQzlERUExMDlBNTIyOEVGMEU2MkVFMzFBMDZEMUE1ODYxQ0FCNDc0RjZDODU3QUM2NkVCNjVBMTkwNUYyNUJCQTE4Njk1NzlFNzNBM0I3RkVEMTNBRjVBMTY2NzMyNkY4OENERkMyRkYyNEIwM0MxNEZEMTM4NEFBN0U3M0NBODk1NzI4ODBCNjA2RTNBOTc0RTE1MzQ3OTYzRkM3QjYzNzg1NzQ5MzZBNDc1ODBEQkNCNDUjKQogICAoZSAjMDEwMDAxIykKICAgKQogICkKICkK")))
> test-name: with cache, lzip + gzip
> location: /home/lfam/guix/tests/publish.scm:479
> source:
> + (test-equal
> +   "with cache, lzip + gzip"
> +   '(200 200 404)
> +   (call-with-temporary-directory
> +     (lambda (cache)
> +       (let ((thread
> +               (with-separate-output-ports
> +                 (call-with-new-thread
> +                   (lambda ()
> +                     (guix-publish
> +                       "--port=6794"
> +                       "-Cgzip:2"
> +                       "-Clzip:2"
> +                       (string-append "--cache=" cache)
> +                       "--cache-bypass-threshold=0"))))))
> +         (wait-until-ready 6794)
> +         (let* ((base "http://localhost:6794/")
> +                (part (store-path-hash-part %item))
> +                (url (string-append base part ".narinfo"))
> +                (nar-url
> +                  (cute string-append
> +                        "nar/"
> +                        <>
> +                        "/"
> +                        (basename %item)))
> +                (cached
> +                  (cute string-append
> +                        cache
> +                        "/"
> +                        <>
> +                        "/"
> +                        (basename %item)
> +                        ".narinfo"))
> +                (nar (cute string-append
> +                           cache
> +                           "/"
> +                           <>
> +                           "/"
> +                           (basename %item)
> +                           ".nar"))
> +                (response (http-get url)))
> +           (wait-for-file (cached "gzip"))
> +           (let* ((body (http-get-port url))
> +                  (narinfo (recutils->alist body))
> +                  (uncompressed
> +                    (string-append base "nar/" (basename %item))))
> +             (and (file-exists? (nar "gzip"))
> +                  (file-exists? (nar "lzip"))
> +                  (equal?
> +                    (take (pk 'narinfo/gzip+lzip narinfo) 7)
> +                    `(("StorePath" unquote %item)
> +                      ("URL" unquote (nar-url "gzip"))
> +                      ("Compression" . "gzip")
> +                      ("FileSize"
> +                       unquote
> +                       (number->string (stat:size (stat (nar "gzip")))))
> +                      ("URL" unquote (nar-url "lzip"))
> +                      ("Compression" . "lzip")
> +                      ("FileSize"
> +                       unquote
> +                       (number->string (stat:size (stat (nar "lzip")))))))
> +                  (list (response-code
> +                          (http-get (string-append base (nar-url "gzip"))))
> +                        (response-code
> +                          (http-get (string-append base (nar-url "lzip"))))
> +                        (response-code (http-get uncompressed))))))))))
> expected-value: (200 200 404)
> actual-value: (200 200 404)
> result: PASS
>
>
> ;;; (wait-for-file "/tmp/guix-directory.5CRlhm/none/drlf4d7hrx8spvy4klkf79k1cbzb72v8-fake-compressed-thing.tar.gz.narinfo")
> test-name: with cache, uncompressed
> location: /home/lfam/guix/tests/publish.scm:526
> source:
> + (test-equal
> +   "with cache, uncompressed"
> +   (list #t
> +         (* 42 3600)
> +         `(("StorePath" unquote item)
> +           ("URL"
> +            unquote
> +            (string-append "nar/" (basename item)))
> +           ("Compression" . "none"))
> +         200
> +         (* 42 3600)
> +         (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"
> +                       "--ttl=42h"
> +                       (string-append "--cache=" cache)
> +                       "--cache-bypass-threshold=0"))))))
> +         (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* ((response (http-get url))
> +                       (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)
> +                        (match (assq-ref
> +                                 (response-headers response)
> +                                 'cache-control)
> +                               ((((quote max-age) . ttl)) ttl)
> +                               (_ #f))
> +                        (filter
> +                          (lambda (item)
> +                            (match item
> +                                   (("Compression" . _) #t)
> +                                   (("StorePath" . _) #t)
> +                                   (("URL" . _) #t)
> +                                   (_ #f)))
> +                          narinfo)
> +                        (response-code uncompressed)
> +                        (match (assq-ref
> +                                 (response-headers uncompressed)
> +                                 'cache-control)
> +                               ((((quote max-age) . ttl)) ttl)
> +                               (_ #f))
> +                        (string->number (assoc-ref narinfo "FileSize"))
> +                        (response-code compressed)))))))))
> expected-value: (#t 151200 (("StorePath" . "/home/lfam/guix/test-tmp/store/drlf4d7hrx8spvy4klkf79k1cbzb72v8-fake-compressed-thing.tar.gz") ("URL" . "nar/drlf4d7hrx8spvy4klkf79k1cbzb72v8-fake-compressed-thing.tar.gz") ("Compression" . "none")) 200 151200 176 404)
> actual-value: (#t 151200 (("StorePath" . "/home/lfam/guix/test-tmp/store/drlf4d7hrx8spvy4klkf79k1cbzb72v8-fake-compressed-thing.tar.gz") ("URL" . "nar/drlf4d7hrx8spvy4klkf79k1cbzb72v8-fake-compressed-thing.tar.gz") ("Compression" . "none")) 200 151200 176 404)
> result: PASS
>
>
> ;;; (wait-for-file "/tmp/guix-directory.lQ5Iyj/gzip/8g66gfkxls4pxvz2l1b47zn6sgryd23r-random.narinfo")
> publishing /home/lfam/guix/test-tmp/store on 0.0.0.0, port 6797
> using 'gzip' compression method, level 2
> publishing /home/lfam/guix/test-tmp/store on 0.0.0.0, port 6794
> using 'gzip' compression method, level 2
> using 'lzip' compression method, level 2
> random seed for tests: 1612901421
> publishing /home/lfam/guix/test-tmp/store on 0.0.0.0, port 6796
> using 'gzip' compression method, level 2
> publishing /home/lfam/guix/test-tmp/store on 0.0.0.0, port 6795
> using 'gzip' compression method, level 3
> finding garbage collector roots...
> removing stale temporary roots file `/home/lfam/guix/test-tmp/var/123751/temproots/123781'
> deleting unused links...
>
> ;;; (response #<<response> version: (1 . 1) code: 200 reason-phrase: "OK" headers: ((content-length . 1277) (content-type application/x-nix-narinfo (charset . "utf-8"))) port: #<closed: file 7f1e03ea1690>>)
> test-name: with cache, vanishing item
> location: /home/lfam/guix/tests/publish.scm:587
> source:
> + (test-equal
> +   "with cache, vanishing item"
> +   200
> +   (call-with-temporary-directory
> +     (lambda (cache)
> +       (let ((thread
> +               (with-separate-output-ports
> +                 (call-with-new-thread
> +                   (lambda ()
> +                     (guix-publish
> +                       "--port=6795"
> +                       (string-append "--cache=" cache)))))))
> +         (wait-until-ready 6795)
> +         (let* ((base "http://localhost:6795/")
> +                (item (add-text-to-store %store "random" (random-text)))
> +                (part (store-path-hash-part item))
> +                (url (string-append base part ".narinfo"))
> +                (cached
> +                  (string-append
> +                    cache
> +                    "/gzip/"
> +                    (basename item)
> +                    ".narinfo"))
> +                (response (http-get url)))
> +           (and (= 200 (response-code response))
> +                (wait-for-file cached)
> +                (begin
> +                  (delete-paths %store (list item))
> +                  (response-code (pk 'response (http-get url))))))))))
> expected-value: 200
> actual-value: 200
> result: PASS

I don't see any failure in the above test results?

Thanks,

Maxim