Skip to content

Commit

Permalink
upstream ci: Avoid scheduling tests that will not be executed.
Browse files Browse the repository at this point in the history
Currently, all tests are scheduled to execution, even those that are
not executed due to be absent from the list of enabled tests configured
in the IPA_ENABLED_* variables. The tests that are not executed are
marked 'skipped'.

This patch change this behavior by no scheduling tests that are not on
the list of enabled tests, if any of the IPA_ENABLED_* variables is set

The behavior of disabled tests is not changed and the test is 'skipped'
  • Loading branch information
rjeffman committed Jun 23, 2022
1 parent c254639 commit 1f820de
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
23 changes: 13 additions & 10 deletions tests/test_playbook_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

from unittest import TestCase

from utils import get_test_playbooks, get_skip_conditions, run_playbook
from utils import (
get_test_playbooks, get_skip_conditions, run_playbook, get_enabled_test
)


def prepare_test(testname, testpath):
Expand Down Expand Up @@ -56,16 +58,17 @@ def wrapper(*args, **kwargs):
test_name = playbook["name"].replace("-", "_")
test_path = playbook["path"]

skip = get_skip_conditions(test_dir_name, test_name) or {}
if get_enabled_test(test_dir_name, test_name):
skip = get_skip_conditions(test_dir_name, test_name) or {}

# pylint: disable=W0621,W0640,W0613
@pytest.mark.skipif(**skip)
@pytest.mark.playbook
@prepare_test(test_name, test_path)
def method(self, test_path, test_name):
run_playbook(test_path)
# pylint: enable=W0621,W0640,W0613
# pylint: disable=W0621,W0640,W0613
@pytest.mark.skipif(**skip)
@pytest.mark.playbook
@prepare_test(test_name, test_path)
def method(self, test_path, test_name):
run_playbook(test_path)
# pylint: enable=W0621,W0640,W0613

_tests[test_name] = method
_tests[test_name] = method

globals()[test_dir_name] = type(test_dir_name, tuple([TestCase]), _tests,)
7 changes: 2 additions & 5 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ def get_disabled_test(group_name, test_name):
def get_enabled_test(group_name, test_name):
enabled_modules = [
enabled.strip()
for enabled in os.environ.get("IPA_ENABLED_MODULES", "").split(":")
for enabled in os.environ.get("IPA_ENABLED_MODULES", "").split(",")
if enabled.strip()
]
enabled_tests = [
enabled.strip()
for enabled in os.environ.get("IPA_ENABLED_TESTS", "").split(":")
for enabled in os.environ.get("IPA_ENABLED_TESTS", "").split(",")
if enabled.strip()
]

Expand Down Expand Up @@ -128,9 +128,6 @@ def get_skip_conditions(group_name, test_name):
"reason": "Environment variable IPA_SERVER_HOST must be set",
}

if not get_enabled_test(group_name, test_name):
return {"condition": True, "reason": "Test not configured to run"}

if get_disabled_test(group_name, test_name):
return {"condition": True, "reason": "Test configured to not run"}

Expand Down

0 comments on commit 1f820de

Please sign in to comment.