guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#27650] [PATCH 2/2] tests: Add 'tailon-service-type' test.


From: Ludovic Courtès
Subject: [bug#27650] [PATCH 2/2] tests: Add 'tailon-service-type' test.
Date: Wed, 26 Jul 2017 22:46:37 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

Christopher Baines <address@hidden> skribis:

> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
> * gnu/tests/web.scm: New file.

[...]

> +(define* (run-tailon-test #:optional (http-port 8081))
> +  "Run tests in %TAILON-OS, which has tailon running and listening on
> +HTTP-PORT."
> +  (mlet* %store-monad ((os ->   (marionette-operating-system
> +                                 %tailon-os
> +                                 #:imported-modules '((gnu services herd)
> +                                                      (guix combinators))))
> +                       (command (system-qemu-image/shared-store-script
> +                                 os #:graphic? #f)))


[...]

> +            (define marionette
> +              ;; Forward the guest's HTTP-PORT, where tailon is listening, to
> +              ;; port 8080 in the host.
> +              (make-marionette (list #$command "-net"
> +                                     #$(simple-format
> +                                        #f
> +                                        "user,hostfwd=tcp::~A-:8080"
> +                                        http-port))))

This can be simplified using the new ‘virtual-machine’ objects:

   https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27751

Could you give it a try?

> +            (test-equal "http-get"
> +              200
> +              (let-values (((response text)
> +                            (http-get #$(simple-format
> +                                         #f
> +                                         "http://localhost:~A/";
> +                                         http-port)
> +                                      #:decode-body? #t)))
> +                (response-code response)))

If there was a more specific API, like a rest API to check whether a
specific log file exists, perhaps that’d be a good extra test.
Otherwise that’s fine.

BTW, it’s enough to use ‘format’ rather than ‘simple-format’ here: it’s
(roughly) equivalent and incurs less typing.  :-)

Feel free to squeeze this patch with the previous one (thus making a
self-contained commit), or leave it separately if it’s more convenient
for you.

Thanks for taking the time to write this test!

Ludo’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]