From: ludo@gnu.org (Ludovic Courtès)
To: "Clément Lassieur" <clement@lassieur.org>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH 2/2] tests: Add 'prosody-service-type' test.
Date: Wed, 08 Feb 2017 15:47:07 +0100 [thread overview]
Message-ID: <87d1espwno.fsf@gnu.org> (raw)
In-Reply-To: <20170205185854.4345-3-clement@lassieur.org> ("Clément Lassieur"'s message of "Sun, 5 Feb 2017 19:58:54 +0100")
Hello!
Clément Lassieur <clement@lassieur.org> skribis:
> * gnu/tests/messaging.scm: New file.
> * gnu/services/messaging.scm: New exported procedure.
> (<shepherd-service>)[provision]: Add 'xmpp-daemon'.
Awesome!
Please also add the new file to gnu/local.mk.
> +(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 herd))))
I think you can remove ‘os-with-service’ and simply add the Prosody
service explicitly in ‘%base-os’ (which could be rename ‘%prosody-os’
maybe).
> + (define script.ft
> + (scheme-file
> + "script.ft"
> + #~(begin
> + (define (handle-received-message time from nickname message)
> + (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’s possible, I agree that adding a timeout (say 1 minute) would be
nice.
> + ;; 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.
> +(define %create-prosody-account
> + (program-file
> + "create-account"
> + #~(let* ((jid (cadr (command-line)))
> + (password (caddr (command-line)))
Better use ‘match’ here. :-)
(match (command-line)
((command jid password)
…))
Could you send an updated patch?
Thank you!
Ludo’.
next prev parent reply other threads:[~2017-02-08 14:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-05 18:58 [PATCH 0/2] Add a test for the Prosody service Clément Lassieur
2017-02-05 18:58 ` [PATCH 1/2] service: shepherd: Replace spaces with hyphens in file names Clément Lassieur
2017-02-08 14:40 ` Ludovic Courtès
2017-02-05 18:58 ` [PATCH 2/2] tests: Add 'prosody-service-type' test Clément Lassieur
2017-02-06 9:48 ` Clément Lassieur
2017-02-08 14:47 ` Ludovic Courtès [this message]
2017-02-10 18:17 ` [PATCH] " Clément Lassieur
2017-02-10 22:42 ` Ludovic Courtès
2017-02-10 18:27 ` [PATCH 2/2] " Clément Lassieur
2017-02-10 22:24 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d1espwno.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=clement@lassieur.org \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.