From edccf70bf63932dfdf443f5f8741e95f8897a63c Mon Sep 17 00:00:00 2001
From: Rafael Guterres Jeffman <rjeffman@redhat.com>
Date: Mon, 22 Aug 2022 16:03:07 -0300
Subject: [PATCH] upstream ci: Add support for distro specific test
 configuration.

Sometimes, mostly due do differences in package versions, there are
some tests that fail on a single distribution which cannot be fixed
by ansible-freeipa, requiring that the offending package is fixed.

To keep tests running succesfully we have options to disable the
failing tests, but this changes are globally applied, meaning that, by
disabling a test, it is disable in all tested distributions.

This patch allows tests to be enabled or disabled for a specific
distribution, by setting the configuration on the 'variable' template
for the specific testing scenario.
---
 tests/azure/templates/galaxy_script.yml       |  1 +
 tests/azure/templates/playbook_tests.yml      |  1 +
 tests/azure/templates/pytest_tests.yml        |  1 +
 tests/azure/templates/variables.yaml          | 10 ++++++----
 tests/azure/templates/variables_c8s.yaml      | 19 ++++++++++++++++++
 tests/azure/templates/variables_c9s.yaml      | 19 ++++++++++++++++++
 tests/azure/templates/variables_centos-7.yaml | 19 ++++++++++++++++++
 .../templates/variables_fedora-latest.yaml    | 20 +++++++++++++++++++
 .../templates/variables_fedora-rawhide.yaml   | 19 ++++++++++++++++++
 9 files changed, 105 insertions(+), 4 deletions(-)
 create mode 100644 tests/azure/templates/variables_c8s.yaml
 create mode 100644 tests/azure/templates/variables_c9s.yaml
 create mode 100644 tests/azure/templates/variables_centos-7.yaml
 create mode 100644 tests/azure/templates/variables_fedora-latest.yaml
 create mode 100644 tests/azure/templates/variables_fedora-rawhide.yaml

diff --git a/tests/azure/templates/galaxy_script.yml b/tests/azure/templates/galaxy_script.yml
index b6694818..bf14238c 100644
--- a/tests/azure/templates/galaxy_script.yml
+++ b/tests/azure/templates/galaxy_script.yml
@@ -25,6 +25,7 @@ jobs:
   timeoutInMinutes: 120
   variables:
   - template: variables.yaml
+  - template: variables_${{ parameters.scenario }}.yaml
   steps:
   - task: UsePythonVersion@0
     inputs:
diff --git a/tests/azure/templates/playbook_tests.yml b/tests/azure/templates/playbook_tests.yml
index 3fb15ad3..abbdf8c0 100644
--- a/tests/azure/templates/playbook_tests.yml
+++ b/tests/azure/templates/playbook_tests.yml
@@ -24,6 +24,7 @@ jobs:
   timeoutInMinutes: 120
   variables:
   - template: variables.yaml
+  - template: variables_${{ parameters.scenario }}.yaml
   steps:
   - task: UsePythonVersion@0
     inputs:
diff --git a/tests/azure/templates/pytest_tests.yml b/tests/azure/templates/pytest_tests.yml
index f25ce2a7..6afd5890 100644
--- a/tests/azure/templates/pytest_tests.yml
+++ b/tests/azure/templates/pytest_tests.yml
@@ -18,6 +18,7 @@ jobs:
   timeoutInMinutes: 120
   variables:
   - template: variables.yaml
+  - template: variables_${{ parameters.scenario }}.yaml
   steps:
   - task: UsePythonVersion@0
     inputs:
diff --git a/tests/azure/templates/variables.yaml b/tests/azure/templates/variables.yaml
index b6e16868..3cdadc03 100644
--- a/tests/azure/templates/variables.yaml
+++ b/tests/azure/templates/variables.yaml
@@ -3,6 +3,9 @@
 # For easier management of items to enable/disable,
 # use one test/module on each line, followed by a comma.
 #
+# If no variable is to be set, add 'empty: true', as the
+# 'variables' dict cannot be empty.
+#
 # Example:
 #
 # disabled_modules: >-
@@ -12,9 +15,8 @@
 #
 ---
 variables:
+  empty: true
   # ipa_enabled_modules: >-
   # ipa_enabled_tests: >-
-  ipa_disabled_modules: >-
-    dnsconfig,
-  ipa_disabled_tests: >-
-    test_dnsconfig_forwarders_ports
+  # ipa_disabled_modules: >-
+  # ipa_disabled_tests: >-
diff --git a/tests/azure/templates/variables_c8s.yaml b/tests/azure/templates/variables_c8s.yaml
new file mode 100644
index 00000000..586d5ecb
--- /dev/null
+++ b/tests/azure/templates/variables_c8s.yaml
@@ -0,0 +1,19 @@
+#
+# Variables must be defined as comma separated lists.
+# For easier management of items to enable/disable,
+# use one test/module on each line, followed by a comma.
+#
+# Example:
+#
+# disabled_modules: >-
+#   dnsconfig,
+#   group,
+#   hostgroup
+#
+---
+variables:
+  empty: true
+#   ipa_enabled_modules: >-
+#   ipa_enabled_tests: >-
+#   ipa_disabled_modules: >-
+#   ipa_disabled_tests: >-
diff --git a/tests/azure/templates/variables_c9s.yaml b/tests/azure/templates/variables_c9s.yaml
new file mode 100644
index 00000000..586d5ecb
--- /dev/null
+++ b/tests/azure/templates/variables_c9s.yaml
@@ -0,0 +1,19 @@
+#
+# Variables must be defined as comma separated lists.
+# For easier management of items to enable/disable,
+# use one test/module on each line, followed by a comma.
+#
+# Example:
+#
+# disabled_modules: >-
+#   dnsconfig,
+#   group,
+#   hostgroup
+#
+---
+variables:
+  empty: true
+#   ipa_enabled_modules: >-
+#   ipa_enabled_tests: >-
+#   ipa_disabled_modules: >-
+#   ipa_disabled_tests: >-
diff --git a/tests/azure/templates/variables_centos-7.yaml b/tests/azure/templates/variables_centos-7.yaml
new file mode 100644
index 00000000..586d5ecb
--- /dev/null
+++ b/tests/azure/templates/variables_centos-7.yaml
@@ -0,0 +1,19 @@
+#
+# Variables must be defined as comma separated lists.
+# For easier management of items to enable/disable,
+# use one test/module on each line, followed by a comma.
+#
+# Example:
+#
+# disabled_modules: >-
+#   dnsconfig,
+#   group,
+#   hostgroup
+#
+---
+variables:
+  empty: true
+#   ipa_enabled_modules: >-
+#   ipa_enabled_tests: >-
+#   ipa_disabled_modules: >-
+#   ipa_disabled_tests: >-
diff --git a/tests/azure/templates/variables_fedora-latest.yaml b/tests/azure/templates/variables_fedora-latest.yaml
new file mode 100644
index 00000000..04fb6d29
--- /dev/null
+++ b/tests/azure/templates/variables_fedora-latest.yaml
@@ -0,0 +1,20 @@
+#
+# Variables must be defined as comma separated lists.
+# For easier management of items to enable/disable,
+# use one test/module on each line, followed by a comma.
+#
+# Example:
+#
+# disabled_modules: >-
+#   dnsconfig,
+#   group,
+#   hostgroup
+#
+---
+variables:
+  # ipa_enabled_modules: >-
+  # ipa_enabled_tests: >-
+  ipa_disabled_modules: >-
+    dnsforwardzone,
+  ipa_disabled_tests: >-
+    test_dnsconfig_forwarders_ports
diff --git a/tests/azure/templates/variables_fedora-rawhide.yaml b/tests/azure/templates/variables_fedora-rawhide.yaml
new file mode 100644
index 00000000..d828bccb
--- /dev/null
+++ b/tests/azure/templates/variables_fedora-rawhide.yaml
@@ -0,0 +1,19 @@
+#
+# Variables must be defined as comma separated lists.
+# For easier management of items to enable/disable,
+# use one test/module on each line, followed by a comma.
+#
+# Example:
+#
+# disabled_modules: >-
+#   dnsconfig,
+#   group,
+#   hostgroup
+#
+---
+variables:
+  empty: true
+  # ipa_enabled_modules: >-
+  # ipa_enabled_tests: >-
+  # ipa_disabled_modules: >-
+  # ipa_disabled_tests: >-
-- 
GitLab