From 0f332e7b0b6245ab812558009103038cf4212dbf Mon Sep 17 00:00:00 2001 From: Phillip Jensen Date: Mon, 23 Oct 2023 11:14:44 +0200 Subject: [PATCH 1/9] test: retry compose down before erroring out --- tests/docker/manageDocker.sh | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/docker/manageDocker.sh diff --git a/tests/docker/manageDocker.sh b/tests/docker/manageDocker.sh new file mode 100644 index 000000000..8f64c3d76 --- /dev/null +++ b/tests/docker/manageDocker.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# 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 From a245d7f49ca1bd208cc9489be199e8f2b309929f Mon Sep 17 00:00:00 2001 From: Phillip Jensen Date: Mon, 23 Oct 2023 11:16:58 +0200 Subject: [PATCH 2/9] test: use new script to manage docker on action run --- .github/workflows/cypress-nightly.yml | 2 +- .github/workflows/examples-nightly.yml | 2 +- .github/workflows/goth-nightly.yml | 2 +- .github/workflows/release.yml | 2 +- tests/docker/Requestor.Dockerfile | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cypress-nightly.yml b/.github/workflows/cypress-nightly.yml index ca7253bf4..6cf4b4440 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: docker compose -f tests/docker/docker-compose.yml down && docker compose -f tests/docker/docker-compose.yml up -d + run: /manageDocker.sh - 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 a5daacefd..ad7612ae8 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: docker compose -f tests/docker/docker-compose.yml down && docker compose -f tests/docker/docker-compose.yml up -d + run: /manageDocker.sh - 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 ca10cb93d..4e583f6bb 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: docker compose -f tests/docker/docker-compose.yml down && docker compose -f tests/docker/docker-compose.yml up -d + run: /manageDocker.sh - 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 ef1b52405..d1a73088b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,7 +63,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: docker compose -f tests/docker/docker-compose.yml down && docker compose -f tests/docker/docker-compose.yml up -d + run: /manageDocker.sh - 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/Requestor.Dockerfile b/tests/docker/Requestor.Dockerfile index b64167fdd..2b56c5f76 100644 --- a/tests/docker/Requestor.Dockerfile +++ b/tests/docker/Requestor.Dockerfile @@ -40,5 +40,6 @@ RUN apt-get update -q \ COPY ./startRequestor.sh /startRequestor.sh +COPY ./manageDocker.sh /manageDocker.sh CMD ["bash", "-c", "/startRequestor.sh"] From 13e3eb1dca86f9ae7653945bd7ff5ce35873483f Mon Sep 17 00:00:00 2001 From: Phillip Jensen Date: Mon, 23 Oct 2023 11:30:46 +0200 Subject: [PATCH 3/9] test: use correct file path --- .github/workflows/cypress-nightly.yml | 2 +- .github/workflows/examples-nightly.yml | 2 +- .github/workflows/goth-nightly.yml | 2 +- .github/workflows/release.yml | 2 +- tests/docker/Requestor.Dockerfile | 1 - tests/docker/{manageDocker.sh => startDocker.sh} | 0 6 files changed, 4 insertions(+), 5 deletions(-) rename tests/docker/{manageDocker.sh => startDocker.sh} (100%) mode change 100644 => 100755 diff --git a/.github/workflows/cypress-nightly.yml b/.github/workflows/cypress-nightly.yml index 6cf4b4440..f8e07d128 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: /manageDocker.sh + run: tests/docker/startDocker.sh - 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 ad7612ae8..0b4fd7de3 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: /manageDocker.sh + run: tests/docker/startDocker.sh - 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 4e583f6bb..fcbc66d25 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: /manageDocker.sh + run: tests/docker/startDocker.sh - 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 d1a73088b..9ac91d286 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,7 +63,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: /manageDocker.sh + run: tests/docker/startDocker.sh - 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/Requestor.Dockerfile b/tests/docker/Requestor.Dockerfile index 2b56c5f76..b64167fdd 100644 --- a/tests/docker/Requestor.Dockerfile +++ b/tests/docker/Requestor.Dockerfile @@ -40,6 +40,5 @@ RUN apt-get update -q \ COPY ./startRequestor.sh /startRequestor.sh -COPY ./manageDocker.sh /manageDocker.sh CMD ["bash", "-c", "/startRequestor.sh"] diff --git a/tests/docker/manageDocker.sh b/tests/docker/startDocker.sh old mode 100644 new mode 100755 similarity index 100% rename from tests/docker/manageDocker.sh rename to tests/docker/startDocker.sh From a014c73c48108a5c89d1e0d78277403c8e6d0454 Mon Sep 17 00:00:00 2001 From: Phillip Jensen Date: Mon, 23 Oct 2023 11:32:51 +0200 Subject: [PATCH 4/9] test: fix command --- tests/docker/startDocker.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/docker/startDocker.sh b/tests/docker/startDocker.sh index 8f64c3d76..ca5df56e3 100755 --- a/tests/docker/startDocker.sh +++ b/tests/docker/startDocker.sh @@ -11,16 +11,16 @@ compose_file="tests/docker/docker-compose.yml" # Function to bring up the services start_services() { - docker-compose -f $compose_file up -d + docker compose -f $compose_file up -d } -# Loop to attempt 'docker-compose down' with retries +# 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 + docker compose -f $compose_file down # Check if the command succeeded if [ $? -eq 0 ]; then From 44d2be60246f31e23382f938d440cbe81e8a45eb Mon Sep 17 00:00:00 2001 From: Phillip Jensen Date: Mon, 23 Oct 2023 11:36:09 +0200 Subject: [PATCH 5/9] test: restart docker service --- tests/docker/startDocker.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/docker/startDocker.sh b/tests/docker/startDocker.sh index ca5df56e3..b5f5a24fd 100755 --- a/tests/docker/startDocker.sh +++ b/tests/docker/startDocker.sh @@ -1,5 +1,7 @@ #!/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 From cee329a29ef9418c379b3ad5f56fc06b8c4cdf9a Mon Sep 17 00:00:00 2001 From: Phillip Jensen Date: Tue, 24 Oct 2023 08:23:32 +0200 Subject: [PATCH 6/9] 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 From c6d7989522c7ca530af573513e34c7f12b29b48e Mon Sep 17 00:00:00 2001 From: Phillip Jensen Date: Tue, 24 Oct 2023 09:32:17 +0200 Subject: [PATCH 7/9] test(example): reduce custom price array length check --- .../examples/selecting-providers/custom-price.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/docs-examples/examples/selecting-providers/custom-price.mjs b/examples/docs-examples/examples/selecting-providers/custom-price.mjs index d4a604006..411bbaa84 100644 --- a/examples/docs-examples/examples/selecting-providers/custom-price.mjs +++ b/examples/docs-examples/examples/selecting-providers/custom-price.mjs @@ -12,10 +12,10 @@ const myFilter = async (proposal) => { let counterIdx = usageVector.findIndex((ele) => ele === "golem.usage.duration_sec"); let proposedCost = proposal.properties["golem.com.pricing.model.linear.coeffs"][counterIdx]; costData.push(proposedCost); - if (costData.length < 11) return false; + if (costData.length < 6) return false; else { costData.shift(); - let averageProposedCost = costData.reduce((part, x) => part + x, 0) / 10; + let averageProposedCost = costData.reduce((part, x) => part + x, 0) / 5; if (proposedCost <= 1.2 * averageProposedCost) decision = true; if (decision) { console.log(proposedCost, averageProposedCost); From 458423cb8654e75e20b198b5f4a9d41bc1e7f6d0 Mon Sep 17 00:00:00 2001 From: Phillip Jensen Date: Tue, 24 Oct 2023 10:18:57 +0200 Subject: [PATCH 8/9] test: update comments --- .github/workflows/cypress-nightly.yml | 4 ++-- .github/workflows/examples-nightly.yml | 4 ++-- .github/workflows/goth-nightly.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cypress-nightly.yml b/.github/workflows/cypress-nightly.yml index 9cfdee853..65f60f231 100644 --- a/.github/workflows/cypress-nightly.yml +++ b/.github/workflows/cypress-nightly.yml @@ -16,14 +16,14 @@ 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 + # 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 diff --git a/.github/workflows/examples-nightly.yml b/.github/workflows/examples-nightly.yml index 7d2f311d9..9ddb33568 100644 --- a/.github/workflows/examples-nightly.yml +++ b/.github/workflows/examples-nightly.yml @@ -32,14 +32,14 @@ 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 + # 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 diff --git a/.github/workflows/goth-nightly.yml b/.github/workflows/goth-nightly.yml index 34f9aeeca..f6c4cd505 100644 --- a/.github/workflows/goth-nightly.yml +++ b/.github/workflows/goth-nightly.yml @@ -32,14 +32,14 @@ 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 + # 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 From fc8d871554e92c6a3747694904a170bb315b9d58 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 08:26:06 +0000 Subject: [PATCH 9/9] build(deps-dev): bump @commitlint/config-conventional Bumps [@commitlint/config-conventional](https://github.com/conventional-changelog/commitlint/tree/HEAD/@commitlint/config-conventional) from 17.8.1 to 18.1.0. - [Release notes](https://github.com/conventional-changelog/commitlint/releases) - [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/@commitlint/config-conventional/CHANGELOG.md) - [Commits](https://github.com/conventional-changelog/commitlint/commits/v18.1.0/@commitlint/config-conventional) --- updated-dependencies: - dependency-name: "@commitlint/config-conventional" dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2733d5b46..8f5d57ed1 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ }, "devDependencies": { "@commitlint/cli": "^17.7.1", - "@commitlint/config-conventional": "^17.7.0", + "@commitlint/config-conventional": "^18.1.0", "@johanblumenberg/ts-mockito": "^1.0.39", "@rollup/plugin-alias": "^5.0.0", "@rollup/plugin-commonjs": "^25.0.3",