Skip to content

Commit 9694177

Browse files
committed
system tests: safer install_kube_template()
Previous version was badly broken: it relied on 'make' rebuilding a file under cwd, which is a no-no; and, in the case where we don't have a source directory, just blindly hoped that there'd be a system-installed .service file with the correct path to podman. Solution: . if running in source directory, run sed directly into destination service file in $UNIT_DIR. This is ugly duplication of a line in Makefile. . if NOT running in a source directory, check $PODMAN: . if it's /usr/bin/podman, continue. Include a warning that will be shown only on test failure. . otherwise skip, because we don't know what we're testing Signed-off-by: Ed Santiago <[email protected]>
1 parent 50714d2 commit 9694177

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

test/system/helpers.systemd.bash

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,18 @@ install_kube_template() {
6565
# If running from a podman source directory, build and use the source
6666
# version of the play-kube-@ unit file
6767
unit_name="[email protected]"
68-
unit_file="contrib/systemd/system/${unit_name}"
69-
if [[ -e ${unit_file}.in ]]; then
70-
echo "# [Building & using $unit_name from source]" >&3
71-
# Force regenerating unit file (existing one may have /usr/bin path)
72-
rm -f $unit_file
73-
BINDIR=$(dirname $PODMAN) make $unit_file
74-
cp $unit_file $UNIT_DIR/$unit_name
68+
unit_file_in="contrib/systemd/system/${unit_name}.in"
69+
if [[ -e $unit_file_in ]]; then
70+
unit_file_out=$UNIT_DIR/$unit_name
71+
sed -e "s;@@PODMAN@@;$PODMAN;g" <$unit_file_in >$unit_file_out.tmp.$$ \
72+
&& mv $unit_file_out.tmp.$$ $unit_file_out
73+
elif [[ "$PODMAN" = "/usr/bin/podman" ]]; then
74+
# Not running from a source directory. This is expected in gating,
75+
# and is probably OK, but it could fail on a misinstalled setup.
76+
# Maintainer will only see this warning in case of test failure.
77+
echo "WARNING: Test will rely on system-installed unit files." >&2
78+
else
79+
skip "No $unit_file_in, and PODMAN=$PODMAN"
7580
fi
7681
}
7782

0 commit comments

Comments
 (0)