From f32288b16d09730dda80bcc4343bd2319656e19a Mon Sep 17 00:00:00 2001 From: Prajjwol Gautam Date: Wed, 9 Feb 2022 05:56:12 -0800 Subject: [PATCH] ci: separate out rpc and integration tests (#931) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- .github/workflows/deploy-contract.yml | 2 +- .github/workflows/test.yml | 24 ++++++++++++++++++++++-- Makefile | 3 +++ scripts/integration-test-all.sh | 19 ++++++++++++++----- scripts/start.sh | 6 +++--- tests/e2e/integration_test.go | 6 ++++-- 7 files changed, 48 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ada108b6..aa882881 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,4 +29,4 @@ jobs: .sum - run: | make build - if: "env.GIT_DIFF != ''" + if: env.GIT_DIFF diff --git a/.github/workflows/deploy-contract.yml b/.github/workflows/deploy-contract.yml index 41edf633..cfbb67e7 100644 --- a/.github/workflows/deploy-contract.yml +++ b/.github/workflows/deploy-contract.yml @@ -35,4 +35,4 @@ jobs: run: | sudo make contract-tools sudo make test-contract - if: "env.GIT_DIFF != ''" + if: env.GIT_DIFF diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bebcbe3a..3f677b26 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -73,7 +73,7 @@ jobs: - name: test-importer run: | make test-import - if: "env.GIT_DIFF != ''" + if: env.GIT_DIFF test-solidity: runs-on: ubuntu-latest @@ -100,7 +100,7 @@ jobs: - name: test-solidity run: | ./scripts/run-solidity-tests.sh --batch=${{ matrix.batch }} - if: "env.GIT_DIFF != ''" + if: env.GIT_DIFF liveness-test: runs-on: ubuntu-latest @@ -150,3 +150,23 @@ jobs: run: | make test-rpc if: env.GIT_DIFF + + test-e2e: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/setup-go@v2.1.4 + with: + go-version: 1.17 + - uses: actions/checkout@v2.4.0 + - uses: technote-space/get-diff-action@v6.0.1 + with: + PATTERNS: | + **/**.sol + **/**.go + go.mod + go.sum + - name: Test e2e + run: | + make test-integration + if: env.GIT_DIFF \ No newline at end of file diff --git a/Makefile b/Makefile index 6580ad6a..de98980e 100755 --- a/Makefile +++ b/Makefile @@ -324,6 +324,9 @@ test-import: test-rpc: ./scripts/integration-test-all.sh -t "rpc" -q 1 -z 1 -s 2 -m "rpc" -r "true" +test-integration: + ./scripts/integration-test-all.sh -t "integration" -q 1 -z 1 -s 2 -m "integration" -r "true" + test-rpc-pending: ./scripts/integration-test-all.sh -t "pending" -q 1 -z 1 -s 2 -m "pending" -r "true" diff --git a/scripts/integration-test-all.sh b/scripts/integration-test-all.sh index 421684b1..1522f219 100755 --- a/scripts/integration-test-all.sh +++ b/scripts/integration-test-all.sh @@ -139,8 +139,18 @@ echo "done sleeping" set +e -if [[ -z $TEST || $TEST == "rpc" || $TEST == "pending" ]]; then +if [[ -z $TEST || $TEST == "integration" ]] ; then + time_out=300s + for i in $(seq 1 "$TEST_QTD"); do + HOST_RPC=http://$IP_ADDR:$RPC_PORT"$i" + echo "going to test ethermint node $HOST_RPC ..." + MODE=$MODE HOST=$HOST_RPC go test ./tests/e2e/... -timeout=$time_out -v -short + TEST_FAIL=$? + done +fi + +if [[ -z $TEST || $TEST == "rpc" || $TEST == "pending" ]]; then time_out=300s if [[ $TEST == "pending" ]]; then time_out=60m0s @@ -149,10 +159,9 @@ if [[ -z $TEST || $TEST == "rpc" || $TEST == "pending" ]]; then for i in $(seq 1 "$TEST_QTD"); do HOST_RPC=http://$IP_ADDR:$RPC_PORT"$i" echo "going to test ethermint node $HOST_RPC ..." - MODE=$MODE HOST=$HOST_RPC go test ./tests/e2e/... -timeout=$time_out -v -short MODE=$MODE HOST=$HOST_RPC go test ./tests/rpc/... -timeout=$time_out -v -short - RPC_FAIL=$? + TEST_FAIL=$? done fi @@ -175,8 +184,8 @@ for i in "${arr[@]}"; do stop_func "$i" done -if [[ (-z $TEST || $TEST == "rpc") && $RPC_FAIL -ne 0 ]]; then - exit $RPC_FAIL +if [[ (-z $TEST || $TEST == "rpc" || $TEST == "integration" ) && $TEST_FAIL -ne 0 ]]; then + exit $TEST_FAIL else exit 0 fi diff --git a/scripts/start.sh b/scripts/start.sh index 285ebda4..c05bff70 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -127,7 +127,7 @@ if [[ -z $TEST || $TEST == "rpc" ]]; then MODE=$MODE HOST=$HOST_RPC go test ./tests/e2e/... -timeout=300s -v -short MODE=$MODE HOST=$HOST_RPC go test ./tests/rpc/... -timeout=300s -v -short - RPC_FAIL=$? + TEST_FAIL=$? done fi @@ -150,8 +150,8 @@ for i in "${arr[@]}"; do stop_func "$i" done -if [[ (-z $TEST || $TEST == "rpc") && $RPC_FAIL -ne 0 ]]; then - exit $RPC_FAIL +if [[ (-z $TEST || $TEST == "rpc") && $TEST_FAIL -ne 0 ]]; then + exit $TEST_FAIL else exit 0 fi diff --git a/tests/e2e/integration_test.go b/tests/e2e/integration_test.go index 773f95ac..3c09b860 100644 --- a/tests/e2e/integration_test.go +++ b/tests/e2e/integration_test.go @@ -4,11 +4,12 @@ import ( "bytes" "context" "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" - evmtypes "github.com/tharsis/ethermint/x/evm/types" "math/big" "testing" + sdk "github.com/cosmos/cosmos-sdk/types" + evmtypes "github.com/tharsis/ethermint/x/evm/types" + // . "github.com/onsi/ginkgo" // . "github.com/onsi/gomega" @@ -392,6 +393,7 @@ func (s *IntegrationTestSuite) TestGetLogs() { common.HexToHash("0x000000000000000000000000" + fmt.Sprintf("%x", common.BytesToAddress(s.network.Validators[0].Address))), common.HexToHash("0x000000000000000000000000378c50d9264c63f3f92b806d4ee56e9d86ffb3ec"), } + s.Require().Equal(expectedTopics, logs[0].Topics) }