From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1damfl-00041W-Oy for guix-patches@gnu.org; Thu, 27 Jul 2017 13:34:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1damfi-0007q9-L4 for guix-patches@gnu.org; Thu, 27 Jul 2017 13:34:05 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:56192) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1damfi-0007q5-I3 for guix-patches@gnu.org; Thu, 27 Jul 2017 13:34:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1damfi-0001Cc-CU for guix-patches@gnu.org; Thu, 27 Jul 2017 13:34:02 -0400 Subject: [bug#27650] [PATCH 2/2] tests: Add 'tailon-service-type' test. Resent-Message-ID: Date: Thu, 27 Jul 2017 18:33:26 +0100 From: Christopher Baines Message-ID: <20170727183326.23045a4a@cbaines.net> In-Reply-To: <87379j7wpe.fsf@gnu.org> References: <20170726090853.8987-1-mail@cbaines.net> <20170726090853.8987-2-mail@cbaines.net> <87379j7wpe.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/O.igqtjAQV/0cu0xfeNH0O+"; protocol="application/pgp-signature" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 27650@debbugs.gnu.org --Sig_/O.igqtjAQV/0cu0xfeNH0O+ Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, 26 Jul 2017 22:46:37 +0200 ludo@gnu.org (Ludovic Court=C3=A8s) wrote: > Christopher Baines skribis: >=20 > > * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. > > * gnu/tests/web.scm: New file. =20 >=20 > [...] >=20 > > +(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))) =20 >=20 >=20 > [...] >=20 > > + (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=3Dtcp::~A-:8080" > > + http-port)))) =20 >=20 > This can be simplified using the new =E2=80=98virtual-machine=E2=80=99 ob= jects: >=20 > https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D27751 >=20 > 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))) =20 >=20 > If there was a more specific API, like a rest API to check whether a > specific log file exists, perhaps that=E2=80=99d be a good extra test. > Otherwise that=E2=80=99s 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=E2=80=99s enough to use =E2=80=98format=E2=80=99 rather than =E2= =80=98simple-format=E2=80=99 here: > it=E2=80=99s (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=E2=80=99s more conve= nient > 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. --Sig_/O.igqtjAQV/0cu0xfeNH0O+ Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAll6I+ZfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE 9XdKRA//YSvaIIdmWGJLxV4HsyPDHKDUADMAh3qEWryFjJBiAoYYDyecpiLqRLLq Rr7HvnnEffx6JAUIDb3Rm5y/mGg+v7VYYWFCIDWnwO9s8yjd8FXLZJNx3Ft/nrY1 SQapJpt3CdlQTZubSb8f4vQxGG23uMyvm8MET94UxXyRFnKuClfEDTHpu9D2nGJo KPZEWwb5qhIx7kXxs3imoRkO/a1hffXhqdV9l/u5oUTDykor+B4tANUB7WBRoZpK 8KM1e2Jk02W34glDVsUD5Z0VI6/36ZItkXby8VdhFbDrlK+cVoiY6nSBvSq/FYG3 mUfX7wMBZAGdTWj5vDEb5JRY+R4mE6gNsbLpGHX3k6W43u47K+ZkYUjOHO8v/JMe GOTqlYH1D3jLZecgcLD7XjBH22CYxRItgMuuxrESMEuEoAwACuyj+ar/r9jwG+j/ PlCJ6xMxEkgTC7++wTxNIRDc8Z+9u9DLB8tjujKeGlVTT6GPSFSKQOvO3SE+BqVm UWWmxNCH6iKmfulOMy2xFr+GaYWhvIB/uir7Jzxv09S+JuppNSrCUw0dYi4sN3Ci yZwfLa/wmmguNuL0X1u7BT+ANms42RlkWISacO2ap7/p08NFZW1URVjwiDMo6D2j m1+Gqf9aohdZMqRPBml4NcuhwCoyxGwJ1j1OVF1LpOlpyXQSzlk= =9791 -----END PGP SIGNATURE----- --Sig_/O.igqtjAQV/0cu0xfeNH0O+--