From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?Cl=C3=A9ment?= Lassieur Subject: Re: [PATCH 2/2] tests: Add 'prosody-service-type' test. Date: Fri, 10 Feb 2017 19:27:52 +0100 Message-ID: <87r335ucif.fsf@lassieur.org> References: <20170205185854.4345-1-clement@lassieur.org> <20170205185854.4345-3-clement@lassieur.org> <87d1espwno.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55851) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ccFvM-0002qw-WC for guix-devel@gnu.org; Fri, 10 Feb 2017 13:28:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ccFvJ-0004rD-SH for guix-devel@gnu.org; Fri, 10 Feb 2017 13:28:01 -0500 In-reply-to: <87d1espwno.fsf@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel@gnu.org Hi Ludovic, Ludovic Court=C3=A8s writes: > Hello! > > Cl=C3=A9ment Lassieur skribis: > >> * gnu/tests/messaging.scm: New file. >> * gnu/services/messaging.scm: New exported procedure. >> ()[provision]: Add 'xmpp-daemon'. > > Awesome! > > Please also add the new file to gnu/local.mk. Done. >> +(define %base-os >> + (operating-system >> + (host-name "komputilo") >> + (timezone "Europe/Berlin") >> + (locale "en_US.UTF-8") >> + >> + (bootloader (grub-configuration (device "/dev/sdX"))) >> + (file-systems %base-file-systems) >> + (firmware '()) >> + (users %base-user-accounts) >> + (services (cons (dhcp-client-service) >> + %base-services)))) >> + >> +(define (os-with-service service) >> + "Return a test operating system that runs SERVICE." >> + (operating-system >> + (inherit %base-os) >> + (services (cons service >> + (operating-system-user-services %base-os))))) >> + >> +(define (run-xmpp-test name xmpp-service pid-file create-account) >> + "Run a test of an OS running XMPP-SERVICE, which writes its PID to = PID-FILE." >> + (mlet* %store-monad ((os -> (marionette-operating-system >> + (os-with-service xmpp-service) >> + #:imported-modules '((gnu services her= d)))) > > I think you can remove =E2=80=98os-with-service=E2=80=99 and simply add= the Prosody > service explicitly in =E2=80=98%base-os=E2=80=99 (which could be rename= =E2=80=98%prosody-os=E2=80=99 > maybe). But then, my test wouldn't be generic anymore, would it? I would like it to be Prosody-independent, so that one can add, say, the ejabberd service easily. That's why I call the service 'xmpp-daemon' instead of 'prosody'. WDYT? >> + (define script.ft >> + (scheme-file >> + "script.ft" >> + #~(begin >> + (define (handle-received-message time from nickname messag= e) >> + (if (equal? message #$message) >> + (ft-quit 0) >> + (ft-quit 1))) >> + (add-hook! ft-message-receive-hook handle-received-message= ) >> + >> + (ft-set-jid! #$jid) >> + (ft-set-password! #$password) >> + (ft-set-server! #$server) >> + (ft-set-port! #$port) >> + (ft-set-sslconn! #f) >> + (ft-connect-blocking) >> + (ft-send-message #$jid #$message) >> + (ft-main-loop)))) > > Very neat that this can be done in Scheme too. :-) > > If it=E2=80=99s possible, I agree that adding a timeout (say 1 minute) = would be > nice. Done. >> + ;; Check XMPP service's PID. >> + (test-assert "service process id" >> + (let ((pid (number->string (wait-for-file #$pid-file)))= ) >> + (marionette-eval `(zero? (system* "ps" "-p" ,pid)) >> + marionette))) > > I think (file-exists? (string-append "/proc/" pid)) would be enough. Done. >> +(define %create-prosody-account >> + (program-file >> + "create-account" >> + #~(let* ((jid (cadr (command-line))) >> + (password (caddr (command-line))) > > Better use =E2=80=98match=E2=80=99 here. :-) > > (match (command-line) > ((command jid password) > =E2=80=A6)) Done. > Could you send an updated patch? Done! Thanks for the review! Cl=C3=A9ment