Skip to content

Commit

Permalink
ci: add localnet test (Finschia#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yongwoo Lee authored Oct 21, 2021
1 parent 7cf904d commit 97ac586
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,25 @@ jobs:
- name: Generate multi node integration test report
run: cat ./*-integration-multi-node-output.txt | ~/go/bin/tparse
if: env.GIT_DIFF

test-localnet-blocks:
runs-on: self-hosted
needs: [build, tests]
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
- name: Start localnet
run: |
make localnet-start
- name: Test blocks
id: test-blocks
continue-on-error: true
run: ./networks/localnet-blocks-test.sh 40 5 10 localhost
- name: Stop localnet
run: |
make localnet-stop
if [ ${{ steps.test-blocks.outcome }} == 'failure' ] ; then
exit 1
fi
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ build: go.sum $(BUILDDIR)/ dbbackend

build-static: go.sum $(BUILDDIR)/
docker build -t line/lbm-builder:static -f builders/Dockerfile.static .
docker run -it --rm -v $(shell pwd):/code -e LBM_BUILD_OPTIONS="$(LBM_BUILD_OPTIONS)" line/lbm-builder:static
docker run -t --rm -v $(shell pwd):/code -e LBM_BUILD_OPTIONS="$(LBM_BUILD_OPTIONS)" line/lbm-builder:static

install: go.sum $(BUILDDIR)/ dbbackend
CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) CGO_ENABLED=$(CGO_ENABLED) go install $(BUILD_FLAGS) $(BUILD_ARGS) ./cmd/lbm
Expand Down
41 changes: 41 additions & 0 deletions networks/localnet-blocks-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

CNT=0
ITER=$1
SLEEP=$2
NUMBLOCKS=$3
NODEADDR=$4

if [ -z "$1" ]; then
echo "Need to input number of iterations to run..."
exit 1
fi

if [ -z "$2" ]; then
echo "Need to input number of seconds to sleep between iterations"
exit 1
fi

if [ -z "$3" ]; then
echo "Need to input block height to declare completion..."
exit 1
fi

if [ -z "$4" ]; then
echo "Need to input node address to poll..."
exit 1
fi

while [ $CNT -lt $ITER ]; do
var=$(curl -s $NODEADDR:26657/status | jq -r '.result.sync_info.latest_block_height')
echo "Number of Blocks: ${var}"
if [ ! -z ${var} ] && [ ${var} -gt ${NUMBLOCKS} ]; then
echo "Number of blocks reached, exiting success..."
exit 0
fi
let CNT=CNT+1
sleep $SLEEP
done

echo "Timeout reached, exiting failure..."
exit 1

0 comments on commit 97ac586

Please sign in to comment.