diff --git a/integration_tests.py b/integration_tests.py index 981dfe275ed..e22d30ad79b 100755 --- a/integration_tests.py +++ b/integration_tests.py @@ -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, @@ -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() @@ -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: diff --git a/tests/CI/docker-compose.yml b/tests/CI/docker-compose.yml index 16b577ee9b5..c4d344b2cb7 100644 --- a/tests/CI/docker-compose.yml +++ b/tests/CI/docker-compose.yml @@ -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: @@ -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: @@ -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"]