Skip to content

Commit 6983eae

Browse files
authored
Fix a problem where release_all is not run correctly (#110)
* Fix a problem where release_all is not run correctly
1 parent ca5695e commit 6983eae

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/environment_provider/environment.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import json
1818
import time
1919
import traceback
20+
import re
2021
from typing import Optional, Union
2122

2223
from etos_lib import ETOS
@@ -34,6 +35,8 @@
3435

3536

3637
TRACER = trace.get_tracer(__name__)
38+
# REGEX for matching /testrun/tercc-id/suite/main-suite-id/subsuite/subsuite-id/suite.
39+
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
3740

3841

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

142148
if failure:

0 commit comments

Comments
 (0)