Skip to content

Commit

Permalink
asdsa
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisburr committed Nov 27, 2023
1 parent 02cffbc commit b57c719
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,13 @@ def create(
flags: Optional[list[str]] = typer.Argument(None),
editable: Optional[bool] = None,
extra_module: Optional[list[str]] = None,
diracx_dist_dir: Optional[str] = None,
release_var: Optional[str] = None,
run_server_tests: bool = True,
run_client_tests: bool = True,
):
"""Start a local instance of the integration tests"""
prepare_environment(flags, editable, extra_module, release_var)
prepare_environment(flags, editable, extra_module, diracx_dist_dir, release_var)
install_server()
install_client()
exit_code = 0
Expand Down Expand Up @@ -191,6 +192,7 @@ def prepare_environment(
flags: Optional[list[str]] = typer.Argument(None),
editable: Optional[bool] = None,
extra_module: Optional[list[str]] = None,
diracx_dist_dir: Optional[str] = None,
release_var: Optional[str] = None,
):
"""Prepare the local environment for installing DIRAC."""
Expand Down Expand Up @@ -227,7 +229,7 @@ def prepare_environment(
extra_services = list(chain(*[config["extra-services"] for config in module_configs.values()]))

typer.secho("Running docker-compose to create containers", fg=c.GREEN)
with _gen_docker_compose(modules) as docker_compose_fn:
with _gen_docker_compose(modules, diracx_dist_dir=diracx_dist_dir) as docker_compose_fn:
subprocess.run(
["docker-compose", "-f", docker_compose_fn, "up", "-d", "dirac-server", "dirac-client"] + extra_services,
check=True,
Expand Down Expand Up @@ -322,7 +324,7 @@ def prepare_environment(
typer.secho("Running docker-compose to create DiracX containers", fg=c.GREEN)
typer.secho(f"Will leave a folder behind: {docker_compose_fn_final}", fg=c.YELLOW)

with _gen_docker_compose(modules) as docker_compose_fn:
with _gen_docker_compose(modules, diracx_dist_dir=diracx_dist_dir) as docker_compose_fn:
# We cannot use the temporary directory created in the context manager because
# we don't stay in the contect manager (Popen)
# So we need something that outlives it.
Expand Down Expand Up @@ -545,7 +547,7 @@ class TestExit(typer.Exit):


@contextmanager
def _gen_docker_compose(modules):
def _gen_docker_compose(modules, *, diracx_dist_dir=None):
# Load the docker-compose configuration and mount the necessary volumes
input_fn = Path(__file__).parent / "tests/CI/docker-compose.yml"
docker_compose = yaml.safe_load(input_fn.read_text())
Expand All @@ -560,21 +562,12 @@ def _gen_docker_compose(modules):
docker_compose["services"]["diracx-wait-for-db"]["volumes"].extend(volumes[:])

module_configs = _load_module_configs(modules)
if "diracx" in module_configs:
docker_compose["services"]["diracx"]["volumes"].append(f"{modules['diracx']}:/diracx")
docker_compose["services"]["diracx"]["tmpfs"] = [
"/diracx/diracx-core/src/diracx_core.egg-info",
"/diracx/diracx-core/build",
"/diracx/diracx-db/src/diracx_db.egg-info",
"/diracx/diracx-db/build",
"/diracx/diracx-routers/src/diracx_routers.egg-info",
"/diracx/diracx-routers/build",
]
entrypoint = docker_compose["services"]["diracx"]["entrypoint"]
docker_compose["services"]["diracx"]["entrypoint"] = entrypoint.replace(
"uvicorn",
"pip install /diracx/diracx-core /diracx/diracx-db /diracx/diracx-routers && uvicorn",
)
if diracx_dist_dir is not None:
for container_name in ["diracx-init-cs", "diracx-wait-for-db", "diracx"]:
docker_compose["services"][container_name]["volumes"].append(f"{diracx_dist_dir}:/diracx_sources")
docker_compose["services"][container_name]["environment"][
"DIRACX_CUSTOM_SOURCE_PREFIXES"
] = "/diracx_sources"

# Add any extension services
for module_name, module_configs in module_configs.items():
Expand Down

0 comments on commit b57c719

Please sign in to comment.