From 7e136b4e0428db1e199184ed7c99325c70457357 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara Date: Tue, 17 Aug 2021 10:09:37 -0500 Subject: [PATCH] Add gating tests Resolves: #1994617 --- gating.yaml | 6 ++ ipvsadm.spec | 5 +- tests/run_tests.sh | 161 +++++++++++++++++++++++++++++++++++++++++++++ tests/tests.yml | 9 +++ 4 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 gating.yaml create mode 100755 tests/run_tests.sh create mode 100644 tests/tests.yml diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..648918d --- /dev/null +++ b/gating.yaml @@ -0,0 +1,6 @@ +--- !Policy +product_versions: + - rhel-9 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} diff --git a/ipvsadm.spec b/ipvsadm.spec index e44e427..da701f6 100644 --- a/ipvsadm.spec +++ b/ipvsadm.spec @@ -1,7 +1,7 @@ Name: ipvsadm Summary: Utility to administer the Linux Virtual Server Version: 1.31 -Release: 6%{?dist} +Release: 7%{?dist} License: GPLv2+ URL: https://kernel.org/pub/linux/utils/kernel/ipvsadm/ @@ -73,6 +73,9 @@ services. Supported Features include: %{_mandir}/man8/%{name}-save.8* %changelog +* Tue Aug 17 2021 Ryan O'Hara - 1.31-7 +- Add gating tests (#1994617) + * Mon Aug 09 2021 Mohan Boddu - 1.31-6 - Rebuilt for IMA sigs, glibc 2.34, aarch64 flags Related: rhbz#1991688 diff --git a/tests/run_tests.sh b/tests/run_tests.sh new file mode 100755 index 0000000..53e2052 --- /dev/null +++ b/tests/run_tests.sh @@ -0,0 +1,161 @@ +#!/bin/sh + +set -o pipefail + +echo -ne "[debug]: getting IP address ... " +IP_ADDR=$( ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1 ) +if [ $? -ne 0 ] ; then + echo "FAIL" + exit 1 +else + echo "OK" +fi + +echo -ne "[debug]: adding virtual service ${IP_ADDR}:80 ... " +ipvsadm -A -t ${IP_ADDR}:80 -s rr +if [ $? -ne 0 ] ; then + echo "FAIL" + exit 1 +else + echo "OK" +fi + +for i in {1..3}; do + echo -ne "[debug]: adding real server 192.168.100.10${i}:80 ... " + ipvsadm -a -t ${IP_ADDR}:80 -r 192.168.100.10${i}:80 -w 1 -m + if [ $? -ne 0 ] ; then + echo "FAIL" + exit 1 + else + echo "OK" + fi +done + +echo -ne "[debug]: checking ipvs is populated ... " +ipvsadm -l -n | grep -q -E "(${IP_ADDR}|192.168.100.10)" +if [ $? -ne 0 ] ; then + echo "FAIL" + exit 1 +else + echo "OK" +fi + +for mod in ip_vs_rr ip_vs; do + echo -ne "[debug]: checking for module ${mod} ... " + grep -q "^${mod} " /proc/modules + if [ $? -ne 0 ] ; then + echo "FAIL" + exit 1 + else + echo "OK" + fi +done + +echo -ne "[debug]: saving ipvsadm configuration ... " +ipvsadm-save -n > /etc/sysconfig/ipvsadm +if [ $? -ne 0 ] ; then + echo "FAIL" + exit 1 +else + echo "OK" +fi + +echo -ne "[debug]: clearing ipvsadm configuration ... " +ipvsadm -C +if [ $? -ne 0 ] ; then + echo "FAIL" + exit 1 +else + echo "OK" +fi + +echo -ne "[debug]: checking ipvs is clear ... " +ipvsadm -l -n | grep -E "(${IP_ADDR}|192.168.100.10)" +if [ $? -eq 0 ] ; then + echo "FAIL" + exit 1 +else + echo "OK" +fi + +for mod in ip_vs_rr ip_vs; do + echo -ne "[debug]: removing module ${mod} ... " + modprobe -r ${mod} + if [ $? -ne 0 ] ; then + echo "FAIL" + exit 1 + else + echo "OK" + fi +done + +for mod in ip_vs_rr ip_vs; do + echo -ne "[debug]: checking for no ${mod} module ... " + grep -q "^${mod} " /proc/modules + if [ $? -eq 0 ] ; then + echo "FAIL" + exit 1 + else + echo "OK" + fi +done + +echo -ne "[debug]: restoring ipvsadm configuration ... " +ipvsadm-restore < /etc/sysconfig/ipvsadm +if [ $? -ne 0 ] ; then + echo "FAIL" + exit 1 +else + echo "OK" +fi + +echo -ne "[debug]: checking ipvs is populated ... " +ipvsadm -l -n | grep -q -E "(${IP_ADDR}|192.168.100.10)" +if [ $? -ne 0 ] ; then + echo "FAIL" + exit 1 +else + echo "OK" +fi + +for mod in ip_vs_rr ip_vs; do + echo -ne "[debug]: checking for module ${mod} ... " + grep -q "^${mod} " /proc/modules + if [ $? -ne 0 ] ; then + echo "FAIL" + exit 1 + else + echo "OK" + fi +done + +for i in {3..1}; do + echo -ne "[debug]: removing real server 192.168.100.10${i}:80 ... " + ipvsadm -d -t ${IP_ADDR}:80 -r 192.168.100.10${i}:80 + if [ $? -ne 0 ] ; then + echo "FAIL" + exit 1 + else + echo "OK" + fi +done + +echo -ne "[debug]: removing virtual service ${IP_ADDR}:80 ... " +ipvsadm -D -t ${IP_ADDR}:80 +if [ $? -ne 0 ] ; then + echo "FAIL" + exit 1 +else + echo "OK" +fi + +echo -ne "[debug]: checking ipvs is clear ... " +ipvsadm -l -n | grep -E "(${IP_ADDR}|192.168.100.10)" +if [ $? -eq 0 ] ; then + echo "FAIL" + exit 1 +else + echo "OK" +fi + +exit 0 diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..a727ce8 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,9 @@ +- hosts: localhost + roles: + - role: standard-test-basic + tags: + - classic + tests: + - simple: + dir: . + run: ./run_tests.sh