From patchwork Sun Jan 31 22:01:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: M X-Patchwork-Id: 26796 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 88CBE27BC1E; Sun, 31 Jan 2021 22:03:17 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6653127BC1D for ; Sun, 31 Jan 2021 22:03:16 +0000 (GMT) Received: from localhost ([::1]:55528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6KoN-0007iz-FA for patchwork@mira.cbaines.net; Sun, 31 Jan 2021 17:03:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6KoA-0007ip-Ja for guix-patches@gnu.org; Sun, 31 Jan 2021 17:03:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:46704) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l6KoA-00015q-Cq for guix-patches@gnu.org; Sun, 31 Jan 2021 17:03:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l6KoA-0001Jn-9J for guix-patches@gnu.org; Sun, 31 Jan 2021 17:03:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#46216] [PATCH] Remove duplication in tests/publish.scm Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 31 Jan 2021 22:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46216 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 46216@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16121305303710 (code B ref -1); Sun, 31 Jan 2021 22:03:02 +0000 Received: (at submit) by debbugs.gnu.org; 31 Jan 2021 22:02:10 +0000 Received: from localhost ([127.0.0.1]:58250 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l6KnJ-0000xA-9p for submit@debbugs.gnu.org; Sun, 31 Jan 2021 17:02:10 -0500 Received: from lists.gnu.org ([209.51.188.17]:49068) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l6KnF-0000u6-LO for submit@debbugs.gnu.org; Sun, 31 Jan 2021 17:02:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6KnD-0007PZ-TQ for guix-patches@gnu.org; Sun, 31 Jan 2021 17:02:05 -0500 Received: from albert.telenet-ops.be ([2a02:1800:110:4::f00:1a]:37862) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l6Kn8-0000el-UW for guix-patches@gnu.org; Sun, 31 Jan 2021 17:02:03 -0500 Received: from ptr-bvsjgyjmffd7q9timvx.18120a2.ip6.access.telenet.be ([IPv6:2a02:1811:8c09:9d00:aaf1:9810:a0b8:a55d]) by albert.telenet-ops.be with bizsmtp id Pa1u2400E0mfAB406a1ug8; Sun, 31 Jan 2021 23:01:54 +0100 Message-ID: <077d7e5c5e6935fce1e816784a03e55eb274dc50.camel@telenet.be> From: Maxime Devos Date: Sun, 31 Jan 2021 23:01:48 +0100 In-Reply-To: References: User-Agent: Evolution 3.34.2 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1612130514; bh=WOL+/PMxdprv3D5tIfuT1cO2Ax1KCBnhf5ZgUVdD0GM=; h=Subject:From:Reply-To:To:Date:In-Reply-To:References; b=PZVwG3sJ0fKcpwh0PMJnIODg1u02RFIen+XAXjgBqHWt7JdrIQFT+587GcHlBdB8e egnL9s37UHUa+iU76xT6LhqwvKLroYw0V5jKBlUJPzEjqPahMC/cEbpCb3LziBI7MT P6746NMW/lzToCQ4HkXfrIa0OUCas0B4iXy2ckyrZERFhOfvYuy4joiMdNyh5TBgab 4SNuq2kCbqMAWjJA6bLfLrsyaRFU/+jHgY6uxpiq5fBRN2Oykj4JDYav2zHiHpC6D8 BObZv8G0IANr20E/G/pc2TKhdl0kuRuPKDPgE5PsMwe5oUx5cbHWwzOg+d4djXe1lk 06gpa9SQVXVHg== Received-SPF: pass client-ip=2a02:1800:110:4::f00:1a; envelope-from=maximedevos@telenet.be; helo=albert.telenet-ops.be X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: 46216@debbugs.gnu.org Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches This is the third patch in the series. Description from patch: This way, there's no risk of accidentally reusing a port number used by another test. This changes the workings of the "/*.narinfo for a compressed file" test a little, by not reusing the port from the test "/*.narinfo with compression". * tests/publish.scm (*latest-port*, call-with-guix-publish, with-guix-publish): automatically assign port numbers, and change tests to use the new calling rules. From 3548be9cb7b862b04defad080a80c85311475c06 Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Sun, 31 Jan 2021 22:53:04 +0100 Subject: [PATCH 3/3] tests: publish: automatically keep track of port numbers This way, there's no risk of accidentally reusing a port number used by another test. This changes the workings of the "/*.narinfo for a compressed file" test a little, by not reusing the port from the test "/*.narinfo with compression". * tests/publish.scm (*latest-port*, call-with-guix-publish, with-guix-publish): automatically assign port numbers, and change tests to use the new calling rules. --- tests/publish.scm | 84 +++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/tests/publish.scm b/tests/publish.scm index e24b0feb00..0a132dfe04 100644 --- a/tests/publish.scm +++ b/tests/publish.scm @@ -106,17 +106,23 @@ The resulting thread is returned." (lambda () (apply guix-publish (format #f "--port=~a" port) extra-arguments))))) -(define (call-with-guix-publish port extra-arguments thunk) - "Call THUNK in an environment where a local publishing service -is running in a separate thread, listening at PORT. EXTRA-ARGUMENTS -are passed as-is as extra command-line arguments." - (let ((thread (apply spawn-guix-publish port extra-arguments))) +;; Keep track of port numbers, to avoid multiple +;; servers listening at the same port. +(define *latest-port* 6789) + +(define (call-with-guix-publish extra-arguments proc) + "Call PROC in an environment where a local publishing service +is running in a separate thread, passing the port listened at. +EXTRA-ARGUMENTS are passed as-is as extra command-line arguments." + (let* ((port (1+ *latest-port*)) + (thread (apply spawn-guix-publish port extra-arguments))) + (set! *latest-port* port) (wait-until-ready port) - (thunk))) + (proc port))) (define-syntax-rule (with-guix-publish port extra-arguments exp ...) - (call-with-guix-publish port extra-arguments - (lambda () exp ...))) + (call-with-guix-publish extra-arguments + (lambda (port) exp ...))) (spawn-guix-publish 6789 "-C0") @@ -279,9 +285,9 @@ References: ~%" `(("StorePath" . ,%item) ("URL" . ,(string-append "nar/gzip/" (basename %item))) ("Compression" . "gzip")) - (with-guix-publish 6799 '("-C5") - (let* ((url (string-append "http://localhost:6799/" - (store-path-hash-part %item) ".narinfo")) + (with-guix-publish port '("-C5") + (let* ((url (format #f "http://localhost:~a/~a.narinfo" port + (store-path-hash-part %item))) (body (http-get-port url))) (filter (lambda (item) (match item @@ -295,9 +301,9 @@ References: ~%" `(("StorePath" . ,%item) ("URL" . ,(string-append "nar/lzip/" (basename %item))) ("Compression" . "lzip")) - (with-guix-publish 6790 '("-Clzip") - (let* ((url (string-append "http://localhost:6790/" - (store-path-hash-part %item) ".narinfo")) + (with-guix-publish port '("-Clzip") + (let* ((url (format #f "http://localhost:~a/~a.narinfo" port + (store-path-hash-part %item))) (body (http-get-port url))) (filter (lambda (item) (match item @@ -309,15 +315,15 @@ References: ~%" (test-equal "/*.narinfo for a compressed file" '("none" "nar") ;compression-less nar - ;; Assume 'guix publish -C' is already running on port 6799. - (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"))))) + (with-guix-publish port '("-C5") + (let* ((item (add-text-to-store %store "fake.tar.gz" + "This is a fake compressed file.")) + (url (format #f "http://localhost:~a/~a.narinfo" port + (store-path-hash-part item))) + (body (http-get-port url)) + (info (recutils->alist body))) + (list (assoc-ref info "Compression") + (dirname (assoc-ref info "URL")))))) (test-equal "/*.narinfo with lzip + gzip" `((("StorePath" . ,%item) @@ -329,8 +335,8 @@ References: ~%" 200) (call-with-temporary-directory (lambda (cache) - (with-guix-publish 6793 '("-Cgzip:2" "-Clzip:2") - (let* ((base "http://localhost:6793/") + (with-guix-publish port '("-Cgzip:2" "-Clzip:2") + (let* ((base (format #f "http://localhost:~a/" port)) (part (store-path-hash-part %item)) (url (string-append base part ".narinfo")) (body (http-get-port url))) @@ -349,8 +355,8 @@ References: ~%" ("Compression" . "none")) 200 404) - (with-guix-publish 6798 '("-C0" "--nar-path=///foo/bar//chbouib/") - (let* ((base "http://localhost:6798/") + (with-guix-publish port '("-C0" "--nar-path=///foo/bar//chbouib/") + (let* ((base (format #f "http://localhost:~a/" port)) (part (store-path-hash-part %item)) (url (string-append base part ".narinfo")) (nar-url (string-append base "foo/bar/chbouib/" @@ -430,9 +436,9 @@ References: ~%" 404) ;nar/… (call-with-temporary-directory (lambda (cache) - (with-guix-publish 6797 `("-C2" ,(string-append "--cache=" cache) + (with-guix-publish port `("-C2" ,(string-append "--cache=" cache) "--cache-bypass-threshold=0") - (let* ((base "http://localhost:6797/") + (let* ((base (format #f "http://localhost:~a/" port)) (part (store-path-hash-part %item)) (url (string-append base part ".narinfo")) (nar-url (string-append base "nar/gzip/" (basename %item))) @@ -480,10 +486,10 @@ References: ~%" '(200 200 404) (call-with-temporary-directory (lambda (cache) - (with-guix-publish 6794 `("-Cgzip:2" "-Clzip:2" + (with-guix-publish port `("-Cgzip:2" "-Clzip:2" ,(string-append "--cache=" cache) "--cache-bypass-threshold=0") - (let* ((base "http://localhost:6794/") + (let* ((base (format #f "http://localhost:~a/" port)) (part (store-path-hash-part %item)) (url (string-append base part ".narinfo")) (nar-url (cute string-append "nar/" <> "/" @@ -532,10 +538,10 @@ References: ~%" 404) ;nar/gzip/… (call-with-temporary-directory (lambda (cache) - (with-guix-publish 6796 `("-C2" "--ttl=42h" + (with-guix-publish port `("-C2" "--ttl=42h" ,(string-append "--cache=" cache) "--cache-bypass-threshold=0") - (let* ((base "http://localhost:6796/") + (let* ((base (format #f "http://localhost:~a/" port)) (part (store-path-hash-part item)) (url (string-append base part ".narinfo")) (cached (string-append cache "/none/" @@ -580,11 +586,11 @@ References: ~%" 200 (call-with-temporary-directory (lambda (cache) - (with-guix-publish 6795 (list (string-append "--cache=" cache)) + (with-guix-publish port (list (string-append "--cache=" cache)) ;; Make sure that, even if ITEM disappears, we're still able to fetch ;; it. - (let* ((base "http://localhost:6795/") + (let* ((base (format #f "http://localhost:~a/" port)) (item (add-text-to-store %store "random" (random-text))) (part (store-path-hash-part item)) (url (string-append base part ".narinfo")) @@ -602,9 +608,9 @@ References: ~%" 200 (call-with-temporary-directory (lambda (cache) - (with-guix-publish 6788 `("-C" "gzip" "-C" "gzip" + (with-guix-publish port `("-C" "gzip" "-C" "gzip" ,(string-append "--cache=" cache)) - (let* ((base "http://localhost:6788/") + (let* ((base (format #f "http://localhost:~a/" port)) (item (add-text-to-store %store "random" (random-text))) (part (store-path-hash-part item)) (narinfo (string-append base part ".narinfo")) @@ -633,9 +639,9 @@ References: ~%" ;; for a non-existing file name. (call-with-temporary-directory (lambda (cache) - (with-guix-publish 6787 `("-C" "gzip" ,(string-append "--cache=" cache)) + (with-guix-publish port `("-C" "gzip" ,(string-append "--cache=" cache)) - (let* ((base "http://localhost:6787/") + (let* ((base (format #f "http://localhost:~a/" port)) (item (add-text-to-store %store "random" (random-text))) (part (store-path-hash-part item)) (narinfo (string-append base part ".narinfo")) -- 2.30.0