Skip to content

Commit

Permalink
testlib.site: Fix issues w/ broken sites if reuse is False
Browse files Browse the repository at this point in the history
In case a test site already exists but is broken, so far we tried to start it anyway, causing the test to fail. This change fixes that, as we no longer start an existing site if we do not reuse it.

Change-Id: I704dd820d192f1f4ca2e90143ad129dc713247a8
  • Loading branch information
rene-slowenski-checkmk committed Nov 13, 2023
1 parent d3d1271 commit ea00489
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/testlib/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -1354,14 +1354,20 @@ def get_site(
logger.debug("Created site %s", site.id)
return site

def get_existing_site(self, name: str, init_livestatus: bool = True) -> Site:
def get_existing_site(
self,
name: str,
start: bool = True,
init_livestatus: bool = True,
) -> Site:
site = self._site_obj(name)

if not site.exists():
if not (site.exists() and start):
return site

if init_livestatus:
site.gather_livestatus_port(from_config=True)

site.start()
logger.debug("Reused site %s", site.id)
return site
Expand Down Expand Up @@ -1581,7 +1587,7 @@ def get_test_site(
if os.environ.get("CLEANUP") is None
else os.environ.get("CLEANUP") == "1"
)
site = self.get_existing_site(name)
site = self.get_existing_site(name, start=reuse_site)
if site.exists():
if reuse_site:
logger.info('Reusing existing site "%s" (REUSE=1)', site.id)
Expand Down

0 comments on commit ea00489

Please sign in to comment.