Skip to content

Commit

Permalink
Testing: Update Docker Compose syntax to V2; rucio#6623
Browse files Browse the repository at this point in the history
  • Loading branch information
rdimaio committed Apr 2, 2024
1 parent 1f6fd5b commit 13b42b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
shell: bash
run: |
docker login https://ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
docker-compose -f $GITHUB_WORKSPACE/dev/rucio/etc/docker/dev/docker-compose.yml --profile storage --profile externalmetadata --profile iam pull
docker compose -f $GITHUB_WORKSPACE/dev/rucio/etc/docker/dev/docker-compose.yml --profile storage --profile externalmetadata --profile iam pull
i=0; until [ "$i" -ge 3 ]; do
IMAGES=$(echo '${{ toJson(matrix.cfg) }}' | $GITHUB_WORKSPACE/dev/rucio/tools/test/build_images.py --output list \
--cache-repo ghcr.io/${{ github.repository }} --branch "${{ needs.setup.outputs.branch }}" \
Expand All @@ -119,7 +119,7 @@ jobs:
sed -i 's;image: docker.io/rucio/rucio-dev.*;image: ${{ fromJSON(steps.images.outputs.images)[0] }};' \
$GITHUB_WORKSPACE/dev/rucio/etc/docker/dev/docker-compose.yml
- name: Start containers
run: docker-compose -f $GITHUB_WORKSPACE/dev/rucio/etc/docker/dev/docker-compose.yml --profile storage --profile externalmetadata --profile iam up -d
run: docker compose -f $GITHUB_WORKSPACE/dev/rucio/etc/docker/dev/docker-compose.yml --profile storage --profile externalmetadata --profile iam up -d
- name: Initialize tests
shell: bash
run: |
Expand Down Expand Up @@ -175,4 +175,4 @@ jobs:
- name: Test external metadata plugin (postgres)
run: docker exec -t dev_rucio_1 tools/pytest.sh -v --tb=short tests/test_did_meta_plugins.py::TestDidMetaExternalPostgresJSON
- name: Stop containers
run: docker-compose -f $GITHUB_WORKSPACE/dev/rucio/etc/docker/dev/docker-compose.yml --profile storage --profile externalmetadata --profile iam down
run: docker compose -f $GITHUB_WORKSPACE/dev/rucio/etc/docker/dev/docker-compose.yml --profile storage --profile externalmetadata --profile iam down
18 changes: 7 additions & 11 deletions tools/test/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ def run_with_httpd(
logs_dir: pathlib.Path,
tests: list[str],
) -> bool:
compose_version = int(run('docker-compose', 'version', '--short', return_stdout=True).decode().split('.')[0])

with (NamedTemporaryFile() as compose_override_file):
compose_override_content = yaml.dump({
Expand All @@ -293,7 +292,7 @@ def run_with_httpd(
}
}
})
print("Overriding docker-compose configuration with: \n", compose_override_content, flush=True)
print("Overriding docker compose configuration with: \n", compose_override_content, flush=True)
with open(compose_override_file.name, 'w') as f:
f.write(compose_override_content)

Expand All @@ -307,16 +306,13 @@ def run_with_httpd(
rucio_container = None
try:
# Start docker compose
run('docker-compose', '-p', project, *up_down_args, 'up', '-d')
run('docker', 'compose', '-p', project, *up_down_args, 'up', '-d')

# Retrieve container names from docker compose
# or use pre-defined names for old, v1, docker-compose
rucio_container = f'{project}_rucio_1'
if compose_version > 1:
rucio_container = next(filter(
lambda c: c['Service'] == 'rucio',
json.loads(run('docker-compose', '-p', project, 'ps', '--format', 'json', return_stdout=True))
), {}).get('Name', rucio_container)
rucio_container = next(filter(
lambda c: c['Service'] == 'rucio',
json.loads(run('docker', 'compose', '-p', project, 'ps', '--format', 'json', return_stdout=True))
), {}).get('Name', rucio_container)

# Running test.sh
if tests:
Expand Down Expand Up @@ -355,7 +351,7 @@ def run_with_httpd(
file=sys.stderr,
flush=True,
)
run('docker-compose', '-p', project, *up_down_args, 'down', '-t', '30', check=False)
run('docker', 'compose', '-p', project, *up_down_args, 'down', '-t', '30', check=False)
return False


Expand Down

0 comments on commit 13b42b3

Please sign in to comment.