summaryrefslogtreecommitdiff
path: root/test/system
diff options
context:
space:
mode:
authorPaul Holzinger <paul.holzinger@web.de>2021-05-05 22:51:23 +0200
committerPaul Holzinger <paul.holzinger@web.de>2021-05-10 12:01:24 +0200
commit77e6ae24369e6c7bed85141ae6f7d0c7b0e26c0b (patch)
tree99c84def2231d9baad798e298fdf79feba0b7c49 /test/system
parent54bed1025d07bc5f77ee4e1e7f942157e211ec0a (diff)
downloadpodman-77e6ae24369e6c7bed85141ae6f7d0c7b0e26c0b.tar.gz
podman-77e6ae24369e6c7bed85141ae6f7d0c7b0e26c0b.tar.bz2
podman-77e6ae24369e6c7bed85141ae6f7d0c7b0e26c0b.zip
Add envars to the generated systemd unit
The with --new generated systemd unit loses the environment variables when the create command only contains the key without the value. Since podman tries to lookup those values from the environment the unit can fail. This commits ensures that we will add the environment variables to the unit file when this is the case. The container environment variables are looked up in the container spec. Fixes #10101 Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'test/system')
-rw-r--r--test/system/250-systemd.bats23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats
index b42769409..4ea192009 100644
--- a/test/system/250-systemd.bats
+++ b/test/system/250-systemd.bats
@@ -125,4 +125,27 @@ function service_cleanup() {
service_cleanup
}
+# These tests can fail in dev. environment because of SELinux.
+# quick fix: chcon -t container_runtime_exec_t ./bin/podman
+@test "podman generate systemd - envar" {
+ xdg_rootless
+
+ cname=$(random_string)
+ FOO=value BAR=%s run_podman create --name $cname --env FOO -e BAR --env MYVAR=myval \
+ $IMAGE sh -c 'printenv && sleep 100'
+
+ # Start systemd service to run this container
+ service_setup
+
+ # Give container time to start; make sure output looks top-like
+ sleep 2
+ run_podman logs $cname
+ is "$output" ".*FOO=value.*" "FOO environment variable set"
+ is "$output" ".*BAR=%s.*" "BAR environment variable set"
+ is "$output" ".*MYVAR=myval.*" "MYVAL environment variable set"
+
+ # All good. Stop service, clean up.
+ service_cleanup
+}
+
# vim: filetype=sh