compare-snapshots script
add compliance test to ci
This commit is contained in:
parent
b988bf7b59
commit
0baaa39e63
@ -7,9 +7,10 @@ on:
|
||||
branches:
|
||||
- main
|
||||
|
||||
# Needed until we can incorporate docker startup into the executor container
|
||||
env:
|
||||
# Needed until we can incorporate docker startup into the executor container
|
||||
DOCKER_HOST: unix:///var/run/dind.sock
|
||||
CANONICAL_VERSION: v5.0.4-alpha
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
@ -17,6 +18,10 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
check-latest: true
|
||||
- name: Install test fixtures
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
@ -24,15 +29,11 @@ jobs:
|
||||
path: ./fixtures
|
||||
ref: v0.3.1
|
||||
token: ${{ secrets.CICD_REPO_TOKEN }}
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
check-latest: true
|
||||
- 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/'
|
||||
git config --global url."https://$TOKEN:@git.vdb.to/".insteadOf https://git.vdb.to/
|
||||
- name: Build package
|
||||
run: go build .
|
||||
- name: Run unit tests
|
||||
@ -53,6 +54,7 @@ jobs:
|
||||
SNAPSHOT_BLOCK_HEIGHT: 32
|
||||
LEVELDB_PATH: ./fixtures/chaindata/_data/small
|
||||
LEVELDB_ANCIENT: ./fixtures/chaindata/_data/small/ancient
|
||||
ETH_GENESIS_BLOCK: "0x37cbb63c7150a7b60f2878433963ed8ba7e5f82fb2683ec7a945c974e1cf4e05"
|
||||
run: |
|
||||
until
|
||||
ready_query='select max(version_id) from goose_db_version;'
|
||||
@ -72,3 +74,56 @@ jobs:
|
||||
[[ "$(count_results eth.header_cids)" = 1 ]]
|
||||
[[ "$(count_results eth.state_cids)" = 5 ]]
|
||||
[[ "$(count_results eth.storage_cids)" = 13 ]]
|
||||
|
||||
compliance-test:
|
||||
name: Run compliance tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
path: ./ipld-eth-state-snapshot
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version-file: ./ipld-eth-state-snapshot/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: ./ipld-eth-state-snapshot
|
||||
run: go build -o ../snapshot-current .
|
||||
|
||||
- name: Checkout canonical version
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: ./ipld-eth-state-snapshot-canonical
|
||||
ref: ${{ env.CANONICAL_VERSION }}
|
||||
- name: Build canonical version
|
||||
working-directory: ./ipld-eth-state-snapshot-canonical
|
||||
run: go build -o ../snapshot-canonical .
|
||||
|
||||
- name: Run dockerd
|
||||
run: |
|
||||
dockerd -H $DOCKER_HOST --userland-proxy=false &
|
||||
sleep 5
|
||||
- name: Run DB container
|
||||
working-directory: ./ipld-eth-state-snapshot
|
||||
run: docker compose -f test/compose.yml up --wait
|
||||
- name: Compare snapshot output
|
||||
env:
|
||||
SNAPSHOT_MODE: postgres
|
||||
SNAPSHOT_BLOCK_HEIGHT: 200
|
||||
LEVELDB_PATH: ./fixtures/chaindata/_data/small2
|
||||
LEVELDB_ANCIENT: ./fixtures/chaindata/_data/small2/ancient
|
||||
ETH_GENESIS_BLOCK: "0x8a3c7cddacbd1ab4ec1b03805fa2a287f3a75e43d87f4f987fcc399f5c042614"
|
||||
run: |
|
||||
./ipld-eth-state-snapshot/scripts/compare-snapshots.sh \
|
||||
./snapshot-canonical ./snapshot-current
|
||||
|
87
scripts/compare-snapshots.sh
Executable file
87
scripts/compare-snapshots.sh
Executable file
@ -0,0 +1,87 @@
|
||||
#!/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
|
||||
: $SNAPSHOT_BLOCK_HEIGHT
|
||||
: $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 SNAPSHOT_MODE=postgres
|
||||
export SNAPSHOT_WORKERS=32
|
||||
export SNAPSHOT_RECOVERY_FILE='compare-snapshots-recovery.txt'
|
||||
|
||||
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 ETH_CHAIN_ID=4242
|
||||
|
||||
dump_table() {
|
||||
statement="copy (select * from $1) to stdout with csv"
|
||||
docker exec -e PGPASSWORD=password test-ipld-eth-db-1 \
|
||||
psql -q cerc_testing -U vdbm -c "$statement" | sort -u > "$2/$1.csv"
|
||||
}
|
||||
|
||||
clear_table() {
|
||||
docker exec -e PGPASSWORD=password test-ipld-eth-db-1 \
|
||||
psql -q cerc_testing -U vdbm -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
|
||||
|
||||
$binary_A stateSnapshot
|
||||
|
||||
mkdir -p $output_dir/A
|
||||
for table in "${tables[@]}"; do
|
||||
dump_table $table $output_dir/A
|
||||
clear_table $table
|
||||
done
|
||||
|
||||
$binary_B stateSnapshot
|
||||
|
||||
mkdir -p $output_dir/B
|
||||
for table in "${tables[@]}"; do
|
||||
dump_table $table $output_dir/B
|
||||
clear_table $table
|
||||
done
|
||||
|
||||
diff -rs $output_dir/A $output_dir/B
|
Loading…
Reference in New Issue
Block a user