ci: liveness test (#498)

* ci: liveness test

* rm key

* makefile

* chmod

* update docs
This commit is contained in:
Federico Kunze Küllmer 2021-08-26 11:21:43 -04:00 committed by GitHub
parent 556fca1524
commit b5288399d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 142 additions and 209 deletions

View File

@ -1,214 +1,58 @@
name: Tests / Code Coverage
# Tests / Code Coverage workflow runs unit tests and uploads a code coverage report
# This workflow is run on pushes to development & every Pull Requests where a .go, .mod, .sum have been changed
name: Tests
on:
pull_request:
push:
branches:
- main
- release/**
jobs:
# TODO: refactor before enabling
# test-rpc:
# runs-on: ubuntu-latest
# timeout-minutes: 10
# steps:
# - uses: actions/checkout@v2.3.4
# - uses: actions/setup-go@v2.1.3
# with:
# go-version: 1.16
# - uses: technote-space/get-diff-action@v5
# id: git_diff
# with:
# SUFFIX_FILTER: |
# .go
# .mod
# .sum
# - name: test-rpc
# run: |
# make test-rpc
# if: "env.GIT_DIFF != ''"
split-test-files:
cleanup-runs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- name: Create a file with all the pkgs
run: go list ./... | grep -Ev 'vendor|importer|rpc/tester' > pkgs.txt
- name: Split pkgs into 4 files
run: split -n l/4 --additional-suffix=.txt ./pkgs.txt
# cache multiple
- uses: actions/upload-artifact@v2
with:
name: "${{ github.sha }}-aa"
path: ./xaa.txt
- uses: actions/upload-artifact@v2
with:
name: "${{ github.sha }}-ab"
path: ./xab.txt
- uses: actions/upload-artifact@v2
with:
name: "${{ github.sha }}-ac"
path: ./xac.txt
- uses: actions/upload-artifact@v2
with:
name: "${{ github.sha }}-ad"
path: ./xad.txt
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'"
test-coverage-run-1:
install-tparse:
runs-on: ubuntu-latest
needs: split-test-files
timeout-minutes: 10
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/setup-go@v2.1.3
- uses: actions/setup-go@v2.1.4
with:
go-version: 1.16
- name: Display Go Version
run: go version
- name: Install tparse
run: |
export GO111MODULE="on" && go get github.com/mfridman/tparse@v0.8.3
- uses: actions/cache@v2.1.6
with:
path: ~/go/bin
key: ${{ runner.os }}-go-tparse-binary
test-unit-cover:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2.1.4
with:
go-version: 1.16
- uses: actions/checkout@v2.3.4
- uses: technote-space/get-diff-action@v5
id: git_diff
with:
SUFFIX_FILTER: |
.go
.mod
.sum
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-aa"
if: "env.GIT_DIFF != ''"
- name: test & coverage report creation
PATTERNS: |
**/**.go
go.mod
go.sum
- name: Test and Create Coverage Report
run: |
cat xaa.txt | xargs go test -timeout 8m -coverprofile=coverage.txt -covermode=atomic
if: "env.GIT_DIFF != ''"
- name: filter out proto files
run: |
excludelist+=" $(find ./ -type f -name '*.pb.go')"
for filename in ${excludelist}; do
filename=$(echo $filename | sed 's/^./github.com\/tharsis\/ethermint/g')
echo "Excluding ${filename} from coverage report..."
sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt
done
if: "env.GIT_DIFF != ''"
make test-unit-cover
if: env.GIT_DIFF
- uses: codecov/codecov-action@v2.0.3
with:
file: ./coverage.txt
fail_ci_if_error: true
if: "env.GIT_DIFF != ''"
test-coverage-run-2:
runs-on: ubuntu-latest
needs: split-test-files
timeout-minutes: 10
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.16
- uses: technote-space/get-diff-action@v5
id: git_diff
with:
SUFFIX_FILTER: |
.go
.mod
.sum
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-ab"
if: "env.GIT_DIFF != ''"
- name: test & coverage report creation
run: |
cat xab.txt | xargs go test -timeout 6m -coverprofile=coverage.txt -covermode=atomic
if: "env.GIT_DIFF != ''"
- name: filter out proto files
run: |
excludelist+=" $(find ./ -type f -name '*.pb.go')"
for filename in ${excludelist}; do
filename=$(echo $filename | sed 's/^./github.com\/tharsis\/ethermint/g')
echo "Excluding ${filename} from coverage report..."
sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt
done
if: "env.GIT_DIFF != ''"
- uses: codecov/codecov-action@v2.0.3
with:
file: ./coverage.txt
fail_ci_if_error: true
if: "env.GIT_DIFF != ''"
test-coverage-run-3:
runs-on: ubuntu-latest
needs: split-test-files
timeout-minutes: 10
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.16
- uses: technote-space/get-diff-action@v5
id: git_diff
with:
SUFFIX_FILTER: |
.go
.mod
.sum
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-ac"
if: "env.GIT_DIFF != ''"
- name: test & coverage report creation
run: |
cat xac.txt | xargs go test -timeout 6m -coverprofile=coverage.txt -covermode=atomic
if: "env.GIT_DIFF != ''"
- name: filter out proto files
run: |
excludelist+=" $(find ./ -type f -name '*.pb.go')"
for filename in ${excludelist}; do
filename=$(echo $filename | sed 's/^./github.com\/tharsis\/ethermint/g')
echo "Excluding ${filename} from coverage report..."
sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt
done
if: "env.GIT_DIFF != ''"
- uses: codecov/codecov-action@v2.0.3
with:
file: ./coverage.txt
fail_ci_if_error: true
if: "env.GIT_DIFF != ''"
test-coverage-run-4:
runs-on: ubuntu-latest
needs: split-test-files
timeout-minutes: 10
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.16
- uses: technote-space/get-diff-action@v5
id: git_diff
with:
SUFFIX_FILTER: |
.go
.mod
.sum
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-ad"
if: "env.GIT_DIFF != ''"
- name: test & coverage report creation
run: |
cat xad.txt | xargs go test -timeout 6m -coverprofile=coverage.txt -covermode=atomic
if: "env.GIT_DIFF != ''"
- name: filter out proto files
run: |
excludelist+=" $(find ./ -type f -name '*.pb.go')"
for filename in ${excludelist}; do
filename=$(echo $filename | sed 's/^./github.com\/tharsis\/ethermint/g')
echo "Excluding ${filename} from coverage report..."
sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt
done
if: "env.GIT_DIFF != ''"
- uses: codecov/codecov-action@v2.0.3
with:
file: ./coverage.txt
fail_ci_if_error: true
if: "env.GIT_DIFF != ''"
if: env.GIT_DIFF
# TODO: refactor before enabling
# test-importer:
@ -216,7 +60,7 @@ jobs:
# timeout-minutes: 10
# steps:
# - uses: actions/checkout@v2.3.4
# - uses: actions/setup-go@v2.1.3
# - uses: actions/setup-go@v2.1.4
# with:
# go-version: 1.16
# - uses: technote-space/get-diff-action@v5
@ -247,3 +91,33 @@ jobs:
run: |
make test-solidity
if: "env.GIT_DIFF != ''"
liveness-test:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/setup-go@v2.1.4
with:
go-version: 1.16
- uses: technote-space/get-diff-action@v5
id: git_diff
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- name: Install Starport
run: |
curl https://get.starport.network/starport! | bash
if: env.GIT_DIFF
- name: Start Local Network via Starport
run: |
starport chain serve --reset-once -v -c ./starport.yml > starport.out 2>&1 &
if: env.GIT_DIFF
- name: Test Local Network Liveness
run: |
sleep 2m
./contrib/scripts/test_localnet_liveness.sh 100 5 50 localhost
if: env.GIT_DIFF

View File

@ -299,18 +299,22 @@ build-docs-versioned:
test: test-unit
test-all: test-unit test-race
PACKAGES_UNIT=$(shell go list ./...)
TEST_PACKAGES=./...
TEST_TARGETS := test-unit test-race
TEST_TARGETS := test-unit test-unit-cover test-race
# Test runs-specific rules. To add a new test target, just add
# a new rule, customise ARGS or TEST_PACKAGES ad libitum, and
# append the new rule to the TEST_TARGETS list.
test-unit: ARGS=-tags='norace'
test-unit: ARGS=-timeout=10m -race
test-unit: TEST_PACKAGES=$(PACKAGES_UNIT)
test-race: ARGS=-race
test-race: TEST_PACKAGES=$(PACKAGES_NOSIMULATION)
$(TEST_TARGETS): run-tests
test-unit-cover: ARGS=-timeout=10m -race -coverprofile=coverage.txt -covermode=atomic
test-unit-cover: TEST_PACKAGES=$(PACKAGES_UNIT)
run-tests:
ifneq (,$(shell which tparse 2>/dev/null))
@ -391,10 +395,6 @@ test-sim-multi-seed-short \
test-sim-multi-seed-long \
test-sim-benchmark-invariants
test-cover:
@export VERSION=$(VERSION); bash -x contrib/test_cover.sh
.PHONY: test-cover
benchmark:
@go test -mod=readonly -bench=. $(PACKAGES_NOSIMULATION)
.PHONY: benchmark

View File

@ -0,0 +1,51 @@
#!/bin/bash
CNT=0
ITER=$1
SLEEP=$2
NUMBLOCKS=$3
NODEADDR=$4
if [ -z "$1" ]; then
echo "Invalid argument: missing number of iterations"
echo "sh test_localnet_liveness.sh <iterations> <sleep> <num-blocks> <node-address>"
exit 1
fi
if [ -z "$2" ]; then
echo "Invalid argument: missing sleep duration"
echo "sh test_localnet_liveness.sh <iterations> <sleep> <num-blocks> <node-address>"
exit 1
fi
if [ -z "$3" ]; then
echo "Invalid argument: missing number of blocks"
echo "sh test_localnet_liveness.sh <iterations> <sleep> <num-blocks> <node-address>"
exit 1
fi
if [ -z "$4" ]; then
echo "Invalid argument: missing node address"
echo "sh test_localnet_liveness.sh <iterations> <sleep> <num-blocks> <node-address>"
exit 1
fi
docker_containers=($(docker ps -q -f name=ethermintd --format='{{.Names}}'))
while [ ${CNT} -lt $ITER ]; do
curr_block=$(curl -s $NODEADDR:26657/status | jq -r '.result.sync_info.latest_block_height')
if [ ! -z ${curr_block} ]; then
echo "Current block: ${curr_block}"
fi
if [ ! -z ${curr_block} ] && [ ${curr_block} -gt ${NUMBLOCKS} ]; then
echo "Success: number of blocks reached"
exit 0
fi
sleep $SLEEP
done
echo "Failed: timeout reached"
exit 1

View File

@ -6,7 +6,7 @@ order: 2
## Pre-requisite Readings
- [Install Starport](https://docs.starport.network/intro/install.html) {prereq}
- [Install Starport](https://docs.starport.network/#install-starport) {prereq}
- [Install Docker](https://docs.docker.com/engine/installation/) {prereq}
- [Install docker-compose](https://docs.docker.com/compose/install/) {prereq}
@ -15,7 +15,7 @@ order: 2
Once you have installed `starport`, just run the localnet by using
```bash
starport serve
starport chain serve --reset-once -v -c ./starport.yml
```
## Automated Localnet with Docker
@ -55,7 +55,6 @@ Creating ethermintdnode1 ... done
Creating ethermintdnode3 ... done
```
### Stop Localnet
Once you are done, execute:

View File

@ -7,7 +7,6 @@ order: 1
## Pre-requisite Readings
- [Install Binary](./../../quickstart/installation) {prereq}
- [Install Starport](https://docs.starport.network/intro/install.html) {prereq}
## Automated Localnet (script)

1
go.mod
View File

@ -24,6 +24,7 @@ require (
github.com/gorilla/mux v1.8.0
github.com/gorilla/websocket v1.4.2
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.0 // indirect
github.com/improbable-eng/grpc-web v0.14.1
github.com/miguelmota/go-ethereum-hdwallet v0.0.1

7
go.sum
View File

@ -300,6 +300,7 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4
github.com/garyburd/redigo v1.6.0/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
@ -410,6 +411,7 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa h1:Q75Upo5UN4JbPFURXZ8nLKYUvF85dyFRop/vQ0Rv+64=
@ -473,6 +475,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t
github.com/grpc-ecosystem/grpc-gateway v1.14.7/go.mod h1:oYZKL012gGh6LMyg/xA7Q2yq6j8bu0wa+9w14EEthWU=
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.5.0 h1:ajue7SzQMywqRjg2fK7dcpc0QhFGpTR2plWfV4EZWR4=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.5.0/go.mod h1:r1hZAcvfFXuYmcKyCJI9wlyOPIZUJl6FCB8Cpca/NLE=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0=
github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s=
@ -1159,6 +1163,7 @@ golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ
golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210615190721-d04028783cf1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -1333,6 +1338,7 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@ -1425,6 +1431,7 @@ google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6D
google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A=
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
google.golang.org/genproto v0.0.0-20210617175327-b9e0b3197ced/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24=
google.golang.org/genproto v0.0.0-20210825212027-de86158e7fda h1:iT5uhT54PtbqUsWddv/nnEWdE5e/MTr+Nv3vjxlBP1A=
google.golang.org/genproto v0.0.0-20210825212027-de86158e7fda/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY=
google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o=

View File

@ -3,17 +3,23 @@ accounts:
coins: ["100000000uatom", "100000000000000000000aphoton"]
- name: bob
coins: ["5000000000000aphoton"]
- name: faucet
coins: ["1000000000000000000000000000aphoton"]
validator:
name: alice
staked: "100000000000000000000aphoton"
faucet:
name: bob
coins: ["10aphoton"]
port: 4500
name: "faucet"
coins: ["1000000000000000000000000000aphoton"]
coins_max: ["100000000aphoton"]
build:
binary: "ethermintd"
init:
home: "$HOME/.ethermintd"
app:
api:
enable: true
json-rpc:
address: "0.0.0.0:8545" # change the JSON-RPC address and port
ws-address: "0.0.0.0:8546" # change the JSON-RPC websocket address and port

View File

@ -31,8 +31,6 @@ const (
prefixLogs
prefixCode
prefixStorage
prefixBlockGasUsed
prefixBaseFee
)
// prefix bytes for the EVM transient store
@ -54,8 +52,6 @@ var (
KeyPrefixLogs = []byte{prefixLogs}
KeyPrefixCode = []byte{prefixCode}
KeyPrefixStorage = []byte{prefixStorage}
KeyPrefixBlockGasUsed = []byte{prefixBlockGasUsed}
KeyPrefixBaseFee = []byte{prefixBaseFee}
)
// Transient Store key prefixes