Skip to content

Commit

Permalink
Fix a problem where release_all is not run correctly (#110)
Browse files Browse the repository at this point in the history
* Fix a problem where release_all is not run correctly
  • Loading branch information
t-persson authored Sep 17, 2024
1 parent ca5695e commit 6983eae
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/environment_provider/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import json
import time
import traceback
import re
from typing import Optional, Union

from etos_lib import ETOS
Expand All @@ -34,6 +35,8 @@


TRACER = trace.get_tracer(__name__)
# REGEX for matching /testrun/tercc-id/suite/main-suite-id/subsuite/subsuite-id/suite.
SUBSUITE_REGEX = r"/testrun/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/suite/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/subsuite/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/suite" # pylint:disable=line-too-long


def checkin_provider(
Expand Down Expand Up @@ -129,14 +132,17 @@ def release_full_environment(etos: ETOS, jsontas: JsonTas, suite_id: str) -> tup
# references to the last log files created. This is to ensure that
# etos-client has enough time to find and download them.
time.sleep(30)
for suite, metadata in registry.testrun.join("suite").read_all():
suite = json.loads(suite)
for sub_suite in suite.get("sub_suites", []):
try:
failure = release_environment(etos, jsontas, registry, sub_suite)
except json.JSONDecodeError as exception:
failure = exception
ETCDPath(metadata.get("key")).delete()
# Iterating over all keys "below" the suite key to find all sub suites.
for value, metadata in registry.testrun.join("suite").read_all():
key = metadata.get("key", b"").decode()
if re.match(SUBSUITE_REGEX, key) is None:
continue
try:
sub_suite = json.loads(value)
failure = release_environment(etos, jsontas, registry, sub_suite)
except json.JSONDecodeError as exception:
failure = exception
ETCDPath(key).delete()
registry.testrun.delete_all()

if failure:
Expand Down

0 comments on commit 6983eae

Please sign in to comment.