Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen committed Sep 1, 2023
1 parent 8813b1a commit a645bdf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 46 deletions.
21 changes: 12 additions & 9 deletions integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,18 @@ def prepare_environment(
)
subprocess.run(command, check=True, shell=True)

docker_compose_fn_final = Path(tempfile.mkdtemp()) / "ci"
typer.secho("Running docker-compose to create DiracX containers", fg=c.GREEN)
docker_compose_fn_final = Path("/tmp/final-dirac-compose/ci/")
typer.secho(f"Will eave a folder behind: {docker_compose_fn_final}", fg=c.YELLOW)

with _gen_docker_compose(modules) 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.
shutil.copytree(docker_compose_fn.parent, docker_compose_fn_final, dirs_exist_ok=True)
# We use Popen because we don't want to wait for this command to finish.
# It is going to start all the diracx containers, including one which waits
# for the DIRAC installation to be over.
subprocess.Popen(
["docker-compose", "-f", docker_compose_fn_final / "docker-compose.yml", "up", "-d", "diracx"],
env=docker_compose_env,
Expand All @@ -327,11 +335,6 @@ def prepare_environment(
stderr=None,
close_fds=True,
)
# subprocess.run(
# ["docker-compose", "-f", docker_compose_fn_final/"docker-compose.yml", "up", "-d", "diracx"],
# check=True,
# env=docker_compose_env,
# )


@app.command()
Expand Down Expand Up @@ -537,15 +540,15 @@ def _gen_docker_compose(modules):
# 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())
# dirac-init-db needs the volume to be able to run the witing script
for ctn in ("dirac-server", "dirac-client", "dirac-init-db"):
# diracx-wait-for-db needs the volume to be able to run the witing script
for ctn in ("dirac-server", "dirac-client", "diracx-wait-for-db"):
if "volumes" not in docker_compose["services"][ctn]:
docker_compose["services"][ctn]["volumes"] = []
volumes = [f"{path}:/home/dirac/LocalRepo/ALTERNATIVE_MODULES/{name}" for name, path in modules.items()]
volumes += [f"{path}:/home/dirac/LocalRepo/TestCode/{name}" for name, path in modules.items()]
docker_compose["services"]["dirac-server"]["volumes"].extend(volumes[:])
docker_compose["services"]["dirac-client"]["volumes"].extend(volumes[:])
docker_compose["services"]["dirac-init-db"]["volumes"].extend(volumes[:])
docker_compose["services"]["diracx-wait-for-db"]["volumes"].extend(volumes[:])

module_configs = _load_module_configs(modules)
if "diracx" in module_configs:
Expand Down
45 changes: 8 additions & 37 deletions tests/CI/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,35 +61,15 @@ services:
- debug=true


dirac-init-db:
diracx-wait-for-db:

image: ${MYSQL_VER}
container_name: dirac-init-db
container_name: diracx-wait-for-db
depends_on:
mysql:
condition: service_healthy
command: /home/dirac/LocalRepo/ALTERNATIVE_MODULES/DIRAC/tests/CI/check_db_initialized.sh
# command: >
# bash -c "dbMissing=true;
# while ${dbMissing};
# do
# dbMissing=false;
# allExistingDBs=$(mycli -uDirac --p123 -h 456 -P 5506 -e "show databases;");
# for db in "${allDBs[@]}";
# do
# if grep -q "${db}" <<< "${allExistingDBs}";
# then
# echo "${db} OK";
# else
# echo "${db} not created";
# dbMissing=true;
# fi;
# done;
# if ${dbMissing};
# then
# sleep 1;
# fi
# done
# """



dirac-server:
Expand Down Expand Up @@ -132,21 +112,19 @@ services:





diracx-init-key:
#image: gitlab-registry.cern.ch/chaen/chrissquare-hack-a-ton/diracx
image: ghcr.io/diracgrid/diracx/server
container_name: diracx-init-key
environment:
- DIRACX_SERVICE_AUTH_TOKEN_KEY="file:///signing-key/rs256.key"
volumes:
- diracx-key-store:/signing-key/
# We need to allow everybody to read the private keys
# Because the users are different between the DIRAC and DiracX containers
entrypoint: |
/dockerMicroMambaEntrypoint.sh bash -c "ssh-keygen -P '' -trsa -b4096 -mPEM -f/signing-key/rs256.key && /dockerMicroMambaEntrypoint.sh chmod o+r /signing-key/rs256.*"
diracx-init-cs:
# image: gitlab-registry.cern.ch/chaen/chrissquare-hack-a-ton/diracx
image: ghcr.io/diracgrid/diracx/server
container_name: diracx-init-cs
environment:
Expand All @@ -159,29 +137,22 @@ services:
/dockerMicroMambaEntrypoint.sh dirac internal generate-cs /cs_store/initialRepo --vo=diracAdmin --user-group=admin --idp-url=http://dsdsd.csds/a/b
diracx:
# image: gitlab-registry.cern.ch/chaen/chrissquare-hack-a-ton/diracx
image: ghcr.io/diracgrid/diracx/server
container_name: diracx
environment:
- DIRACX_CONFIG_BACKEND_URL=git+file:///cs_store/initialRepo
- "DIRACX_DB_URL_AUTHDB=sqlite+aiosqlite:///:memory:"
- DIRACX_DB_URL_JOBDB=mysql+aiomysql://Dirac:Dirac@mysql/JobDB
#- "DIRACX_DB_URL_JOBDB=sqlite+aiosqlite:///:memory:"
- DIRACX_SERVICE_AUTH_TOKEN_KEY=file:///signing-key/rs256.key
- DIRACX_SERVICE_AUTH_ALLOWED_REDIRECTS=["http://diracx:8000/docs/oauth2-redirect"]
ports:
- 8000:8000
depends_on:
dirac-init-db:
condition: service_completed_successfully # Let the init container create the cs
# diracx-init-cs:
# condition: service_completed_successfully # Let the init container create the cs
# diracx-init-key:
# condition: service_completed_successfully # Let the init container create the cs
diracx-wait-for-db:
condition: service_completed_successfully
volumes:
- diracx-cs-store:/cs_store/
- diracx-key-store:/signing-key/
# - /home/chaen/dirac/diracx-project/diracx/src/diracx/:/opt/conda/lib/python3.11/site-packages/diracx

healthcheck:
test: ["CMD", "/dockerMicroMambaEntrypoint.sh", "curl", "-f", "http://localhost:8000/.well-known/openid-configuration"]
Expand Down

0 comments on commit a645bdf

Please sign in to comment.