Skip to content

Commit

Permalink
add healthcheck wait condition and parallelize starting of containers
Browse files Browse the repository at this point in the history
  • Loading branch information
hubertdeng123 committed Dec 10, 2024
1 parent ade1b03 commit a899549
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 12 additions & 3 deletions devservices/commands/up.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import concurrent.futures
import os
import subprocess
from argparse import _SubParsersAction
Expand Down Expand Up @@ -128,7 +129,7 @@ def _up(
current_env[
DEVSERVICES_DEPENDENCIES_CACHE_DIR_KEY
] = relative_local_dependency_directory
options = ["-d"]
options = ["-d", "--wait"]
dependency_graph = construct_dependency_graph(service, modes=modes)
starting_order = dependency_graph.get_starting_order()
sorted_remote_dependencies = sorted(
Expand All @@ -144,8 +145,16 @@ def _up(
mode_dependencies=mode_dependencies,
)

for cmd in docker_compose_commands:
_bring_up_dependency(cmd, current_env, status, len(options))
cmd_outputs = []
with concurrent.futures.ThreadPoolExecutor() as executor:
futures = [
executor.submit(
_bring_up_dependency, cmd, current_env, status, len(options)
)
for cmd in docker_compose_commands
]
for future in concurrent.futures.as_completed(futures):
cmd_outputs.append(future.result())


def _create_devservices_network() -> None:
Expand Down
4 changes: 4 additions & 0 deletions tests/commands/test_up.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def test_up_simple(
"clickhouse",
"redis",
"-d",
"--wait",
],
check=True,
capture_output=True,
Expand Down Expand Up @@ -288,6 +289,7 @@ def test_up_mode_simple(
"up",
"redis",
"-d",
"--wait",
],
check=True,
capture_output=True,
Expand Down Expand Up @@ -426,6 +428,7 @@ def test_up_mutliple_modes(
"up",
"redis",
"-d",
"--wait",
],
check=True,
capture_output=True,
Expand Down Expand Up @@ -553,6 +556,7 @@ def test_up_multiple_modes_overlapping_running_service(
"up",
"clickhouse",
"-d",
"--wait",
],
mock.ANY,
),
Expand Down

0 comments on commit a899549

Please sign in to comment.