add compliance test
Some checks failed
Tests / Run integration tests (pull_request) Successful in 3m37s
Tests / Run compliance tests (pull_request) Failing after 3h8m41s

This commit is contained in:
Roy Crihfield 2023-09-29 10:36:18 +08:00
parent 31c25f4ad0
commit d2077fb057
3 changed files with 172 additions and 2 deletions

View File

@ -47,7 +47,7 @@ jobs:
# Complete integration tests are TODO
- name: Run basic integration test
env:
DATABASE_TYPE: postgres
STATEDIFF_MODE: postgres
LEVELDB_PATH: ./fixtures/chaindata/_data/small
LEVELDB_ANCIENT: ./fixtures/chaindata/_data/small/ancient
LOG_FILE: ./server-log
@ -71,3 +71,61 @@ jobs:
[[ "$(count_results eth.header_cids)" = 33 ]]
[[ "$(count_results eth.state_cids)" = 21 ]]
[[ "$(count_results eth.storage_cids)" = 18 ]]
compliance-test:
name: Run compliance tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: ./eth-statediff-service
- uses: actions/setup-go@v3
with:
go-version-file: ./eth-statediff-service/go.mod
check-latest: true
- name: Install test fixtures
uses: actions/checkout@v3
with:
repository: cerc-io/eth-testing
path: ./fixtures
ref: v0.3.1
- name: Configure Gitea access
env:
TOKEN: ${{ secrets.CICD_REPO_TOKEN }}
run: |
git config --global url."https://$TOKEN:@git.vdb.to/".insteadOf https://git.vdb.to/
- name: Build current version
working-directory: ./eth-statediff-service
run: go build -o ../service-current .
- name: Checkout canonical version
uses: actions/checkout@v3
with:
path: ./eth-statediff-service-canonical
ref: ${{ env.CANONICAL_VERSION }}
- name: Build canonical version
working-directory: ./eth-statediff-service-canonical
run: go build -o ../service-canonical .
- name: Run dockerd
run: |
dockerd -H $DOCKER_HOST --userland-proxy=false &
sleep 5
- name: Run DB container
working-directory: ./eth-statediff-service
run: docker compose -f test/compose.yml up --wait
- name: Compare statediff output
env:
LEVELDB_PATH: ./fixtures/chaindata/_data/small2
LEVELDB_ANCIENT: ./fixtures/chaindata/_data/small2/ancient
ETH_GENESIS_BLOCK: "0x8a3c7cddacbd1ab4ec1b03805fa2a287f3a75e43d87f4f987fcc399f5c042614"
run: |
until
ready_query='select max(version_id) from goose_db_version;'
version=$(docker exec -e PGPASSWORD=password test-ipld-eth-db-1 \
psql -tA cerc_testing -U vdbm -c "$ready_query")
[[ "$version" -ge 18 ]]
do sleep 1; done
./eth-statediff-service/scripts/compare-statediffs.sh \
./service-canonical ./service-current

112
scripts/compare-statediffs.sh Executable file
View File

@ -0,0 +1,112 @@
#!/bin/bash
# Compare the full snapshot output from two versions of the service
#
# Usage: compare-versions.sh [-d <output-dir>] <binary-A> <binary-B>
#
# Configure the input data using environment vars.
(
set -u
: $LEVELDB_PATH
: $LEVELDB_ANCIENT
: $ETH_GENESIS_BLOCK
)
while getopts d: opt; do
case $opt in
d) output_dir="$OPTARG"
esac
done
shift $((OPTIND - 1))
binary_A=$1
binary_B=$2
shift 2
if [[ -z $output_dir ]]; then
output_dir=$(mktemp -d)
fi
export STATEDIFF_MODE=postgres
export STATEDIFF_TRIE_WORKERS=32
export DATABASE_NAME="cerc_testing"
export DATABASE_HOSTNAME="localhost"
export DATABASE_PORT=8077
export DATABASE_USER="vdbm"
export DATABASE_PASSWORD="password"
export ETH_CLIENT_NAME=test-client
export ETH_NODE_ID=test-node
export ETH_NETWORK_ID=test-network
export LOG_LEVEL=debug
dump_table() {
statement="copy (select * from $1) to stdout with csv"
docker exec -e PGPASSWORD="$DATABASE_PASSWORD" test-ipld-eth-db-1 \
psql -q $DATABASE_NAME -U $DATABASE_USER -c "$statement" | sort -u > "$2/$1.csv"
}
clear_table() {
docker exec -e PGPASSWORD="$DATABASE_PASSWORD" test-ipld-eth-db-1 \
psql -q $DATABASE_NAME -U $DATABASE_USER -c "truncate $1"
}
tables=(
eth.log_cids
eth.receipt_cids
eth.state_cids
eth.storage_cids
eth.transaction_cids
eth.uncle_cids
ipld.blocks
public.nodes
)
for table in "${tables[@]}"; do
clear_table $table
done
range_start=190
range_end=200
run_service() {
export LOG_FILE=$(mktemp)
export LOG_FILE_PATH=$LOG_FILE
service_binary=$1
service_output_dir=$2
$service_binary serve --config ./test/ci-config.toml serve &
until grep "HTTP endpoint opened" $LOG_FILE
do sleep 1; done
./scripts/request-range.sh $range_start $range_end
if E=$?; [[ $E != 0 ]]; then
cat $LOG_FILE
return $E
fi
echo "Waiting for service to complete requests..."
until grep \
-e "Finished processing block $range_end" \
-e "finished processing statediff height $range_end" \
$LOG_FILE
do sleep 1; done
kill -INT $!
mkdir -p $service_output_dir
for table in "${tables[@]}"; do
dump_table $table $service_output_dir
clear_table $table
done
}
set -e
run_service $binary_A $output_dir/A
run_service $binary_B $output_dir/B
diff -rs $output_dir/A $output_dir/B

View File

@ -4,7 +4,7 @@ set -eu
FROM=$1
TO=$2
URL=127.0.0.1:8545
URL='127.0.0.1:8545'
DATA='{
"jsonrpc": "2.0",