Skip to content

Commit

Permalink
Merge pull request #111 from Tauffer-Consulting/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
vinicvaz authored Oct 16, 2023
2 parents dd56e8a + b07c412 commit 164c811
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/domino/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.4
0.5.5
6 changes: 4 additions & 2 deletions src/domino/testing/dry_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def piece_dry_run(
logger = get_configured_logger("piece_dry_run")

pieces_images_map = os.environ.get("PIECES_IMAGES_MAP", {})
http_server = None
if pieces_images_map and piece_name in pieces_images_map:
try:
from domino.testing.http_client import TestingHttpClient
Expand All @@ -51,8 +52,9 @@ def piece_dry_run(
return dry_run_response.json()
except Exception as e:
logger.error(f"Error running dry run with http client: {e}")
http_server.stop()
http_server.remove()
if http_server:
http_server.stop()
http_server.remove()
raise e

if not repository_folder_path:
Expand Down
7 changes: 4 additions & 3 deletions src/domino/testing/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
import time
import docker
from domino.logger import get_configured_logger
from domino.testing import http_server
from pathlib import Path


class TestingHttpClient:

docker_client = docker.from_env()
DOMINO_TESTING_CONTAINER_NAME = 'domino_testing_http_server'
DOMINO_INTERNAL_REPOSITORY_FOLDER_PATH = "/home/domino/pieces_repository/"
BASE_HTTP_SERVER_HOST_URL = "http://0.0.0.0:8080"
logger = get_configured_logger("TestingHttpClient")

@classmethod
def wait_health_check(cls):
max_retries = 10
max_retries = 30
retry_delay_in_seconds = 1
url = f'{cls.BASE_HTTP_SERVER_HOST_URL}/health-check'
for _ in range(max_retries):
Expand All @@ -38,6 +38,7 @@ def start_http_server(cls, image: str):
image=image,
command=["bash", "-c", "python -c 'from domino.testing import http_server; http_server.run_server()'"],
ports={'8080/tcp': ('0.0.0.0', 8080)},
name=cls.DOMINO_TESTING_CONTAINER_NAME,
detach=True,
)
container_state = container.attrs.get('State').get('Running')
Expand All @@ -51,7 +52,7 @@ def start_http_server(cls, image: str):
cls.wait_health_check()
return container
except Exception as e:
container = cls.docker_client.containers.get('domino_testing_http_server')
container = cls.docker_client.containers.get(cls.DOMINO_TESTING_CONTAINER_NAME)
if container:
container.stop()
container.remove()
Expand Down

0 comments on commit 164c811

Please sign in to comment.