|
17 | 17 | import json
|
18 | 18 | import time
|
19 | 19 | import traceback
|
| 20 | +import re |
20 | 21 | from typing import Optional, Union
|
21 | 22 |
|
22 | 23 | from etos_lib import ETOS
|
|
34 | 35 |
|
35 | 36 |
|
36 | 37 | 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 |
37 | 40 |
|
38 | 41 |
|
39 | 42 | def checkin_provider(
|
@@ -129,14 +132,17 @@ def release_full_environment(etos: ETOS, jsontas: JsonTas, suite_id: str) -> tup
|
129 | 132 | # references to the last log files created. This is to ensure that
|
130 | 133 | # etos-client has enough time to find and download them.
|
131 | 134 | 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() |
140 | 146 | registry.testrun.delete_all()
|
141 | 147 |
|
142 | 148 | if failure:
|
|
0 commit comments