From 97dc45549d5074b394cd8d29c11a44b0730a5a08 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Thu, 17 Aug 2023 13:24:06 -0600 Subject: [PATCH] Update fixturenet eth test (#506) --- .../workflows/fixturenet-eth-plugeth-test.yml | 36 +++++++++++++++ .gitea/workflows/fixturenet-eth-test.yml | 10 +++++ .gitea/workflows/test.yml | 1 + .../container-build/cerc-lighthouse/build.sh | 2 +- tests/fixturenet-eth-plugeth/run-test.sh | 44 +++++++++++++++++++ tests/fixturenet-eth/run-test.sh | 29 +++++++----- 6 files changed, 111 insertions(+), 11 deletions(-) create mode 100644 .gitea/workflows/fixturenet-eth-plugeth-test.yml create mode 100755 tests/fixturenet-eth-plugeth/run-test.sh diff --git a/.gitea/workflows/fixturenet-eth-plugeth-test.yml b/.gitea/workflows/fixturenet-eth-plugeth-test.yml new file mode 100644 index 00000000..ced0823f --- /dev/null +++ b/.gitea/workflows/fixturenet-eth-plugeth-test.yml @@ -0,0 +1,36 @@ +name: Fixturenet-Eth-Plugeth-Test + +on: + push: + branches: 'ci-test' + +# Needed until we can incorporate docker startup into the executor container +env: + DOCKER_HOST: unix:///var/run/dind.sock + + +jobs: + test: + name: "Run an Ethereum plugeth fixturenet test" + runs-on: ubuntu-latest + steps: + - name: "Clone project repository" + uses: actions/checkout@v3 + - name: "Install Python" + uses: cerc-io/setup-python@v4 + with: + python-version: '3.8' + - name: "Print Python version" + run: python3 --version + - name: "Install shiv" + run: pip install shiv + - name: "Generate build version file" + run: ./scripts/create_build_tag_file.sh + - name: "Build local shiv package" + run: ./scripts/build_shiv_package.sh + - name: Start dockerd # Also needed until we can incorporate into the executor + run: | + dockerd -H $DOCKER_HOST --userland-proxy=false & + sleep 5 + - name: "Run fixturenet-eth tests" + run: ./tests/fixturenet-eth-plugeth/run-test.sh diff --git a/.gitea/workflows/fixturenet-eth-test.yml b/.gitea/workflows/fixturenet-eth-test.yml index 43572c92..5a0410f2 100644 --- a/.gitea/workflows/fixturenet-eth-test.yml +++ b/.gitea/workflows/fixturenet-eth-test.yml @@ -4,6 +4,11 @@ on: push: branches: 'ci-test' +# Needed until we can incorporate docker startup into the executor container +env: + DOCKER_HOST: unix:///var/run/dind.sock + + jobs: test: name: "Run an Ethereum fixturenet test" @@ -23,5 +28,10 @@ jobs: run: ./scripts/create_build_tag_file.sh - name: "Build local shiv package" run: ./scripts/build_shiv_package.sh + - name: Start dockerd # Also needed until we can incorporate into the executor + run: | + dockerd -H $DOCKER_HOST --userland-proxy=false & + sleep 5 - name: "Run fixturenet-eth tests" run: ./tests/fixturenet-eth/run-test.sh + diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index 303b42f4..46c5f937 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -37,3 +37,4 @@ jobs: sleep 5 - name: "Run smoke tests" run: ./tests/smoke-test/run-smoke-test.sh + diff --git a/app/data/container-build/cerc-lighthouse/build.sh b/app/data/container-build/cerc-lighthouse/build.sh index 2e9cfe3c..cdc95612 100755 --- a/app/data/container-build/cerc-lighthouse/build.sh +++ b/app/data/container-build/cerc-lighthouse/build.sh @@ -6,4 +6,4 @@ source ${CERC_CONTAINER_BASE_DIR}/build-base.sh # See: https://stackoverflow.com/a/246128/1701505 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/lighthouse:local ${build_command_args} ${SCRIPT_DIR} +docker build -t cerc/lighthouse:local ${build_command_args} --build-arg TAG_SUFFIX="" ${SCRIPT_DIR} diff --git a/tests/fixturenet-eth-plugeth/run-test.sh b/tests/fixturenet-eth-plugeth/run-test.sh new file mode 100755 index 00000000..1a961b56 --- /dev/null +++ b/tests/fixturenet-eth-plugeth/run-test.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +set -e +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi +set -e +echo "Running stack-orchestrator Ethereum plugeth fixturenet test" +# Bit of a hack, test the most recent package +TEST_TARGET_SO=$( ls -t1 ./package/laconic-so* | head -1 ) +CERC_STACK_NAME=fixturenet-plugeth-tx +# Set a new unique repo dir +export CERC_REPO_BASE_DIR=$(mktemp -d stack-orchestrator-fixturenet-eth-test.XXXXXXXXXX) +echo "Testing this package: $TEST_TARGET_SO" +echo "Test version command" +reported_version_string=$( $TEST_TARGET_SO version ) +echo "Version reported is: ${reported_version_string}" +echo "Cloning repositories into: $CERC_REPO_BASE_DIR" +$TEST_TARGET_SO --stack $CERC_STACK_NAME setup-repositories +echo "Building containers" +$TEST_TARGET_SO --stack $CERC_STACK_NAME build-containers +echo "Images in registry:" +docker image ls +echo "Deploying the cluster" +$TEST_TARGET_SO --stack $CERC_STACK_NAME deploy up +# Verify that the fixturenet is up and running +$TEST_TARGET_SO --stack $CERC_STACK_NAME deploy ps +$TEST_TARGET_SO --stack $CERC_STACK_NAME deploy exec fixturenet-eth-bootnode-lighthouse /scripts/status-internal.sh +initial_block_number=$($TEST_TARGET_SO --stack fixturenet-plugeth-tx deploy exec foundry "cast block-number") +# Check that the block number increases some time later +sleep 12 +subsequent_block_number=$($TEST_TARGET_SO --stack $CERC_STACK_NAME deploy exec foundry "cast block-number") +block_number_difference=$((subsequent_block_number - initial_block_number)) +# Block height difference should be between 1 and some small number +if [[ $block_number_difference -gt 1 && $block_number_difference -lt 10 ]]; then + echo "Test passed" + test_result=0 +else + echo "Test failed: block numbers were ${initial_block_number} and ${subsequent_block_number}" + test_result=1 +fi +$TEST_TARGET_SO --stack $CERC_STACK_NAME deploy down +echo "Removing cloned repositories" +rm -rf $CERC_REPO_BASE_DIR +exit $test_result diff --git a/tests/fixturenet-eth/run-test.sh b/tests/fixturenet-eth/run-test.sh index a7e04030..b5654584 100755 --- a/tests/fixturenet-eth/run-test.sh +++ b/tests/fixturenet-eth/run-test.sh @@ -4,36 +4,45 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then set -x fi -echo "Running stack-orchestrator Ethereum fixturenet test" +echo "$(date +"%Y-%m-%d %T"): Running stack-orchestrator Ethereum fixturenet test" # Bit of a hack, test the most recent package TEST_TARGET_SO=$( ls -t1 ./package/laconic-so* | head -1 ) # Set a new unique repo dir export CERC_REPO_BASE_DIR=$(mktemp -d stack-orchestrator-fixturenet-eth-test.XXXXXXXXXX) -echo "Testing this package: $TEST_TARGET_SO" -echo "Test version command" +echo "$(date +"%Y-%m-%d %T"): Testing this package: $TEST_TARGET_SO" +echo "$(date +"%Y-%m-%d %T"): Test version command" reported_version_string=$( $TEST_TARGET_SO version ) -echo "Version reported is: ${reported_version_string}" -echo "Cloning repositories into: $CERC_REPO_BASE_DIR" -$TEST_TARGET_SO --stack fixturenet-eth setup-repositories +echo "$(date +"%Y-%m-%d %T"): Version reported is: ${reported_version_string}" +echo "$(date +"%Y-%m-%d %T"): Cloning repositories into: $CERC_REPO_BASE_DIR" +$TEST_TARGET_SO --stack fixturenet-eth setup-repositories +echo "$(date +"%Y-%m-%d %T"): Building containers" $TEST_TARGET_SO --stack fixturenet-eth build-containers +echo "$(date +"%Y-%m-%d %T"): Starting stack" $TEST_TARGET_SO --stack fixturenet-eth deploy up +echo "$(date +"%Y-%m-%d %T"): Stack started" # Verify that the fixturenet is up and running $TEST_TARGET_SO --stack fixturenet-eth deploy ps -$TEST_TARGET_SO --stack fixturenet-eth deploy exec fixturenet-eth-bootnode-lighthouse /scripts/status-internal.sh +# echo "$(date +"%Y-%m-%d %T"): Getting stack status" +# $TEST_TARGET_SO --stack fixturenet-eth deploy exec fixturenet-eth-bootnode-lighthouse /scripts/status-internal.sh +echo "$(date +"%Y-%m-%d %T"): Getting initial block number" initial_block_number=$($TEST_TARGET_SO --stack fixturenet-eth deploy exec foundry "cast block-number") # Check that the block number increases some time later -sleep 12 +sleep 120 +echo "$(date +"%Y-%m-%d %T"): Getting subsequent block number" subsequent_block_number=$($TEST_TARGET_SO --stack fixturenet-eth deploy exec foundry "cast block-number") block_number_difference=$((subsequent_block_number - initial_block_number)) # Block height difference should be between 1 and some small number -if [[ $block_number_difference -gt 1 && $block_number_difference -lt 10 ]]; then +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:" + $TEST_TARGET_SO --stack fixturenet-eth deploy logs test_result=1 fi $TEST_TARGET_SO --stack fixturenet-eth deploy down -echo "Removing cloned repositories" +echo "$(date +"%Y-%m-%d %T"): Removing cloned repositories" rm -rf $CERC_REPO_BASE_DIR +echo "$(date +"%Y-%m-%d %T"): Test finished" exit $test_result