From 861fe0bebb33eb516e2802067826151608d3e7a0 Mon Sep 17 00:00:00 2001 From: Yiming Zang Date: Mon, 2 Jan 2023 20:12:11 -0800 Subject: [PATCH 1/5] Add docker test --- .github/workflows/integration-test.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/integration-test.yml diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 0000000000..f08bc3a9c2 --- /dev/null +++ b/.github/workflows/integration-test.yml @@ -0,0 +1,25 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Docker Integration Test + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.18 + + - name: Start 4 node docker cluster + run: make clean && make docker-cluster-start From 79051dc682cabe085b7b6d5af31083997d5aff94 Mon Sep 17 00:00:00 2001 From: Yiming Zang Date: Mon, 2 Jan 2023 21:19:56 -0800 Subject: [PATCH 2/5] Add validation script for github workflow --- .github/workflows/integration-test.yml | 37 ++++++++++++++++++++- docker/localnode/scripts/step5_start_sei.sh | 9 ++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index f08bc3a9c2..3f542ea34b 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -9,10 +9,15 @@ on: pull_request: branches: [ "master" ] +defaults: + run: + shell: bash + jobs: build: runs-on: ubuntu-latest + timeout-minutes: 15 steps: - uses: actions/checkout@v3 @@ -22,4 +27,34 @@ jobs: go-version: 1.18 - name: Start 4 node docker cluster - run: make clean && make docker-cluster-start + run: make clean && make docker-cluster-start & + + - name: Wait for docker cluster to start + run: | + until [ $(cat build/generated/launch.complete |wc -l) = 4 ] + do + sleep 5 + done + + - name: Verify there are 4 validators running + run: | + NUM_VALIDATORS=$(docker exec -it sei-node0 build/seid q tendermint-validator-set |grep address |wc -l) + if [[ "$NUM_VALIDATORS" -eq 4 ]]; + then + echo "Number validators is correct: $NUM_VALIDATORS" + fi + else + exit 1 + fi + + - name: Verify block height is keep increasing + run: | + HEIGHT_1=$(docker exec -it sei-node0 build/seid status |jq -r .SyncInfo.latest_block_height) + echo $HEIGHT_1 + sleep 30 + HEIGHT_2=$(docker exec -it sei-node0 build/seid status |jq -r .SyncInfo.latest_block_height) + echo $HEIGHT_2 + if [ "$HEIGHT_1" -le "$HEIGHT_2" ]; + then + exit 1 + fi diff --git a/docker/localnode/scripts/step5_start_sei.sh b/docker/localnode/scripts/step5_start_sei.sh index 8ef3f29a9f..43a5f21419 100755 --- a/docker/localnode/scripts/step5_start_sei.sh +++ b/docker/localnode/scripts/step5_start_sei.sh @@ -9,6 +9,13 @@ mkdir -p $LOG_DIR echo "Starting the sei chain daemon" cp build/generated/genesis-sei.json ~/.sei/config/genesis.json ./build/seid start --chain-id sei > "$LOG_DIR"/seid-$NODE_ID.log 2>&1 & +echo "Done" >> build/generated/launch.complete echo "Server started successfully! Check your logs under $LOG_DIR/" -tail -f /dev/null \ No newline at end of file + +until [ $(cat build/generated/launch.complete |wc -l) = 4 ] +do + sleep 5 +done + +tail -f /dev/null From 910773e3696a916756f3f9b87db3d4629fa02d27 Mon Sep 17 00:00:00 2001 From: Yiming Zang Date: Mon, 2 Jan 2023 21:26:07 -0800 Subject: [PATCH 3/5] Fix tty --- .github/workflows/integration-test.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 3f542ea34b..7176657bf7 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -27,7 +27,9 @@ jobs: go-version: 1.18 - name: Start 4 node docker cluster - run: make clean && make docker-cluster-start & + run: | + make clean && make docker-cluster-start & + sleep 360 - name: Wait for docker cluster to start run: | @@ -38,7 +40,7 @@ jobs: - name: Verify there are 4 validators running run: | - NUM_VALIDATORS=$(docker exec -it sei-node0 build/seid q tendermint-validator-set |grep address |wc -l) + NUM_VALIDATORS=$(docker exec -i sei-node0 build/seid q tendermint-validator-set |grep address |wc -l) if [[ "$NUM_VALIDATORS" -eq 4 ]]; then echo "Number validators is correct: $NUM_VALIDATORS" @@ -49,10 +51,10 @@ jobs: - name: Verify block height is keep increasing run: | - HEIGHT_1=$(docker exec -it sei-node0 build/seid status |jq -r .SyncInfo.latest_block_height) + HEIGHT_1=$(docker exec -i sei-node0 build/seid status |jq -r .SyncInfo.latest_block_height) echo $HEIGHT_1 sleep 30 - HEIGHT_2=$(docker exec -it sei-node0 build/seid status |jq -r .SyncInfo.latest_block_height) + HEIGHT_2=$(docker exec -i sei-node0 build/seid status |jq -r .SyncInfo.latest_block_height) echo $HEIGHT_2 if [ "$HEIGHT_1" -le "$HEIGHT_2" ]; then From 52e5c2e6c75dff87851947a56d9697ee1d86a8bc Mon Sep 17 00:00:00 2001 From: Yiming Zang Date: Mon, 2 Jan 2023 21:34:28 -0800 Subject: [PATCH 4/5] Fix if else --- .github/workflows/integration-test.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 7176657bf7..8ad46f25ce 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -27,15 +27,13 @@ jobs: go-version: 1.18 - name: Start 4 node docker cluster - run: | - make clean && make docker-cluster-start & - sleep 360 + run: make clean && make docker-cluster-start & - name: Wait for docker cluster to start run: | until [ $(cat build/generated/launch.complete |wc -l) = 4 ] do - sleep 5 + sleep 10 done - name: Verify there are 4 validators running @@ -44,7 +42,6 @@ jobs: if [[ "$NUM_VALIDATORS" -eq 4 ]]; then echo "Number validators is correct: $NUM_VALIDATORS" - fi else exit 1 fi From 733b77e1870b5c4b3ae5e2df24d7be4d811a9506 Mon Sep 17 00:00:00 2001 From: Yiming Zang Date: Mon, 2 Jan 2023 21:41:52 -0800 Subject: [PATCH 5/5] Fix if condition --- .github/workflows/integration-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 8ad46f25ce..9f7e7362a7 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -50,10 +50,10 @@ jobs: run: | HEIGHT_1=$(docker exec -i sei-node0 build/seid status |jq -r .SyncInfo.latest_block_height) echo $HEIGHT_1 - sleep 30 + sleep 15 HEIGHT_2=$(docker exec -i sei-node0 build/seid status |jq -r .SyncInfo.latest_block_height) echo $HEIGHT_2 - if [ "$HEIGHT_1" -le "$HEIGHT_2" ]; + if [ "$HEIGHT_1" -ge "$HEIGHT_2" ]; then exit 1 fi