From fbde1448807a1ba9e8fe081e669348aac5dcf8f2 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Mon, 1 Apr 2024 13:52:32 +0530 Subject: [PATCH 01/10] Run registry CLI tests as part of laconicd fixturenet test workflow --- .gitea/workflows/fixturenet-laconicd-test.yml | 3 + .../docker-compose-fixturenet-laconicd.yml | 3 + .../cerc-laconic-registry-cli/Dockerfile | 4 ++ tests/fixturenet-laconicd/run-cli-test.sh | 55 +++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100755 tests/fixturenet-laconicd/run-cli-test.sh diff --git a/.gitea/workflows/fixturenet-laconicd-test.yml b/.gitea/workflows/fixturenet-laconicd-test.yml index 67f3797e..6df5e45b 100644 --- a/.gitea/workflows/fixturenet-laconicd-test.yml +++ b/.gitea/workflows/fixturenet-laconicd-test.yml @@ -46,3 +46,6 @@ jobs: run: ./scripts/build_shiv_package.sh - name: "Run fixturenet-laconicd tests" run: ./tests/fixturenet-laconicd/run-test.sh + # TODO: Separate out in a job + - name: "Run laconic CLI tests" + run: ./tests/fixturenet-laconicd/run-cli-test.sh diff --git a/stack_orchestrator/data/compose/docker-compose-fixturenet-laconicd.yml b/stack_orchestrator/data/compose/docker-compose-fixturenet-laconicd.yml index 7b48f60d..f3025062 100644 --- a/stack_orchestrator/data/compose/docker-compose-fixturenet-laconicd.yml +++ b/stack_orchestrator/data/compose/docker-compose-fixturenet-laconicd.yml @@ -3,6 +3,9 @@ services: restart: unless-stopped image: cerc/laconicd:local command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"] + environment: + TEST_AUCTION_ENABLED: ${TEST_AUCTION_ENABLED} + TEST_REGISTRY_EXPIRY: ${TEST_REGISTRY_EXPIRY} volumes: # The cosmos-sdk node's database directory: - laconicd-data:/root/.laconicd diff --git a/stack_orchestrator/data/container-build/cerc-laconic-registry-cli/Dockerfile b/stack_orchestrator/data/container-build/cerc-laconic-registry-cli/Dockerfile index 8ff8ab7e..94d2d7e3 100644 --- a/stack_orchestrator/data/container-build/cerc-laconic-registry-cli/Dockerfile +++ b/stack_orchestrator/data/container-build/cerc-laconic-registry-cli/Dockerfile @@ -52,6 +52,10 @@ RUN npm config set @cerc-io:registry ${CERC_NPM_REGISTRY_URL} \ # Globally install the cli package RUN yarn global add @cerc-io/laconic-registry-cli +# Clone the repo for running CLI tests inside the container +RUN git clone https://git.vdb.to/cerc-io/laconic-registry-cli.git \ + && cd laconic-registry-cli && yarn + # Add scripts RUN mkdir /scripts RUN mkdir /scripts/demo-records diff --git a/tests/fixturenet-laconicd/run-cli-test.sh b/tests/fixturenet-laconicd/run-cli-test.sh new file mode 100755 index 00000000..79275cde --- /dev/null +++ b/tests/fixturenet-laconicd/run-cli-test.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +set -e +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi + +echo "$(date +"%Y-%m-%d %T"): Running stack-orchestrator Laconicd fixturenet test" +env +cat /etc/hosts +# Bit of a hack, test the most recent package +TEST_TARGET_SO=$( ls -t1 ./package/laconic-so* | head -1 ) + +echo "$(date +"%Y-%m-%d %T"): Starting stack" +TEST_AUCTION_ENABLED=true $TEST_TARGET_SO --stack fixturenet-laconicd deploy --cluster laconicd up +echo "$(date +"%Y-%m-%d %T"): Stack started" + +# Verify that the fixturenet is up and running +$TEST_TARGET_SO --stack fixturenet-laconicd deploy --cluster laconicd ps + +# Get the key from laconicd +laconicd_key=$(docker exec laconicd-laconicd-1 sh -c 'yes | laconicd keys export mykey --unarmored-hex --unsafe') + +# Get the fixturenet account address +laconicd_account_address=$(docker exec laconicd-laconicd-1 laconicd keys list | awk '/- address:/ {print $3}') + +# Set parameters for the test suite +cosmos_chain_id=laconic_9000-1 +laconicd_rest_endpoint=http://laconicd:1317 +laconicd_gql_endpoint=http://laconicd:9473/api + +# Create the required config and copy it over inside the container +config_file="config.yml" +config=$(cat < "$config_file" + +docker cp $config_file laconicd-cli-1:laconic-registry-cli/config.yml + +# Run the tests +docker exec -it -e TEST_ACCOUNT=$laconicd_account_address laconicd-cli-1 sh -c 'cd laconic-registry-cli && yarn test' + +# Clean up +$TEST_TARGET_SO --stack fixturenet-laconicd deploy --cluster laconicd down --delete-volumes +echo "$(date +"%Y-%m-%d %T"): Test finished" -- 2.45.2 From e8cacd899a60bdd3a0e9f2705e54d77ff178173e Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Mon, 1 Apr 2024 20:10:29 +0530 Subject: [PATCH 02/10] Use existing config in the CLI container --- tests/fixturenet-laconicd/run-cli-test.sh | 28 ++++------------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/tests/fixturenet-laconicd/run-cli-test.sh b/tests/fixturenet-laconicd/run-cli-test.sh index 79275cde..408ad79b 100755 --- a/tests/fixturenet-laconicd/run-cli-test.sh +++ b/tests/fixturenet-laconicd/run-cli-test.sh @@ -18,34 +18,14 @@ echo "$(date +"%Y-%m-%d %T"): Stack started" # Verify that the fixturenet is up and running $TEST_TARGET_SO --stack fixturenet-laconicd deploy --cluster laconicd ps -# Get the key from laconicd -laconicd_key=$(docker exec laconicd-laconicd-1 sh -c 'yes | laconicd keys export mykey --unarmored-hex --unsafe') - # Get the fixturenet account address laconicd_account_address=$(docker exec laconicd-laconicd-1 laconicd keys list | awk '/- address:/ {print $3}') -# Set parameters for the test suite -cosmos_chain_id=laconic_9000-1 -laconicd_rest_endpoint=http://laconicd:1317 -laconicd_gql_endpoint=http://laconicd:9473/api +# Copy over config +docker exec -it laconicd-cli-1 cp config.yml laconic-registry-cli/ -# Create the required config and copy it over inside the container -config_file="config.yml" -config=$(cat < "$config_file" - -docker cp $config_file laconicd-cli-1:laconic-registry-cli/config.yml +# Wait for the laconid endpoint to come up +docker exec laconicd-laconicd-1 sh -c "curl --retry 10 --retry-delay 3 --retry-connrefused http://127.0.0.1:9473/api" # Run the tests docker exec -it -e TEST_ACCOUNT=$laconicd_account_address laconicd-cli-1 sh -c 'cd laconic-registry-cli && yarn test' -- 2.45.2 From 0b53e24781b85dc8b417af61316e5ca800da36a6 Mon Sep 17 00:00:00 2001 From: neeraj Date: Tue, 2 Apr 2024 09:51:19 +0530 Subject: [PATCH 03/10] Update fixturenet laconicd test workflow --- .gitea/workflows/fixturenet-laconicd-test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitea/workflows/fixturenet-laconicd-test.yml b/.gitea/workflows/fixturenet-laconicd-test.yml index 6df5e45b..c8c3991e 100644 --- a/.gitea/workflows/fixturenet-laconicd-test.yml +++ b/.gitea/workflows/fixturenet-laconicd-test.yml @@ -11,7 +11,7 @@ on: jobs: test: - name: "Run an Laconicd fixturenet test" + name: "Run Laconicd fixturenet and Laconic CLI tests" runs-on: ubuntu-latest steps: - name: 'Update' @@ -46,6 +46,5 @@ jobs: run: ./scripts/build_shiv_package.sh - name: "Run fixturenet-laconicd tests" run: ./tests/fixturenet-laconicd/run-test.sh - # TODO: Separate out in a job - name: "Run laconic CLI tests" run: ./tests/fixturenet-laconicd/run-cli-test.sh -- 2.45.2 From 2ba72d180fd1799f625f7558f0e76b1a9bb1ab4e Mon Sep 17 00:00:00 2001 From: neeraj Date: Tue, 2 Apr 2024 09:53:19 +0530 Subject: [PATCH 04/10] Run fixturenet laconicd test workflow on pull request --- .gitea/workflows/fixturenet-laconicd-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitea/workflows/fixturenet-laconicd-test.yml b/.gitea/workflows/fixturenet-laconicd-test.yml index c8c3991e..faf9c878 100644 --- a/.gitea/workflows/fixturenet-laconicd-test.yml +++ b/.gitea/workflows/fixturenet-laconicd-test.yml @@ -1,6 +1,8 @@ name: Fixturenet-Laconicd-Test on: + pull_request: + branches: '*' push: branches: '*' paths: -- 2.45.2 From 1e34e7d26d18eea81a007ee44fcef6261dc13c08 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 2 Apr 2024 11:13:35 +0530 Subject: [PATCH 05/10] Remove tty flag from docker commands --- tests/fixturenet-laconicd/run-cli-test.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/fixturenet-laconicd/run-cli-test.sh b/tests/fixturenet-laconicd/run-cli-test.sh index 408ad79b..0ff01de9 100755 --- a/tests/fixturenet-laconicd/run-cli-test.sh +++ b/tests/fixturenet-laconicd/run-cli-test.sh @@ -5,7 +5,7 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then set -x fi -echo "$(date +"%Y-%m-%d %T"): Running stack-orchestrator Laconicd fixturenet test" +echo "$(date +"%Y-%m-%d %T"): Running stack-orchestrator Laconic registry CLI tests" env cat /etc/hosts # Bit of a hack, test the most recent package @@ -22,13 +22,15 @@ $TEST_TARGET_SO --stack fixturenet-laconicd deploy --cluster laconicd ps laconicd_account_address=$(docker exec laconicd-laconicd-1 laconicd keys list | awk '/- address:/ {print $3}') # Copy over config -docker exec -it laconicd-cli-1 cp config.yml laconic-registry-cli/ +docker exec laconicd-cli-1 cp config.yml laconic-registry-cli/ # Wait for the laconid endpoint to come up +echo "Waiting for the RPC endpoint to come up" docker exec laconicd-laconicd-1 sh -c "curl --retry 10 --retry-delay 3 --retry-connrefused http://127.0.0.1:9473/api" # Run the tests -docker exec -it -e TEST_ACCOUNT=$laconicd_account_address laconicd-cli-1 sh -c 'cd laconic-registry-cli && yarn test' +echo "Running the tests" +docker exec -e TEST_ACCOUNT=$laconicd_account_address laconicd-cli-1 sh -c 'cd laconic-registry-cli && yarn test' # Clean up $TEST_TARGET_SO --stack fixturenet-laconicd deploy --cluster laconicd down --delete-volumes -- 2.45.2 From 3d5e3363e0d01f24b4340ff96fd6f48eb95725e3 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 2 Apr 2024 11:38:56 +0530 Subject: [PATCH 06/10] Revert "Run fixturenet laconicd test workflow on pull request" This reverts commit 2ba72d180fd1799f625f7558f0e76b1a9bb1ab4e. --- .gitea/workflows/fixturenet-laconicd-test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitea/workflows/fixturenet-laconicd-test.yml b/.gitea/workflows/fixturenet-laconicd-test.yml index faf9c878..c8c3991e 100644 --- a/.gitea/workflows/fixturenet-laconicd-test.yml +++ b/.gitea/workflows/fixturenet-laconicd-test.yml @@ -1,8 +1,6 @@ name: Fixturenet-Laconicd-Test on: - pull_request: - branches: '*' push: branches: '*' paths: -- 2.45.2 From 95973be5a1329182e12d91fa32b9323b6c306329 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 3 Apr 2024 18:16:01 +0530 Subject: [PATCH 07/10] Trigger fixturenet-laconicd test workflow --- .gitea/workflows/triggers/fixturenet-laconicd-test | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitea/workflows/triggers/fixturenet-laconicd-test b/.gitea/workflows/triggers/fixturenet-laconicd-test index ad09df27..59af2ab6 100644 --- a/.gitea/workflows/triggers/fixturenet-laconicd-test +++ b/.gitea/workflows/triggers/fixturenet-laconicd-test @@ -1,3 +1,4 @@ Change this file to trigger running the fixturenet-laconicd-test CI job Trigger Trigger +Trigger -- 2.45.2 From 71b6868f68fccd67f0e545e8eb87574a4dce3de2 Mon Sep 17 00:00:00 2001 From: neeraj Date: Wed, 3 Apr 2024 18:30:25 +0530 Subject: [PATCH 08/10] Add flag to retry if connection is refused --- tests/webapp-test/run-webapp-test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/webapp-test/run-webapp-test.sh b/tests/webapp-test/run-webapp-test.sh index 8cae4828..d93d0d6d 100755 --- a/tests/webapp-test/run-webapp-test.sh +++ b/tests/webapp-test/run-webapp-test.sh @@ -32,14 +32,14 @@ set +e CONTAINER_ID=$(docker run -p 3000:80 -d -e CERC_SCRIPT_DEBUG=$CERC_SCRIPT_DEBUG cerc/test-progressive-web-app:local) sleep 3 -wget -t 7 -O test.before -m http://localhost:3000 +wget --tries 7 --retry-connrefused -O test.before -m http://localhost:3000 docker logs $CONTAINER_ID docker remove -f $CONTAINER_ID CONTAINER_ID=$(docker run -p 3000:80 -e CERC_WEBAPP_DEBUG=$CHECK -e CERC_SCRIPT_DEBUG=$CERC_SCRIPT_DEBUG -d cerc/test-progressive-web-app:local) sleep 3 -wget -t 7 -O test.after -m http://localhost:3000 +wget --tries 7 --retry-connrefused -O test.after -m http://localhost:3000 docker logs $CONTAINER_ID docker remove -f $CONTAINER_ID -- 2.45.2 From f2f9d5749aff9e4e317cc920a4182ad34a8f7532 Mon Sep 17 00:00:00 2001 From: neeraj Date: Thu, 4 Apr 2024 10:42:30 +0530 Subject: [PATCH 09/10] Mount registry-cli repo for running tests --- .../data/compose/docker-compose-fixturenet-laconicd.yml | 1 + .../data/container-build/cerc-laconic-registry-cli/Dockerfile | 4 ---- tests/fixturenet-laconicd/run-cli-test.sh | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/stack_orchestrator/data/compose/docker-compose-fixturenet-laconicd.yml b/stack_orchestrator/data/compose/docker-compose-fixturenet-laconicd.yml index f3025062..7821f6ea 100644 --- a/stack_orchestrator/data/compose/docker-compose-fixturenet-laconicd.yml +++ b/stack_orchestrator/data/compose/docker-compose-fixturenet-laconicd.yml @@ -28,6 +28,7 @@ services: image: cerc/laconic-registry-cli:local volumes: - ../config/fixturenet-laconicd/registry-cli-config-template.yml:/registry-cli-config-template.yml + - ${BASE_DIR}/laconic-registry-cli:/laconic-registry-cli volumes: laconicd-data: diff --git a/stack_orchestrator/data/container-build/cerc-laconic-registry-cli/Dockerfile b/stack_orchestrator/data/container-build/cerc-laconic-registry-cli/Dockerfile index 94d2d7e3..8ff8ab7e 100644 --- a/stack_orchestrator/data/container-build/cerc-laconic-registry-cli/Dockerfile +++ b/stack_orchestrator/data/container-build/cerc-laconic-registry-cli/Dockerfile @@ -52,10 +52,6 @@ RUN npm config set @cerc-io:registry ${CERC_NPM_REGISTRY_URL} \ # Globally install the cli package RUN yarn global add @cerc-io/laconic-registry-cli -# Clone the repo for running CLI tests inside the container -RUN git clone https://git.vdb.to/cerc-io/laconic-registry-cli.git \ - && cd laconic-registry-cli && yarn - # Add scripts RUN mkdir /scripts RUN mkdir /scripts/demo-records diff --git a/tests/fixturenet-laconicd/run-cli-test.sh b/tests/fixturenet-laconicd/run-cli-test.sh index 0ff01de9..3eac56f9 100755 --- a/tests/fixturenet-laconicd/run-cli-test.sh +++ b/tests/fixturenet-laconicd/run-cli-test.sh @@ -12,7 +12,7 @@ cat /etc/hosts TEST_TARGET_SO=$( ls -t1 ./package/laconic-so* | head -1 ) echo "$(date +"%Y-%m-%d %T"): Starting stack" -TEST_AUCTION_ENABLED=true $TEST_TARGET_SO --stack fixturenet-laconicd deploy --cluster laconicd up +TEST_AUCTION_ENABLED=true BASE_DIR=~/cerc $TEST_TARGET_SO --stack fixturenet-laconicd deploy --cluster laconicd up echo "$(date +"%Y-%m-%d %T"): Stack started" # Verify that the fixturenet is up and running @@ -30,7 +30,7 @@ docker exec laconicd-laconicd-1 sh -c "curl --retry 10 --retry-delay 3 --retry-c # Run the tests echo "Running the tests" -docker exec -e TEST_ACCOUNT=$laconicd_account_address laconicd-cli-1 sh -c 'cd laconic-registry-cli && yarn test' +docker exec -e TEST_ACCOUNT=$laconicd_account_address laconicd-cli-1 sh -c 'cd laconic-registry-cli && yarn && yarn test' # Clean up $TEST_TARGET_SO --stack fixturenet-laconicd deploy --cluster laconicd down --delete-volumes -- 2.45.2 From 87aef8cebe8e6a0c30fc282c9adc6bf7d1940a83 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Thu, 4 Apr 2024 11:57:03 +0530 Subject: [PATCH 10/10] Add default for registry-cli repo base path --- .../data/compose/docker-compose-fixturenet-laconicd.yml | 2 +- tests/fixturenet-laconicd/run-cli-test.sh | 2 +- tests/webapp-test/run-webapp-test.sh | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stack_orchestrator/data/compose/docker-compose-fixturenet-laconicd.yml b/stack_orchestrator/data/compose/docker-compose-fixturenet-laconicd.yml index 7821f6ea..38b8d442 100644 --- a/stack_orchestrator/data/compose/docker-compose-fixturenet-laconicd.yml +++ b/stack_orchestrator/data/compose/docker-compose-fixturenet-laconicd.yml @@ -28,7 +28,7 @@ services: image: cerc/laconic-registry-cli:local volumes: - ../config/fixturenet-laconicd/registry-cli-config-template.yml:/registry-cli-config-template.yml - - ${BASE_DIR}/laconic-registry-cli:/laconic-registry-cli + - ${BASE_DIR:-~/cerc}/laconic-registry-cli:/laconic-registry-cli volumes: laconicd-data: diff --git a/tests/fixturenet-laconicd/run-cli-test.sh b/tests/fixturenet-laconicd/run-cli-test.sh index 3eac56f9..877d0104 100755 --- a/tests/fixturenet-laconicd/run-cli-test.sh +++ b/tests/fixturenet-laconicd/run-cli-test.sh @@ -26,7 +26,7 @@ docker exec laconicd-cli-1 cp config.yml laconic-registry-cli/ # Wait for the laconid endpoint to come up echo "Waiting for the RPC endpoint to come up" -docker exec laconicd-laconicd-1 sh -c "curl --retry 10 --retry-delay 3 --retry-connrefused http://127.0.0.1:9473/api" +docker exec laconicd-laconicd-1 sh -c "curl --retry 20 --retry-delay 3 --retry-connrefused http://127.0.0.1:9473/api" # Run the tests echo "Running the tests" diff --git a/tests/webapp-test/run-webapp-test.sh b/tests/webapp-test/run-webapp-test.sh index d93d0d6d..39b08c3b 100755 --- a/tests/webapp-test/run-webapp-test.sh +++ b/tests/webapp-test/run-webapp-test.sh @@ -32,14 +32,14 @@ set +e CONTAINER_ID=$(docker run -p 3000:80 -d -e CERC_SCRIPT_DEBUG=$CERC_SCRIPT_DEBUG cerc/test-progressive-web-app:local) sleep 3 -wget --tries 7 --retry-connrefused -O test.before -m http://localhost:3000 +wget --tries 20 --retry-connrefused --waitretry=3 -O test.before -m http://localhost:3000 docker logs $CONTAINER_ID docker remove -f $CONTAINER_ID CONTAINER_ID=$(docker run -p 3000:80 -e CERC_WEBAPP_DEBUG=$CHECK -e CERC_SCRIPT_DEBUG=$CERC_SCRIPT_DEBUG -d cerc/test-progressive-web-app:local) sleep 3 -wget --tries 7 --retry-connrefused -O test.after -m http://localhost:3000 +wget --tries 20 --retry-connrefused --waitretry=3 -O test.after -m http://localhost:3000 docker logs $CONTAINER_ID docker remove -f $CONTAINER_ID -- 2.45.2