feat(ci): run 2x dev nodes for automated-testing (#5346)

This commit is contained in:
Max Revitt 2022-12-09 13:07:57 +00:00 committed by GitHub
parent 5c05ff4c2a
commit ebea8298df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 158 additions and 0 deletions

View File

@ -127,3 +127,13 @@ jobs:
# check with root permissions, should be cached from previous build
- name: sudo make docker
run: sudo DOCKER_TAG=thorax/erigon:ci-$GITHUB_SHA DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) make docker
automated-tests:
runs-on:
ubuntu-20.04
if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
steps:
- uses: actions/checkout@v3
- name: run automated testing
run: BUILD_ERIGON=1 ./tests/automated-testing/run.sh

View File

@ -281,6 +281,11 @@ hive:
docker pull thorax/hive:latest
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(OUTPUT_DIR):/work thorax/hive:latest --sim $(SIM) --results-root=/work/results --client erigon_ci-local # run erigon
## automated-tests run automated tests (BUILD_ERIGON=0 to prevent erigon build with local image tag)
.PHONY: automated-tests
automated-tests:
./tests/automated-testing/run.sh
## help: print commands help
help : Makefile
@sed -n 's/^##//p' $<

3
tests/automated-testing/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
results/
logdir/
*.log

View File

@ -0,0 +1,64 @@
version: "3.8"
services:
erigon:
profiles:
- first
image: thorax/erigon:$ERIGON_TAG
command: |
erigon --datadir=/home/erigon/.local/share/erigon --chain=dev --private.api.addr=0.0.0.0:9090 --mine --log.dir.path=/logs/node1
ports:
- "8551:8551"
volumes:
- datadir:/home/erigon/.local/share/erigon
- ./logdir:/logs
user: ${DOCKER_UID}:${DOCKER_GID}
restart: unless-stopped
mem_swappiness: 0
erigon-node2:
profiles:
- second
image: thorax/erigon:$ERIGON_TAG
command: |
erigon --datadir=/home/erigon/.local/share/erigon --chain=dev --private.api.addr=0.0.0.0:9090 --staticpeers=$ENODE --log.dir.path=/logs/node2
volumes:
- datadir2:/home/erigon/.local/share/erigon
- ./logdir:/logs
user: ${DOCKER_UID}:${DOCKER_GID}
restart: unless-stopped
mem_swappiness: 0
rpcdaemon:
profiles:
- first
image: thorax/erigon:$ERIGON_TAG
command: |
rpcdaemon --private.api.addr=erigon:9090 --http.api=admin,eth,erigon,web3,net,debug,trace,txpool,parity --http.addr=0.0.0.0 --http.vhosts=* --http.corsdomain=* --http.port=8545 --log.dir.path=/logs/node1
volumes:
- ./logdir:/logs
user: ${DOCKER_UID}:${DOCKER_GID}
ports: [ "8545:8545" ]
rpcdaemon-node2:
profiles:
- second
image: thorax/erigon:$ERIGON_TAG
command: |
rpcdaemon --private.api.addr=erigon-node2:9090 --http.api=admin,eth,erigon,web3,net,debug,trace,txpool,parity --http.addr=0.0.0.0 --http.vhosts=* --http.corsdomain=* --http.port=8545 --log.dir.path=/logs/node2
volumes:
- ./logdir:/logs
user: ${DOCKER_UID}:${DOCKER_GID}
ports: [ "8546:8545" ]
tests:
profiles: [ "tests" ]
image: thorax/automated-testing
volumes:
- ./results:/erigon-automated-testing/results
entrypoint: |
pytest -m smoke_test --quiet --junitxml="./results/result.xml" --url="http://rpcdaemon:8545" --tb=line
volumes:
datadir:
datadir2:

70
tests/automated-testing/run.sh Executable file
View File

@ -0,0 +1,70 @@
#!/bin/bash
function stopContainers () {
# stop containers
echo "stopping containers..."
docker-compose --profile=first down -v --remove-orphans
docker-compose --profile=second down -v --remove-orphans
}
ORIGINAL_DIR=$(pwd)
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd "$SCRIPT_DIR" || exit
#export DOCKER_UID=1000
#export DOCKER_GID=1000
# set GITHUB_SHA
if [ -z "$GITHUB_SHA" ]; then
export GITHUB_SHA=local
fi
echo "GITHUB_SHA=$GITHUB_SHA"
# set ERIGON_TAG
if [ -z "$ERIGON_TAG" ]; then
export ERIGON_TAG=ci-$GITHUB_SHA
fi
echo "ERIGON_TAG=$ERIGON_TAG"
# set BUILD_ERIGON
if [ -z "$BUILD_ERIGON" ]; then
export BUILD_ERIGON=0
fi
echo "BUILD_ERIGON=$BUILD_ERIGON"
if [ "$BUILD_ERIGON" = 1 ] ; then
echo "building erigon..."
cd ../../ && DOCKER_TAG=thorax/erigon:$ERIGON_TAG DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) make docker
fi
# move back to the script directory
cd "$SCRIPT_DIR" || exit
# pull container images
echo "pulling container images..."
docker compose pull
# run node 1
echo "starting node 1..."
docker-compose --profile=first up -d --force-recreate --remove-orphans
# wait for node 1 to start up
echo "waiting for node 1 to start up..."
sleep 10
# run node 2
echo "starting node 2..."
export ENODE=$(./scripts/enode.sh)
docker-compose --profile=second up -d --force-recreate --remove-orphans
# wait for node 2 to start up
echo "waiting for node 2 to start up..."
sleep 10
# run tests!
echo "running tests..."
docker compose run --rm tests || { echo 'tests failed'; stopContainers; exit 1; }
stopContainers
cd "$ORIGINAL_DIR" || exit

View File

@ -0,0 +1,6 @@
#!/bin/bash
set -e
TARGET_RESPONSE=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"admin_nodeInfo","params":[],"id":1}' "127.0.0.1:8545" )
echo ${TARGET_RESPONSE}| jq -r '.result.enode' | sed 's/127.0.0.1/erigon/g' | sed 's/?discport=0//g'