Skip to content

Commit

Permalink
tests.testlib: bugfix in site.Site; enables usage of REUSE=1.
Browse files Browse the repository at this point in the history
Skip creation of (existing) automation user within an existing site
, when REUSE=1.

Details:

During a (system) test-run in the site creation stage,
a new automation user is being created.

When tests are re-run using `REUSE=1`, the site-creation is skipped
BUT the automation user creation is not. This led to a pytest run
failure, as the user already existed.

CMK-21035

Change-Id: I8352872e0766b32792999794916a14914e96a15b
  • Loading branch information
dhsh-checkmk committed Jan 14, 2025
1 parent a3461e1 commit e9349fa
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/testlib/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,10 +1134,9 @@ def core_history_log(self) -> Path:
def core_history_log_timeout(self) -> int:
return 10 if self.core_name() == "cmc" else 30

def _create_automation_user(self) -> None:
username = AUTOMATION_USER
def _create_automation_user(self, username: str) -> None:
self._automation_secret = Password.random(24)

logger.info("Creating test-user: '%s'.", username)
self.openapi.users.create(
username=username,
fullname="Automation user for tests",
Expand All @@ -1152,7 +1151,11 @@ def _create_automation_user(self) -> None:
@tracer.start_as_current_span("Site.prepare_for_tests")
def prepare_for_tests(self) -> None:
logger.info("Prepare for tests")
self._create_automation_user()
username = AUTOMATION_USER
if self.openapi.users.get(username) is None:
self._create_automation_user(username)
else:
logger.info("Reusing existing test-user: '%s' (REUSE=1).", username)
if self.enforce_english_gui:
web = CMKWebSession(self)
if not self.version.is_saas_edition():
Expand Down

0 comments on commit e9349fa

Please sign in to comment.