diff --git a/.circleci/config.yml b/.circleci/config.yml index e1751907..9d284be6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -268,6 +268,28 @@ jobs: name: Run tests command: bash test/persist/test_failure_indices.sh + localnet: + working_directory: /home/circleci/.go_workspace/src/github.com/tendermint/tendermint + machine: + image: circleci/classic:latest + environment: + GOBIN: /home/circleci/.go_workspace/bin + GOPATH: /home/circleci/.go_workspace/ + GOOS: linux + GOARCH: amd64 + parallelism: 1 + steps: + - checkout + - run: + name: run localnet and exit on failure + command: | + set -x + make get_tools + make get_vendor_deps + make build-linux + make localnet-start & + ./scripts/localnet-blocks-test.sh 40 5 10 localhost + test_p2p: environment: GOBIN: /home/circleci/.go_workspace/bin @@ -337,6 +359,9 @@ workflows: - test_persistence: requires: - setup_dependencies + - localnet: + requires: + - setup_dependencies - test_p2p - upload_coverage: requires: diff --git a/scripts/localnet-blocks-test.sh b/scripts/localnet-blocks-test.sh new file mode 100755 index 00000000..a33ab00f --- /dev/null +++ b/scripts/localnet-blocks-test.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +ITERATIONS=$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 + +I=0 +while [ ${I} -lt "$ITERATIONS" ]; 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 + I=$((I+1)) + sleep "$SLEEP" +done + +echo "Timeout reached, exiting failure..." +exit 1