Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a problem where release_all is not run correctly #110

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading