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: Christopher Baines
Subject: [bug#27650] [PATCH 2/2] tests: Add 'tailon-service-type' test.
Date: Thu, 27 Jul 2017 18:33:26 +0100

On Wed, 26 Jul 2017 22:46:37 +0200
address@hidden (Ludovic Courtès) wrote:

> 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?

Yep, I'll send an updated patch that switches to use this approach.

> > +            (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.

I'm not sure there is an API, but I'll have a think about more useful
testing approaches. Maybe checking for things in the response, or
trying to run Tailon's test suite...

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

Ok, I'll change to use format.

> 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.

Squashing them is fine, I'll do this.

> Thanks for taking the time to write this test!

No problem, thanks for your and everyone elses advice on QEMU on IRC,
it was very useful.

Also, I've removed the sleep, and replaced it with a function to retry
the connection on error, which should hopefully avoid any issues with
it failing just because Tailon hasn't finished starting yet.

Attachment: pgpPZlL0JT3SV.pgp
Description: OpenPGP digital signature


reply via email to

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