add compliance test
This commit is contained in:
parent
3c5bd48ae7
commit
67086055c2
@ -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,63 @@ 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
|
||||
timeout-minutes: 10
|
||||
env:
|
||||
LEVELDB_PATH: ./fixtures/chaindata/_data/small2
|
||||
LEVELDB_ANCIENT: ./fixtures/chaindata/_data/small2/ancient
|
||||
ETH_GENESIS_BLOCK: "0x8a3c7cddacbd1ab4ec1b03805fa2a287f3a75e43d87f4f987fcc399f5c042614"
|
||||
ETH_CHAIN_CONFIG: ./eth-statediff-service/test/ci-chain.json
|
||||
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
|
||||
|
121
scripts/compare-statediffs.sh
Executable file
121
scripts/compare-statediffs.sh
Executable file
@ -0,0 +1,121 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Usage: compare-versions.sh [-d <output-dir>] <binary-A> <binary-B>
|
||||
#
|
||||
# Compares full statediff output from two versions of the service.
|
||||
# Configure the input data using environment vars.
|
||||
(
|
||||
set -u
|
||||
: $LEVELDB_PATH
|
||||
: $LEVELDB_ANCIENT
|
||||
: $ETH_GENESIS_BLOCK
|
||||
: $ETH_CHAIN_CONFIG
|
||||
) || exit 1
|
||||
|
||||
# Range of diffs to request
|
||||
range_start=50
|
||||
range_end=100
|
||||
|
||||
# Get the parent directory
|
||||
script_dir=$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")
|
||||
|
||||
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 STATEDIFF_SERVICE_WORKERS=8
|
||||
export STATEDIFF_WORKER_QUEUE_SIZE=1024
|
||||
|
||||
export DATABASE_NAME="cerc_testing"
|
||||
export DATABASE_HOSTNAME="localhost"
|
||||
export DATABASE_PORT=8077
|
||||
export DATABASE_USER="vdbm"
|
||||
export DATABASE_PASSWORD="password"
|
||||
|
||||
export ETH_NODE_ID=test-node
|
||||
export ETH_CLIENT_NAME=test-client
|
||||
export ETH_NETWORK_ID=test-network
|
||||
export ETH_CHAIN_ID=4242
|
||||
|
||||
export SERVICE_HTTP_PATH='127.0.0.1:8545'
|
||||
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
|
||||
|
||||
run_service() {
|
||||
export LOG_FILE=$(mktemp)
|
||||
export LOG_FILE_PATH=$LOG_FILE
|
||||
|
||||
service_binary=$1
|
||||
service_output_dir=$2
|
||||
|
||||
$service_binary serve &
|
||||
|
||||
until grep "HTTP endpoint opened" $LOG_FILE
|
||||
do sleep 1; done
|
||||
|
||||
$script_dir/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
|
@ -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",
|
||||
|
@ -1,3 +1,5 @@
|
||||
# Config file for service in compose.yml
|
||||
|
||||
[leveldb]
|
||||
mode = "local"
|
||||
url = "http://127.0.0.1:8082/"
|
||||
@ -29,7 +31,7 @@
|
||||
|
||||
[ethereum]
|
||||
chainConfig = "test/ci-chain.json"
|
||||
nodeID = ""
|
||||
clientName = "eth-statediff-service"
|
||||
networkID = 1
|
||||
nodeID = "test-node"
|
||||
clientName = "test-eth-statediff-service"
|
||||
networkID = "test-network"
|
||||
chainID = 41337
|
||||
|
Loading…
Reference in New Issue
Block a user