From bd8c78e1a3225c77c942ddb65e23e8f355457046 Mon Sep 17 00:00:00 2001 From: Ian Kay Date: Thu, 2 Nov 2023 09:26:47 -0400 Subject: [PATCH] update fixturenet-plugeth test --- .github/workflows/fixturenet-plugeth.yml | 30 +++++++++++ .../triggers/fixturenet-plugeth-test | 3 ++ app/deploy/deploy.py | 2 +- tests/fixturenet-eth-plugeth/run-test.sh | 51 ++++++++++++++++--- 4 files changed, 78 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/fixturenet-plugeth.yml create mode 100644 .github/workflows/triggers/fixturenet-plugeth-test diff --git a/.github/workflows/fixturenet-plugeth.yml b/.github/workflows/fixturenet-plugeth.yml new file mode 100644 index 00000000..f6deacfe --- /dev/null +++ b/.github/workflows/fixturenet-plugeth.yml @@ -0,0 +1,30 @@ +name: Fixturenet-Plugeth Test + +on: + push: + branches: '*' + paths: + - '!**' + - '.github/workflows/triggers/fixturenet-plugeth-test' + +jobs: + test: + name: "Run fixturenet-plugeth test suite" + runs-on: ubuntu-latest + steps: + - name: "Clone project repository" + uses: actions/checkout@v3 + - name: "Install Python" + uses: actions/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: "Run fixturenet-plugeth tests" + run: ./tests/fixturenet-plugeth/run-test.sh diff --git a/.github/workflows/triggers/fixturenet-plugeth-test b/.github/workflows/triggers/fixturenet-plugeth-test new file mode 100644 index 00000000..8041ff09 --- /dev/null +++ b/.github/workflows/triggers/fixturenet-plugeth-test @@ -0,0 +1,3 @@ +Change this file to trigger running the fixturenet-plugeth-test CI job + +trigger diff --git a/app/deploy/deploy.py b/app/deploy/deploy.py index a2d7cc01..ae4d7076 100644 --- a/app/deploy/deploy.py +++ b/app/deploy/deploy.py @@ -151,7 +151,7 @@ def exec_operation(ctx, extra_args): if global_context.verbose: print(f"Running compose exec {service_name} {command_to_exec}") try: - ctx.obj.deployer.execute(service_name, command_to_exec, envs=container_exec_env) + ctx.obj.deployer.execute(service_name, command_to_exec, tty=True, envs=container_exec_env) except DeployerException: print("container command returned error exit status") diff --git a/tests/fixturenet-eth-plugeth/run-test.sh b/tests/fixturenet-eth-plugeth/run-test.sh index 1a961b56..792838a8 100755 --- a/tests/fixturenet-eth-plugeth/run-test.sh +++ b/tests/fixturenet-eth-plugeth/run-test.sh @@ -24,21 +24,58 @@ 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") +# $TEST_TARGET_SO --stack $CERC_STACK_NAME deploy exec fixturenet-eth-bootnode-lighthouse /scripts/status-internal.sh + +timeout=900 # 15 minutes +echo "$(date +"%Y-%m-%d %T"): 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 + echo "$(date +"%Y-%m-%d %T"): Waiting for initial block..." + initial_block_number=$($TEST_TARGET_SO --stack $CERC_STACK_NAME 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 + echo "$(date +"%Y-%m-%d %T"): 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 + echo "$(date +"%Y-%m-%d %T"): Waiting for five blocks or $timeout seconds..." + subsequent_block_number=$($TEST_TARGET_SO --stack $CERC_STACK_NAME 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)) + +echo "$(date +"%Y-%m-%d %T"): 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 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 $CERC_STACK_NAME deploy logs test_result=1 fi -$TEST_TARGET_SO --stack $CERC_STACK_NAME deploy down + +$TEST_TARGET_SO --stack $CERC_STACK_NAME deploy down --delete-volumes echo "Removing cloned repositories" rm -rf $CERC_REPO_BASE_DIR exit $test_result