[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/2] tests: Add 'prosody-service-type' test.
From: |
Clément Lassieur |
Subject: |
Re: [PATCH 2/2] tests: Add 'prosody-service-type' test. |
Date: |
Fri, 10 Feb 2017 19:27:52 +0100 |
User-agent: |
mu4e 0.9.18; emacs 25.1.91.1 |
Hi Ludovic,
Ludovic Courtès <address@hidden> writes:
> Hello!
>
> Clément Lassieur <address@hidden> 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.
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 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).
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 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.
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 ‘match’ here. :-)
>
> (match (command-line)
> ((command jid password)
> …))
Done.
> Could you send an updated patch?
Done! Thanks for the review!
Clément