Skip to content

Commit 008c6c2

Browse files
committed
Introduce 'requires_non_root_user' marker
Introduce a new marker and mark the tests which require a user different from root and therefore can't be executed in Kubernetes. Add two new integration make targets: one runs only the marked tests and another one all the tests except for marked. Use the second one in 'test-integration-single-f12less-k8s.groovy'. CMK-24352 Change-Id: I54b5b304b9ad2bdb5ef62d482406a3be6f7b011c
1 parent 1e55619 commit 008c6c2

4 files changed

Lines changed: 16 additions & 1 deletion

File tree

buildscripts/scripts/test-integration-single-f12less-k8s.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void main() {
2222
def edition = params.EDITION;
2323
def fake_artifacts = params.FAKE_ARTIFACTS;
2424

25-
def make_target = "test-integration";
25+
def make_target = "test-integration-k8s";
2626
def download_dir = "package_download";
2727
def test_results_dir = "test-results";
2828

tests/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ RANDOM_TZ = $(shell printf "UTC%+d\n" $$(( $$RANDOM / 1261 - 11 )) )
3131

3232
SYSTEM_TESTS := \
3333
test-integration \
34+
test-integration-k8s \
35+
test-integration-non-root \
3436
test-integration-redfish \
3537
test-integration-otel \
3638
test-composition \
@@ -239,6 +241,14 @@ test-integration:
239241
$(PYTEST) $(PYTEST_SYSTEM_TEST_ARGS) $(realpath integration) \
240242
--session-timeout 7200
241243

244+
test-integration-k8s:
245+
$(PYTEST) $(PYTEST_SYSTEM_TEST_ARGS) $(realpath integration) \
246+
-m "not requires_non_root_user" --session-timeout 7200
247+
248+
test-integration-non-root:
249+
$(PYTEST) $(PYTEST_SYSTEM_TEST_ARGS) $(realpath integration) \
250+
-m requires_non_root_user --session-timeout 600
251+
242252
test-integration-redfish:
243253
$(PYTEST) $(PYTEST_SYSTEM_TEST_ARGS) \
244254
$(realpath integration_redfish) --session-timeout 1800

tests/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,10 @@ def pytest_configure(config: pytest.Config) -> None:
374374
"markers",
375375
"skip_on_code_coverage: skip the tests when code-coverage measurement is active",
376376
)
377+
config.addinivalue_line(
378+
"markers",
379+
"requires_non_root_user: Tests that require a non-root user to be executed.",
380+
)
377381

378382

379383
def pytest_collection_modifyitems(items: list[pytest.Function], config: pytest.Config) -> None:

tests/integration/agents/test_check_mk_agent.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def _write_config(runas_user: str, mk_confdir: Path, script_dir: Path) -> None:
3131
cfg_file.write_text(f"local {runas_user} {script_dir.as_posix()}", encoding="UTF-8")
3232

3333

34+
@pytest.mark.requires_non_root_user
3435
@pytest.mark.parametrize("runas_user", ["root", "user"])
3536
def test_cmk_agent_run_runas_executor(runas_user: str, tmp_path: Path) -> None:
3637
# the actual username

0 commit comments

Comments
 (0)