Add CI test #3
37
.gitea/workflows/fixturenet-eth-stack.yml
Normal file
37
.gitea/workflows/fixturenet-eth-stack.yml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
name: Ethereum Fixturenet Stack Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: '*'
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- ci-test
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: "Run Ethereum Fixturenet stack test"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: "Clone project repository"
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
# At present the stock setup-python action fails on Linux/aarch64
|
||||||
|
# Conditional steps below workaroud this by using deadsnakes for that case only
|
||||||
|
- name: "Install Python for ARM on Linux"
|
||||||
|
if: ${{ runner.arch == 'arm64' && runner.os == 'Linux' }}
|
||||||
|
uses: deadsnakes/action@v3.0.1
|
||||||
|
with:
|
||||||
|
python-version: '3.8'
|
||||||
|
- name: "Install Python cases other than ARM on Linux"
|
||||||
|
if: ${{ ! (runner.arch == 'arm64' && runner.os == 'Linux') }}
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.8'
|
||||||
|
- name: "Print Python version"
|
||||||
|
run: python3 --version
|
||||||
|
- name: "Install stack orchestrator"
|
||||||
|
run: ./scripts/install-so.sh
|
||||||
|
- name: "Run stack tests"
|
||||||
|
run: |
|
||||||
|
PATH=$PATH:~/bin
|
||||||
|
./tests/fixturenet-eth-stack/run-test.sh
|
@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
Experimental external packaging of the Ethereum fixturenet stack.
|
Experimental external packaging of the Ethereum fixturenet stack.
|
||||||
|
|
||||||
[stack documentation](stacks/fixturenet-eth/README.md)
|
[stack documentation](stack-orchestrator/stacks/fixturenet-eth/README.md)
|
||||||
|
5
scripts/install-so.sh
Executable file
5
scripts/install-so.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
mkdir ~/bin
|
||||||
|
curl -L -o ~/bin/laconic-so https://git.vdb.to/cerc-io/stack-orchestrator/releases/download/latest/laconic-so
|
||||||
|
chmod +x ~/bin/laconic-so
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
services:
|
services:
|
||||||
foundry:
|
foundry:
|
||||||
restart: always
|
restart: always
|
||||||
image: cerc/foundry:local
|
image: ghcr.io/foundry-rs/foundry:latest
|
||||||
command: ["while :; do sleep 600; done"]
|
command: ["while :; do sleep 600; done"]
|
||||||
volumes:
|
volumes:
|
||||||
- ../config/foundry/foundry.toml:/foundry.toml
|
- ../config/foundry/foundry.toml:/foundry.toml
|
||||||
|
@ -4,7 +4,6 @@ description: "Ethereum Fixturenet"
|
|||||||
repos:
|
repos:
|
||||||
- git.vdb.to/cerc-io/go-ethereum@v1.11.6-statediff-v5
|
- git.vdb.to/cerc-io/go-ethereum@v1.11.6-statediff-v5
|
||||||
- git.vdb.to/cerc-io/lighthouse
|
- git.vdb.to/cerc-io/lighthouse
|
||||||
- github.com/dboreham/foundry
|
|
||||||
containers:
|
containers:
|
||||||
- cerc/go-ethereum
|
- cerc/go-ethereum
|
||||||
- cerc/lighthouse
|
- cerc/lighthouse
|
||||||
@ -12,7 +11,6 @@ containers:
|
|||||||
- cerc/fixturenet-eth-genesis
|
- cerc/fixturenet-eth-genesis
|
||||||
- cerc/fixturenet-eth-geth
|
- cerc/fixturenet-eth-geth
|
||||||
- cerc/fixturenet-eth-lighthouse
|
- cerc/fixturenet-eth-lighthouse
|
||||||
- cerc/foundry
|
|
||||||
pods:
|
pods:
|
||||||
- fixturenet-eth
|
- fixturenet-eth
|
||||||
- foundry
|
- foundry
|
||||||
|
116
tests/fixturenet-eth-stack/run-test.sh
Executable file
116
tests/fixturenet-eth-stack/run-test.sh
Executable file
@ -0,0 +1,116 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
|
||||||
|
SO_COMMAND=laconic-so
|
||||||
|
|
||||||
|
test_name="Fixturenet eth stack deploy test"
|
||||||
|
echo "Running ${test_name}"
|
||||||
|
|
||||||
|
stack_name=$(pwd)/stack-orchestrator/stacks/fixturenet-eth
|
||||||
|
|
||||||
|
test_fail_exit () {
|
||||||
|
local fail_message=$1
|
||||||
|
echo "${test_name}: ${fail_message}"
|
||||||
|
echo "${test_name}: FAILED"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
log_info () {
|
||||||
|
local message=$1
|
||||||
|
echo "$(date +"%Y-%m-%d %T"): ${message}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Sanity check the stack dir exists
|
||||||
|
if [ ! -d "${stack_name}" ]; then
|
||||||
|
test_fail_exit "stack directory not present"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set a non-default repo dir
|
||||||
|
export CERC_REPO_BASE_DIR=~/stack-orchestrator-test/repo-base-dir
|
||||||
|
reported_version_string=$( $SO_COMMAND version )
|
||||||
|
echo "SO version is: ${reported_version_string}"
|
||||||
|
echo "Cloning repositories into: $CERC_REPO_BASE_DIR"
|
||||||
|
rm -rf $CERC_REPO_BASE_DIR
|
||||||
|
mkdir -p $CERC_REPO_BASE_DIR
|
||||||
|
|
||||||
|
$SO_COMMAND --stack ${stack_name} setup-repositories
|
||||||
|
|
||||||
|
echo "Building containers"
|
||||||
|
$SO_COMMAND --stack ${stack_name} build-containers
|
||||||
|
|
||||||
|
test_deployment_dir=$CERC_REPO_BASE_DIR/test-deployment-dir
|
||||||
|
test_deployment_spec=$CERC_REPO_BASE_DIR/test-deployment-spec.yml
|
||||||
|
|
||||||
|
$SO_COMMAND --stack ${stack_name} deploy init --output $test_deployment_spec
|
||||||
|
# Check the file now exists
|
||||||
|
if [ ! -f "$test_deployment_spec" ]; then
|
||||||
|
test_fail_exit "deploy init test: spec fille not present"
|
||||||
|
fi
|
||||||
|
echo "deploy init test: passed"
|
||||||
|
|
||||||
|
$SO_COMMAND --stack ${stack_name} deploy create --spec-file $test_deployment_spec --deployment-dir $test_deployment_dir
|
||||||
|
# Check the deployment dir exists
|
||||||
|
if [ ! -d "$test_deployment_dir" ]; then
|
||||||
|
test_fail_exit "deploy create test: deployment directory not present"
|
||||||
|
fi
|
||||||
|
echo "deploy create test: passed"
|
||||||
|
|
||||||
|
$SO_COMMAND deployment --dir $test_deployment_dir start
|
||||||
|
|
||||||
|
timeout=900 # 15 minutes
|
||||||
|
log_info "Getting initial block number. Timeout set to $timeout seconds"
|
||||||
|
start_time=$(date +%s)
|
||||||
|
elapsed_time=0
|
||||||
|
initial_block_number=0
|
||||||
|
while [ "$initial_block_number" -eq 0 ] && [ $elapsed_time -lt $timeout ]; do
|
||||||
|
sleep 10
|
||||||
|
log_info "Waiting for initial block..."
|
||||||
|
initial_block_number=$($SO_COMMAND --stack fixturenet-eth deploy exec foundry "cast block-number")
|
||||||
|
current_time=$(date +%s)
|
||||||
|
elapsed_time=$((current_time - start_time))
|
||||||
|
done
|
||||||
|
|
||||||
|
subsequent_block_number=$initial_block_number
|
||||||
|
|
||||||
|
# if initial block was 0 after timeout, assume chain did not start successfully and skip finding subsequent block
|
||||||
|
if [[ $initial_block_number -gt 0 ]]; then
|
||||||
|
timeout=300
|
||||||
|
log_info "Getting subsequent block number. Timeout set to $timeout seconds"
|
||||||
|
start_time=$(date +%s)
|
||||||
|
elapsed_time=0
|
||||||
|
# wait for 5 blocks or timeout
|
||||||
|
while [ "$subsequent_block_number" -le $((initial_block_number + 5)) ] && [ $elapsed_time -lt $timeout ]; do
|
||||||
|
sleep 10
|
||||||
|
log_info "Waiting for five blocks or $timeout seconds..."
|
||||||
|
subsequent_block_number=$($SO_COMMAND --stack fixturenet-eth deploy exec foundry "cast block-number")
|
||||||
|
current_time=$(date +%s)
|
||||||
|
elapsed_time=$((current_time - start_time))
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# will return 0 if either of the above loops timed out
|
||||||
|
block_number_difference=$((subsequent_block_number - initial_block_number))
|
||||||
|
|
||||||
|
log_info "Results of block height queries:"
|
||||||
|
echo "Initial block height: $initial_block_number"
|
||||||
|
echo "Subsequent block height: $subsequent_block_number"
|
||||||
|
|
||||||
|
# Block height difference should be between 1 and some small number
|
||||||
|
if [[ $block_number_difference -gt 1 && $block_number_difference -lt 100 ]]; then
|
||||||
|
echo "Test passed"
|
||||||
|
test_result=0
|
||||||
|
else
|
||||||
|
echo "Test failed: block numbers were ${initial_block_number} and ${subsequent_block_number}"
|
||||||
|
echo "Logs from stack:"
|
||||||
|
$SO_COMMAND --stack fixturenet-eth deploy logs
|
||||||
|
test_result=1
|
||||||
|
fi
|
||||||
|
$SO_COMMAND deployment --dir $test_deployment_dir stop --delete-volumes
|
||||||
|
log_info "Removing cloned repositories"
|
||||||
|
rm -rf $CERC_REPO_BASE_DIR
|
||||||
|
log_info "Test finished"
|
||||||
|
exit $test_result
|
Loading…
Reference in New Issue
Block a user