From cee329a29ef9418c379b3ad5f56fc06b8c4cdf9a Mon Sep 17 00:00:00 2001 From: Phillip Jensen Date: Tue, 24 Oct 2023 08:23:32 +0200 Subject: [PATCH] test: scratch script and just restart docker --- .github/workflows/cypress-nightly.yml | 2 +- .github/workflows/examples-nightly.yml | 2 +- .github/workflows/goth-nightly.yml | 2 +- .github/workflows/release.yml | 6 ++-- tests/docker/startDocker.sh | 47 -------------------------- 5 files changed, 6 insertions(+), 53 deletions(-) delete mode 100755 tests/docker/startDocker.sh diff --git a/.github/workflows/cypress-nightly.yml b/.github/workflows/cypress-nightly.yml index f8e07d128..9cfdee853 100644 --- a/.github/workflows/cypress-nightly.yml +++ b/.github/workflows/cypress-nightly.yml @@ -24,7 +24,7 @@ jobs: - name: Start the docker containers # Use a random string to avoid other providers on the same subnet which might cause tests to fail because it expects only providers named provider-1 and provider-2 - run: tests/docker/startDocker.sh + run: sudo service docker restart && docker compose -f tests/docker/docker-compose.yml down && docker compose -f tests/docker/docker-compose.yml up -d - name: Fund the requestor # Use a funding script which will retry funding the requestor 3 times, else it exits with error. The faucet is not reliable and sometimes fails to fund the requestor, thus the retry. diff --git a/.github/workflows/examples-nightly.yml b/.github/workflows/examples-nightly.yml index 0b4fd7de3..7d2f311d9 100644 --- a/.github/workflows/examples-nightly.yml +++ b/.github/workflows/examples-nightly.yml @@ -40,7 +40,7 @@ jobs: - name: Start the docker containers # Use a random string to avoid other providers on the same subnet which might cause tests to fail because it expects only providers named provider-1 and provider-2 - run: tests/docker/startDocker.sh + run: sudo service docker restart && docker compose -f tests/docker/docker-compose.yml down && docker compose -f tests/docker/docker-compose.yml up -d - name: Fund the requestor # Use a funding script which will retry funding the requestor 3 times, else it exits with error. The faucet is not reliable and sometimes fails to fund the requestor, thus the retry. diff --git a/.github/workflows/goth-nightly.yml b/.github/workflows/goth-nightly.yml index fcbc66d25..34f9aeeca 100644 --- a/.github/workflows/goth-nightly.yml +++ b/.github/workflows/goth-nightly.yml @@ -40,7 +40,7 @@ jobs: - name: Start the docker containers # Use a random string to avoid other providers on the same subnet which might cause tests to fail because it expects only providers named provider-1 and provider-2 - run: tests/docker/startDocker.sh + run: sudo service docker restart && docker compose -f tests/docker/docker-compose.yml down && docker compose -f tests/docker/docker-compose.yml up -d - name: Fund the requestor # Use a funding script which will retry funding the requestor 3 times, else it exits with error. The faucet is not reliable and sometimes fails to fund the requestor, thus the retry. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9ac91d286..3c2d26a74 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,15 +55,15 @@ jobs: uses: actions/checkout@v3 - name: Use random string for subnet + # Use a random string to avoid other providers on the same subnet which might cause tests to fail because it expects only providers named provider-1 and provider-2 run: echo "YAGNA_SUBNET=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8 ; echo '')" >> $GITHUB_ENV - name: Build the docker containers - # Use a random string to avoid other providers on the same subnet which might cause tests to fail because it expects only providers named provider-1 and provider-2 run: docker compose -f tests/docker/docker-compose.yml build - name: Start the docker containers - # Use a random string to avoid other providers on the same subnet which might cause tests to fail because it expects only providers named provider-1 and provider-2 - run: tests/docker/startDocker.sh + # Restart docker to avoid issues with the docker compose down due to improper cleanup of the previous run. + run: sudo service docker restart && docker compose -f tests/docker/docker-compose.yml down && docker compose -f tests/docker/docker-compose.yml up -d - name: Fund the requestor # Use a funding script which will retry funding the requestor 3 times, else it exits with error. The faucet is not reliable and sometimes fails to fund the requestor, thus the retry. diff --git a/tests/docker/startDocker.sh b/tests/docker/startDocker.sh deleted file mode 100755 index b5f5a24fd..000000000 --- a/tests/docker/startDocker.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -# Restart docker first as it may be in a bad state. -sudo service docker restart -# Maximum number of attempts to bring down the Docker Compose -max_attempts=5 - -# Counter for the number of attempts -attempt=0 - -# Path to your docker-compose file -compose_file="tests/docker/docker-compose.yml" - -# Function to bring up the services -start_services() { - docker compose -f $compose_file up -d -} - -# Loop to attempt 'docker compose down' with retries -while [ $attempt -lt $max_attempts ]; do - # Increment the attempt counter - ((attempt=attempt+1)) - - # Try to bring down the services - docker compose -f $compose_file down - - # Check if the command succeeded - if [ $? -eq 0 ]; then - echo "Successfully brought down the services." - # If successful, break out of the loop - break - else - echo "Attempt $attempt failed..." - # If max attempts reached, show error and exit - if [ $attempt -eq $max_attempts ]; then - echo "Failed to bring down the services after $max_attempts attempts." - exit 1 - fi - # If not, wait for a bit before retrying - echo "Retrying in 5 seconds..." - sleep 5 - fi -done - -# If we reached here, it means we successfully brought the services down. -# So we start them up again. -start_services