[systemd-devel] Scripting a server test

Johannes Ernst johannes.ernst at gmail.com
Mon Jun 15 12:17:54 PDT 2015


This is a best-practice question.

I’d like to automate testing of a web application (running in a container) by running curl from the host. The logical sequence should be:

* boot container using local tar file or existing directory
* wait until container is-system-running=true
* on the container, execute a few commands
* on the host, run curl against the container
* tear down the container

I need to boot the container, and the image I need to use for this test brings up a login prompt at the console.

I’m thinking of doing something like:
> machinectl import-tar foo.tar foo
> machinectl start foo
> ssh foo systemctl is-system-running
until satisfied
> ssh foo some other commands
> curl http://foo/ <http://foo/>…
> machinectl poweroff foo
> machinectl status foo
until off

But I don’t like the “container import and registration” part of this, because my container is very ephemeral and might only live for a few minutes if the test passes.

Alternatively I could create myself a “test at .service” which would be identical to systemd-nspawn at .service, except it would use the directory as the %I instead of the machine name, so I could start it like:
> systemctl start test@/my/container/directory

Or I could fork off the systemctl-nspawn command in my test script.

Opinions? I figure this is a common-enough scenario that there might be some opinions on this list ...

Cheers,



Johannes.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150615/dc696df2/attachment.html>


More information about the systemd-devel mailing list