From b98937464e252aae34954b272d0f523e1766cf83 Mon Sep 17 00:00:00 2001 From: Oyvind Albrigtsen Date: Fri, 12 Apr 2024 10:23:43 +0200 Subject: [PATCH] - Add CI gating tests Resolves: RHEL-25954 --- gating.yaml | 6 ++++++ tests/run_tests.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ tests/tests.yml | 19 +++++++++++++++++++ 3 files changed, 70 insertions(+) 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/tests/run_tests.sh b/tests/run_tests.sh new file mode 100755 index 0000000..351104d --- /dev/null +++ b/tests/run_tests.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +PYTHON_VERSION=$(python3 --version | awk '{print $NF}') +err=0 + +if [ "$(pcs stonith list 2> /dev/null | wc -l)" -eq 0 ]; then + echo "ERROR: pcs: no agents available..." + err=$((err+1)) +fi +echo "INFO: pcs: agents available..." + +# test bundled libraries +declare -A libs=( + # aliyun + ["aliyunsdkcore"]="sys.path.insert(0, '/usr/lib/fence-agents/support/aliyun/lib/python$PYTHON_VERSION/site-packages');" + ["aliyunsdkecs"]="sys.path.insert(0, '/usr/lib/fence-agents/support/aliyun/lib/python$PYTHON_VERSION/site-packages');" + # aws + ["boto3"]="sys.path.insert(0, '/usr/lib/fence-agents/support/aws/lib/python$PYTHON_VERSION/site-packages');" + # azure + ["azure"]="sys.path.insert(0, '/usr/lib/fence-agents/support/azure/lib/python$PYTHON_VERSION/site-packages');" + ["msrestazure"]="sys.path.insert(0, '/usr/lib/fence-agents/support/azure/lib/python$PYTHON_VERSION/site-packages');" + # common + ["pexpect"]="sys.path.insert(0, '/usr/lib/fence-agents/support/common/lib/python$PYTHON_VERSION/site-packages');" + ["suds"]="sys.path.insert(0, '/usr/lib/fence-agents/support/common/lib/python$PYTHON_VERSION/site-packages');" + # google + ["googleapiclient"]="sys.path.insert(0, '/usr/lib/fence-agents/support/google/lib/python$PYTHON_VERSION/site-packages');" + ["pyroute2"]="sys.path.insert(0, '/usr/lib/fence-agents/support/google/lib/python$PYTHON_VERSION/site-packages');" + ) + +for lib in "${!libs[@]}"; do + output=$(python3 -c "import sys; sys.path.append('/usr/share/fence'); \ + ${libs[$lib]} \ + import $lib" 2>&1) + if [ $? -ne 0 ]; then + echo -e "ERROR: Failed to import $lib:\n$output" + err=$((err+1)) + else + echo "INFO: importing $lib works..." + fi +done + +if [ $err -ge 1 ]; then + echo -e "\nERROR: $err tests FAILED..." + exit 1 +fi diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..0cbc907 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,19 @@ +- hosts: localhost + roles: + - role: standard-test-basic + tags: + - classic + - container + required_packages: + - fence-agents-all + - fence-agents-aliyun + - fence-agents-aws + - fence-agents-azure-arm + - fence-agents-gce + - fence-agents-virsh + - pcs + + tests: + - subpackage_tests: + dir: . + run: ./run_tests.sh