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@.service” which would be identical 
to systemd-nspawn@.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.

_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to