summaryrefslogtreecommitdiff
path: root/tests/publish.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-11-04 15:57:00 +0100
committerLudovic Courtès <ludo@gnu.org>2020-11-04 16:02:53 +0100
commit5e7cf66fb35780f930ad0bc5fe21ac330df4411d (patch)
treeb4604b178b43e29e136635333a7716579f02dbab /tests/publish.scm
parent95024494f31c3176bcd2238662e7b7868acc2882 (diff)
publish: Do not path the empty string to 'query-path-info'.
Fixes <https://bugs.gnu.org/44442>. Regression introduced in 2b2ab7796ac186d88060793b8873fc0e21462758. * guix/scripts/publish.scm (render-nar/cached): Do not call 'bypass-cache?' when ITEM is the empty string. * tests/publish.scm ("with cache, cache bypass, unmapped hash part"): New test.
Diffstat (limited to 'tests/publish.scm')
-rw-r--r--tests/publish.scm35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/publish.scm b/tests/publish.scm
index 84aa6e5d73d..e46e6256b7d 100644
--- a/tests/publish.scm
+++ b/tests/publish.scm
@@ -622,6 +622,41 @@ References: ~%"
622 (stat:size (stat item))) 622 (stat:size (stat item)))
623 (response-code response)))))))))) 623 (response-code response))))))))))
624 624
625(test-equal "with cache, cache bypass, unmapped hash part"
626 200
627
628 ;; This test reproduces the bug described in <https://bugs.gnu.org/44442>:
629 ;; the daemon connection would be closed as a side effect of a nar request
630 ;; for a non-existing file name.
631 (call-with-temporary-directory
632 (lambda (cache)
633 (let ((thread (with-separate-output-ports
634 (call-with-new-thread
635 (lambda ()
636 (guix-publish "--port=6787" "-C" "gzip"
637 (string-append "--cache=" cache)))))))
638 (wait-until-ready 6787)
639
640 (let* ((base "http://localhost:6787/")
641 (item (add-text-to-store %store "random" (random-text)))
642 (part (store-path-hash-part item))
643 (narinfo (string-append base part ".narinfo"))
644 (nar (string-append base "nar/gzip/" (basename item)))
645 (cached (string-append cache "/gzip/" (basename item)
646 ".narinfo")))
647 ;; The first response used to be 500 and to terminate the daemon
648 ;; connection as a side effect.
649 (and (= (response-code
650 (http-get (string-append base "nar/gzip/"
651 (make-string 32 #\e)
652 "-does-not-exist")))
653 404)
654 (= 200 (response-code (http-get nar)))
655 (= 200 (response-code (http-get narinfo)))
656 (begin
657 (wait-for-file cached)
658 (response-code (http-get nar)))))))))
659
625(test-equal "/log/NAME" 660(test-equal "/log/NAME"
626 `(200 #t application/x-bzip2) 661 `(200 #t application/x-bzip2)
627 (let ((drv (run-with-store %store 662 (let ((drv (run-with-store %store