From 105805cb9b5fd9aab2fd37b45cf85fd0f53b0da4 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Thu, 4 Apr 2024 07:16:46 +0000 Subject: [PATCH] Run registry CLI tests as part of laconicd fixturenet tests (#791) Part of https://www.notion.so/Test-registry-cli-in-SO-fixturenet-laconicd-CI-ef1f497678264362931bd12643ba8a17 Co-authored-by: neeraj Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/791 Co-authored-by: Prathamesh Musale Co-committed-by: Prathamesh Musale --- .gitea/workflows/fixturenet-laconicd-test.yml | 4 +- .../triggers/fixturenet-laconicd-test | 1 + .../docker-compose-fixturenet-laconicd.yml | 4 ++ tests/fixturenet-laconicd/run-cli-test.sh | 37 +++++++++++++++++++ tests/webapp-test/run-webapp-test.sh | 4 +- 5 files changed, 47 insertions(+), 3 deletions(-) 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..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,3 +46,5 @@ jobs: run: ./scripts/build_shiv_package.sh - name: "Run fixturenet-laconicd tests" run: ./tests/fixturenet-laconicd/run-test.sh + - name: "Run laconic CLI tests" + run: ./tests/fixturenet-laconicd/run-cli-test.sh 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 diff --git a/stack_orchestrator/data/compose/docker-compose-fixturenet-laconicd.yml b/stack_orchestrator/data/compose/docker-compose-fixturenet-laconicd.yml index 7b48f60d..38b8d442 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 @@ -25,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:-~/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 new file mode 100755 index 00000000..877d0104 --- /dev/null +++ b/tests/fixturenet-laconicd/run-cli-test.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -e +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi + +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 +TEST_TARGET_SO=$( ls -t1 ./package/laconic-so* | head -1 ) + +echo "$(date +"%Y-%m-%d %T"): Starting stack" +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 +$TEST_TARGET_SO --stack fixturenet-laconicd deploy --cluster laconicd ps + +# Get the fixturenet account address +laconicd_account_address=$(docker exec laconicd-laconicd-1 laconicd keys list | awk '/- address:/ {print $3}') + +# Copy over config +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 20 --retry-delay 3 --retry-connrefused http://127.0.0.1:9473/api" + +# 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 && yarn test' + +# Clean up +$TEST_TARGET_SO --stack fixturenet-laconicd deploy --cluster laconicd down --delete-volumes +echo "$(date +"%Y-%m-%d %T"): Test finished" diff --git a/tests/webapp-test/run-webapp-test.sh b/tests/webapp-test/run-webapp-test.sh index 8cae4828..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 -t 7 -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 -t 7 -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