From d466b1fc8221a6224fe7ded53a828f9c29ed9457 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 21 Jan 2018 00:05:09 +0100 Subject: services: Missing services are automatically instantiated. This simplifies OS configuration: users no longer need to be aware of what a given service depends on. See the discussion at . * gnu/services.scm (missing-target-error): New procedure. (service-back-edges): Use it. (instantiate-missing-services): New procedure. * gnu/system.scm (operating-system-services): Call 'instantiate-missing-services'. * tests/services.scm ("instantiate-missing-services") ("instantiate-missing-services, no default value"): New tests. * gnu/services/version-control.scm (cgit-service-type)[extensions]: Add FCGIWRAP-SERVICE-TYPE. * gnu/tests/version-control.scm (%cgit-os): Remove NGINX-SERVICE-TYPE and FCGIWRAP-SERVICE-TYPE instances. * doc/guix.texi (Log Rotation): Remove 'mcron-service-type' in example. (Miscellaneous Services): Remove 'nginx-service-type' and 'fcgiwrap-service-type' in Cgit example. --- tests/services.scm | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/services.scm b/tests/services.scm index ca32b565c4..b146a0dec2 100644 --- a/tests/services.scm +++ b/tests/services.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2015, 2016, 2017 Ludovic Courtès +;;; Copyright © 2015, 2016, 2017, 2018 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -122,6 +122,36 @@ (fold-services (list s) #:target-type t1) #f))) +(test-assert "instantiate-missing-services" + (let* ((t1 (service-type (name 't1) (extensions '()) + (default-value 'dflt) + (compose concatenate) + (extend cons))) + (t2 (service-type (name 't2) + (extensions + (list (service-extension t1 list))))) + (s1 (service t1 'hey!)) + (s2 (service t2 42))) + (and (lset= equal? + (list (service t1) s2) + (instantiate-missing-services (list s2))) + (equal? (list s1 s2) + (instantiate-missing-services (list s1 s2)))))) + +(test-assert "instantiate-missing-services, no default value" + (let* ((t1 (service-type (name 't1) (extensions '()))) + (t2 (service-type (name 't2) + (extensions + (list (service-extension t1 list))))) + (s (service t2 42))) + (guard (c ((missing-target-service-error? c) + (and (eq? (missing-target-service-error-target-type c) + t1) + (eq? (missing-target-service-error-service c) + s)))) + (instantiate-missing-services (list s)) + #f))) + (test-assert "shepherd-service-lookup-procedure" (let* ((s1 (shepherd-service (provision '(s1 s1b)) (start #f))) (s2 (shepherd-service (provision '(s2 s2b)) (start #f))) -- cgit v1.2.3 From 33988f9b5876e4b44cabe1997a91eb604931c1ca Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 22 Jan 2018 10:46:34 +0100 Subject: publish: Restore gzip compression in cache-less mode. Fixes . Regression introduced in 297e04d66010ada31a40f40143d81bf6b62affcc. Reported by Christopher Baines . * guix/scripts/publish.scm (nar-response-port): Add 'compression' parameter and honor it. (http-write): Get 'x-nar-compression' from the initial RESPONSE. --- guix/scripts/publish.scm | 16 +++++++++------- tests/publish.scm | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm index 1673fb9f33..b5dfdab32f 100644 --- a/guix/scripts/publish.scm +++ b/guix/scripts/publish.scm @@ -672,10 +672,10 @@ example: \"/foo/bar\" yields '(\"foo\" \"bar\")." exp ...) (const #f))) -(define (nar-response-port response) +(define (nar-response-port response compression) "Return a port on which to write the body of RESPONSE, the response of a /nar request, according to COMPRESSION." - (match (assoc-ref (response-headers response) 'x-nar-compression) + (match compression (($ 'gzip level) ;; Note: We cannot used chunked encoding here because ;; 'make-gzip-output-port' wants a file port. @@ -697,11 +697,13 @@ blocking." (call-with-new-thread (lambda () (set-thread-name "publish nar") - (let* ((response (write-response (sans-content-length response) - client)) - (port (begin - (force-output client) - (nar-response-port response)))) + (let* ((compression (assoc-ref (response-headers response) + 'x-nar-compression)) + (response (write-response (sans-content-length response) + client)) + (port (begin + (force-output client) + (nar-response-port response compression)))) ;; XXX: Given our ugly workaround for in ;; 'render-nar', BODY here is just the file name of the store item. ;; We call 'write-file' from here because we know that's the only diff --git a/tests/publish.scm b/tests/publish.scm index bd1a75cf00..8c88a8c93d 100644 --- a/tests/publish.scm +++ b/tests/publish.scm @@ -111,6 +111,10 @@ (sleep 1) (loop (- i 1)))))) +(define %gzip-magic-bytes + ;; Magic bytes of gzip file. + #vu8(#x1f #x8b)) + ;; Wait until the two servers are ready. (wait-until-ready 6789) @@ -213,6 +217,18 @@ FileSize: ~a~%" (cut restore-file <> temp))) (call-with-input-file temp read-string)))) +(unless (zlib-available?) + (test-skip 1)) +(test-equal "/nar/gzip/* is really gzip" + %gzip-magic-bytes + ;; Since 'gzdopen' (aka. 'call-with-gzip-input-port') transparently reads + ;; uncompressed gzip, the test above doesn't check whether it's actually + ;; gzip. This is what this test does. See . + (let ((nar (http-get-port + (publish-uri + (string-append "/nar/gzip/" (basename %item)))))) + (get-bytevector-n nar (bytevector-length %gzip-magic-bytes)))) + (unless (zlib-available?) (test-skip 1)) (test-equal "/*.narinfo with compression" -- cgit v1.2.3