On Mon, 15.06.15 12:17, Johannes Ernst ([email protected]) wrote: > 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
consider using "systemctl -M foo is-system-running". Also: "systemd-run -M foo ...." to execute arbitrary commands in a container, without the need of ssh. > 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. There's no need to import it. You can put the tree wherever you want and then point nspawn to it with --directory=. You can also simply symlink the thing into /var/lib/machines... > Alternatively I could create myself a “[email protected]” which would be > identical to [email protected], 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 The path would need escaping... I'd generally recommend just using the final filename in the instance... Also, you could probably even run nspawn with little else than a systemd-run command line, as transient unit. Or you could run nspawn in foreground.... > Opinions? I figure this is a common-enough scenario that there might be some > opinions on this list ... Well, you basically have a lot of options, you need to figure out which ones work best for you ;-) Lennart -- Lennart Poettering, Red Hat _______________________________________________ systemd-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/systemd-devel
