From b52340635b5d40e15217917bf5808e06ce0c52f6 Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Nov 03 2023 20:22:42 +0000 Subject: Improve test_nginx.sh - use download-prg.infra.opensuse.org (faster) - check if one of the roles installs packages we don't have in the docker image yet - replace systemctl (which refues to work inside docker) with a symlink to /usr/bin/true to avoid useless error messages - fix filename of subroles in grep command - run salt non-quiet so that we see error messages --- diff --git a/bin/test_nginx.sh b/bin/test_nginx.sh index b882b3f..c899400 100755 --- a/bin/test_nginx.sh +++ b/bin/test_nginx.sh @@ -2,8 +2,17 @@ # Validate the salt-generated nginx configs +sed -i 's/download.opensuse.org/download-prg.infra.opensuse.org/' /etc/zypp/repos.d/* + +zypper lr -d + +rpm -qa --qf '%{name}\n' | sort > /tmp/packages-before + [[ $(whoami) == 'root' ]] || { echo 'Please run this script as root'; exit 1; } +# systemctl refuses to work in a container, but is needed by service.running. Replace it with /usr/bin/true to avoid useless error messages +( cd /usr/bin/ ; ln -sf true systemctl ) + source bin/get_colors.sh rpm -q nginx salt salt-master @@ -78,11 +87,11 @@ WEB_ROLES=( $(bin/get_roles.py) ) for role in ${WEB_ROLES[@]}; do rolestatus=0 - if grep nginx salt/role/$role.sls > /dev/null; then + if grep nginx salt/role/${role/./\/}.sls > /dev/null; then echo_INFO "Testing role: $role" reset_nginx reset_ip - salt-call --local -l quiet state.apply role.$role > /dev/null + salt-call --local state.apply role.$role > /dev/null create_fake_certs touch_includes $role @@ -110,6 +119,11 @@ for role in ${WEB_ROLES[@]}; do fi done +rpm -qa --qf '%{name}\n' | sort > /tmp/packages-after + +diff -U0 /tmp/packages-before /tmp/packages-after || echo '=== The packages listed above were installed by one of the roles. Consider to add them to the docker image to speed up this test.' + + exit $STATUS vim:expandtab