Skip to content

Commit

Permalink
chore(tests): cleanup integration tests (cometbft#4088)
Browse files Browse the repository at this point in the history
Refs cometbft#2260

---------

Co-authored-by: Andy Nogueira <me@andynogueira.dev>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 1, 2024
1 parent bfff14c commit e997f0a
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 215 deletions.
65 changes: 0 additions & 65 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,68 +46,3 @@ jobs:
- name: install
if: steps.filter.outputs.code == 'true'
run: GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} make build

test_abci_cli:
runs-on: ubuntu-latest
needs: build
timeout-minutes: 5
steps:
- uses: actions/checkout@v4

- id: filter
uses: dorny/paths-filter@v3
with:
filters: |
code:
- '**/*.go'
- 'Makefile'
- 'go.*'
- run: echo "GO_VERSION=$(cat .github/workflows/go-version.env | grep GO_VERSION | cut -d '=' -f2)" >> $GITHUB_ENV
if: steps.filter.outputs.code == 'true'

- uses: actions/setup-go@v5
if: steps.filter.outputs.code == 'true'
with:
go-version: ${{ env.GO_VERSION }}

- name: install
if: steps.filter.outputs.code == 'true'
run: make install_abci

- run: abci/tests/test_cli/test.sh
if: steps.filter.outputs.code == 'true'
shell: bash

test_apps:
runs-on: ubuntu-latest
needs: build
timeout-minutes: 5
steps:
- uses: actions/checkout@v4

- id: filter
uses: dorny/paths-filter@v3
with:
filters: |
code:
- '**/*.go'
- 'Makefile'
- 'go.*'
- run: echo "GO_VERSION=$(cat .github/workflows/go-version.env | grep GO_VERSION | cut -d '=' -f2)" >> $GITHUB_ENV
if: steps.filter.outputs.code == 'true'

- uses: actions/setup-go@v5
if: steps.filter.outputs.code == 'true'
with:
go-version: ${{ env.GO_VERSION }}

- name: install
if: steps.filter.outputs.code == 'true'
run: make install install_abci

- name: test_apps
if: steps.filter.outputs.code == 'true'
run: test/app/test.sh
shell: bash
41 changes: 41 additions & 0 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Integration Tests
on:
pull_request:
merge_group:
push:
paths:
- "**.go"
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
integration_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- id: filter
uses: dorny/paths-filter@v2
with:
filters: |
code:
- '**/*.go'
- 'Makefile'
- 'go.*'
- run: echo "GO_VERSION=$(cat .github/workflows/go-version.env | grep GO_VERSION | cut -d '=' -f2)" >> $GITHUB_ENV
if: steps.filter.outputs.code == 'true'

- uses: actions/setup-go@v5
if: steps.filter.outputs.code == 'true'
with:
go-version: ${{ env.GO_VERSION }}

- name: Run tests
if: steps.filter.outputs.code == 'true'
run: |
make test_integrations
6 changes: 4 additions & 2 deletions abci/tests/test_cli/test.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#! /bin/bash
set -e

set -o errexit # abort on nonzero exitstatus
set -o nounset # abort on unbound variable
set -o pipefail # don't hide errors within pipes

# Get the root directory.
export PATH="$GOBIN:$PATH"
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
DIR="$( cd -P "$( dirname "$SOURCE" )/../.." && pwd )"
Expand Down
1 change: 1 addition & 0 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CometBFT Tests

## Unit tests

The unit tests (ie. `go test`) can be run with `make test` from the root directory of the repository.

## Integration tests
Expand Down
7 changes: 6 additions & 1 deletion test/app/clean.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#! /bin/bash

set -o nounset # abort on unbound variable
set -o pipefail # don't hide errors within pipes

killall cometbft
killall abci-cli
rm -rf ~/.cometbft_app
rm -rf ~/.cometbft
10 changes: 5 additions & 5 deletions test/app/counter_test.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#! /bin/bash

export GO111MODULE=on

set -u
set -o errexit # abort on nonzero exitstatus
set -o nounset # abort on unbound variable
set -o pipefail # don't hide errors within pipes

#####################
# counter over socket
Expand All @@ -19,7 +19,7 @@ function getCode() {
echo -1
fi

if [[ $(echo $R | jq 'has("code")') == "true" ]]; then
if [[ $(echo "$R" | jq 'has("code")') == "true" ]]; then
# this won't actually work if there's an error ...
echo "$R" | jq ".code"
else
Expand Down Expand Up @@ -94,7 +94,7 @@ fi
echo "... sending tx. expect error"

# second time should get rejected by the mempool (return error and non-zero code)
sendTx $TX true
sendTx "$TX" true


echo "... sending tx. expect no error"
Expand Down
50 changes: 19 additions & 31 deletions test/app/kvstore_test.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#! /bin/bash
set -ex

function toHex() {
echo -n $1 | hexdump -ve '1/1 "%.2X"' | awk '{print "0x" $0}'
set -o errexit # abort on nonzero exitstatus
set -o nounset # abort on unbound variable
set -o pipefail # don't hide errors within pipes

function toHex() {
echo -n "$1" | hexdump -ve '1/1 "%.2X"' | awk '{print "0x" $0}'
}

#####################
Expand All @@ -14,40 +16,33 @@ TESTNAME=$1
# store key value pair
KEY="abcd"
VALUE="dcba"
echo $(toHex $KEY=$VALUE)
curl -s 127.0.0.1:26657/broadcast_tx_commit?tx=$(toHex $KEY=$VALUE)
toHex $KEY=$VALUE
curl -s 127.0.0.1:26657/broadcast_tx_commit?tx="$(toHex $KEY=$VALUE)"
echo $?
echo ""


###########################
# test using the abci-cli
###########################

echo "... testing query with abci-cli"

# we should be able to look up the key
RESPONSE=`abci-cli query \"$KEY\"`
RESPONSE=$(abci-cli query \"$KEY\")

set +e
A=`echo $RESPONSE | grep "$VALUE"`
if [[ $? != 0 ]]; then
if ! grep -q "$VALUE" <<< "$RESPONSE"; then
echo "Failed to find $VALUE for $KEY. Response:"
echo "$RESPONSE"
exit 1
fi
set -e

# we should not be able to look up the value
RESPONSE=`abci-cli query \"$VALUE\"`
set +e
A=`echo $RESPONSE | grep \"value: $VALUE\"`
if [[ $? == 0 ]]; then
echo "Found '$VALUE' for $VALUE when we should not have. Response:"
RESPONSE=$(abci-cli query \"$VALUE\")
if grep -q "value: $VALUE" <<< "$RESPONSE"; then
echo "Found 'value: $VALUE' for $VALUE when we should not have. Response:"
echo "$RESPONSE"
exit 1
fi
set -e

#############################
# test using the /abci_query
Expand All @@ -56,29 +51,22 @@ set -e
echo "... testing query with /abci_query 2"

# we should be able to look up the key
RESPONSE=`curl -s "127.0.0.1:26657/abci_query?path=\"\"&data=$(toHex $KEY)&prove=false"`
RESPONSE=`echo $RESPONSE | jq .result.response.log`
RESPONSE=$(curl -s "127.0.0.1:26657/abci_query?path=\"\"&data=$(toHex $KEY)&prove=false")
RESPONSE=$(echo "$RESPONSE" | jq .result.response.log)

set +e
A=`echo $RESPONSE | grep 'exists'`
if [[ $? != 0 ]]; then
if ! grep -q "exists" <<< "$RESPONSE"; then
echo "Failed to find 'exists' for $KEY. Response:"
echo "$RESPONSE"
exit 1
fi
set -e

# we should not be able to look up the value
RESPONSE=`curl -s "127.0.0.1:26657/abci_query?path=\"\"&data=$(toHex $VALUE)&prove=false"`
RESPONSE=`echo $RESPONSE | jq .result.response.log`
set +e
A=`echo $RESPONSE | grep 'exists'`
if [[ $? == 0 ]]; then
echo "Found 'exists' for $VALUE when we should not have. Response:"
RESPONSE=$(curl -s "127.0.0.1:26657/abci_query?path=\"\"&data=$(toHex $VALUE)&prove=false")
RESPONSE=$(echo "$RESPONSE" | jq .result.response.log)
if ! grep -q "does not exist" <<< "$RESPONSE"; then
echo "Failed to find 'does not exist' for $VALUE. Response:"
echo "$RESPONSE"
exit 1
fi
set -e


echo "Passed Test: $TESTNAME"
30 changes: 9 additions & 21 deletions test/app/test.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#! /bin/bash
set -ex

#- kvstore over socket, curl
set -o errexit # abort on nonzero exitstatus
set -o nounset # abort on unbound variable
set -o pipefail # don't hide errors within pipes

# TODO: install everything
#- kvstore over socket, curl

export PATH="$GOBIN:$PATH"
export CMTHOME=$HOME/.cometbft_app
export CMTHOME=$HOME/.cometbft

function kvstore_over_socket(){
rm -rf $CMTHOME
rm -rf "$CMTHOME"
cometbft init
echo "Starting kvstore_over_socket"
abci-cli kvstore > /dev/null &
Expand All @@ -26,7 +26,7 @@ function kvstore_over_socket(){

# start cometbft first
function kvstore_over_socket_reorder(){
rm -rf $CMTHOME
rm -rf "$CMTHOME"
cometbft init
echo "Starting kvstore_over_socket_reorder (ie. start cometbft first)"
cometbft node > cometbft.log &
Expand All @@ -42,17 +42,5 @@ function kvstore_over_socket_reorder(){
kill -9 $pid_kvstore $pid_cometbft
}

case "$1" in
"kvstore_over_socket")
kvstore_over_socket
;;
"kvstore_over_socket_reorder")
kvstore_over_socket_reorder
;;
*)
echo "Running all"
kvstore_over_socket
echo ""
kvstore_over_socket_reorder
echo ""
esac
kvstore_over_socket
kvstore_over_socket_reorder
39 changes: 0 additions & 39 deletions test/docker/Dockerfile

This file was deleted.

3 changes: 0 additions & 3 deletions test/docker/build.sh

This file was deleted.

2 changes: 0 additions & 2 deletions test/docker/config-template.toml

This file was deleted.

14 changes: 0 additions & 14 deletions test/test_cover.sh

This file was deleted.

Loading

0 comments on commit e997f0a

Please sign in to comment.