Add gating tests

Related: #1966688
This commit is contained in:
Ryan O'Hara 2021-08-10 13:11:41 -05:00
parent 401bac44f6
commit f585e9ceb5
4 changed files with 177 additions and 0 deletions

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-9
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

16
tests/haproxy.cfg.in Normal file
View File

@ -0,0 +1,16 @@
global
daemon
maxconn 1024
user haproxy
group haproxy
defaults
mode http
timeout connect 2s
timeout client 10s
timeout server 10s
listen test
bind *:81
server $VHOST1_NAME $VHOST1_ADDR:$VHOST1_PORT check
server $VHOST2_NAME $VHOST2_ADDR:$VHOST2_PORT check

142
tests/run_tests.sh Executable file
View File

@ -0,0 +1,142 @@
#!/bin/sh
export VHOST1_NAME="vhost1"
export VHOST1_ADDR="192.168.100.101"
export VHOST1_PORT="80"
export VHOST2_NAME="vhost2"
export VHOST2_ADDR="192.168.100.102"
export VHOST2_PORT="80"
mkdir -p /var/www/html/${VHOST1_NAME}
mkdir -p /var/www/html/${VHOST2_NAME}
echo ${VHOST1_NAME} > /var/www/html/${VHOST1_NAME}/index.html
echo ${VHOST2_NAME} > /var/www/html/${VHOST2_NAME}/index.html
restorecon -R /var/www/html
cat >/etc/httpd/conf.d/vhost.conf <<EOF
<VirtualHost ${VHOST1_ADDR}:${VHOST1_PORT}>
DocumentRoot /var/www/html/${VHOST1_NAME}
</VirtualHost>
<VirtualHost ${VHOST2_ADDR}:${VHOST2_PORT}>
DocumentRoot /var/www/html/${VHOST2_NAME}
</VirtualHost>
EOF
echo -ne "[debug]: adding ${VHOST1_ADDR} ... "
ip addr add ${VHOST1_ADDR} dev lo
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
echo -ne "[debug]: adding ${VHOST1_ADDR} ... "
ip addr add ${VHOST2_ADDR} dev lo
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
echo -ne "[debug]: starting httpd service ... "
systemctl start httpd
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
echo -ne "[debug]: checking httpd active ... "
systemctl -q is-active httpd
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
VHOST1_VARS='${VHOST1_NAME}:${VHOST1_ADDR}:${VHOST1_PORT}'
VHOST2_VARS='${VHOST2_NAME}:${VHOST2_ADDR}:${VHOST2_PORT}'
echo -ne "[debug]: setting up config file .... "
envsubst "${VHOST1_VARS},${VHOST2_VARS}" < ./haproxy.cfg.in > /etc/haproxy/haproxy.cfg
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
echo -ne "[debug]: configuring selinux policy ... "
setsebool haproxy_connect_any 1
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
echo -ne "[debug]: starting haproxy service ... "
systemctl start haproxy
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
echo -ne "[debug]: checking haproxy active ... "
systemctl -q is-active haproxy
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
echo -ne "[debug]: fetching URL via haproxy ... "
if [[ $( curl -s http://127.0.0.1:81 ) != ${VHOST1_NAME} ]] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
echo -ne "[debug]: fetching URL via haproxy ... "
if [[ $( curl -s http://127.0.0.1:81 ) != ${VHOST2_NAME} ]] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
echo -ne "[debug]: stopping haproxy service ... "
systemctl stop haproxy
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
echo -ne "[debug]: checking haproxy inactive ... "
systemctl -q is-active haproxy
if [ $? -ne 3 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
systemctl stop httpd
ip addr del ${VHOST1_ADDR}/32 dev lo
ip addr del ${VHOST2_ADDR}/32 dev lo
exit 0

13
tests/tests.yml Normal file
View File

@ -0,0 +1,13 @@
- hosts: localhost
roles:
- role: standard-test-basic
tags:
- classic
tests:
- simple:
dir: .
run: ./run_tests.sh
required_packages:
- curl
- gettext
- httpd