Skip to content

Commit

Permalink
A0-3474: Recovery test after abft update included in nightly (#1488)
Browse files Browse the repository at this point in the history
### Description
Added `test_recover_after_abft_update` to the e2e logic nightly
pipeline. Changed printing to logging in the test.
### Testing
Successfully ran the new `nightly-e2e-logic-tests` pipeline ->
[run](https://github.com/Cardinal-Cryptography/aleph-node/actions/runs/6863083818)
  • Loading branch information
woocash2 authored Nov 14, 2023
1 parent 6450c81 commit 3c1c12d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 17 deletions.
27 changes: 24 additions & 3 deletions .github/workflows/nightly-e2e-logic-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,29 @@ jobs:
needs: [build-test-node-image-and-e2e-client-image]
uses: ./.github/workflows/_run-e2e-tests.yml

check-e2e-test-suite-completion:
needs: [run-e2e-tests]
run-recover-after-abft-update-test:
needs: [build-test-node-and-runtime]
name: Run recovery test after abft update
runs-on: [self-hosted, Linux, X64, medium]
steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Download release artifact
uses: actions/download-artifact@v3
with:
name: aleph-test-node
path: target/release/

- name: Run test
timeout-minutes: 15
run: |
./.github/scripts/test_python_general.sh \
--aleph-node ../target/release/aleph-node \
--testcase test_recover_after_abft_update
check-nightly-pipeline-completion:
needs: [run-e2e-tests, run-recover-after-abft-update-test]
name: Check e2e test suite completion
if: ${{ !cancelled() }}
runs-on: ubuntu-20.04
Expand All @@ -42,7 +63,7 @@ jobs:
slack-notification:
name: Slack notification
runs-on: ubuntu-20.04
needs: [check-e2e-test-suite-completion]
needs: [check-nightly-pipeline-completion]
if: >
!cancelled() &&
github.event_name != 'workflow_dispatch'
Expand Down
30 changes: 16 additions & 14 deletions local-tests/test_recover_after_abft_update.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#!/bin/env python
import os
from os.path import abspath, join
from time import ctime, sleep
from time import sleep
from chainrunner import Chain, Seq, generate_keys


def printt(s): print(ctime() + ' | ' + s)

import logging

'''
Make sure to compile the binary with --features short_session
Make sure to compile the aleph-node project with --features short_session
'''

logging.basicConfig(
level=logging.INFO,
format='%(asctime)s %(levelname)-8s %(message)s',
)

# Path to working directory, where chainspec, logs and nodes' dbs are written:
workdir = abspath(os.getenv('WORKDIR', '/tmp/workdir'))
# Path to the aleph-node binary.
Expand All @@ -20,8 +22,8 @@ def printt(s): print(ctime() + ' | ' + s)
phrases = [f'//{i}' for i in range(8)]
keys = generate_keys(binary, phrases)
chain = Chain(workdir)
printt('Bootstrapping the chain with binary')

logging.info('Bootstrapping the chain with binary')
chain.bootstrap(binary,
keys.values(),
sudo_account_id=keys[phrases[0]],
Expand All @@ -41,29 +43,29 @@ def printt(s): print(ctime() + ' | ' + s)
BLOCKS_PER_STAGE = 180
chain.set_flags_validator('validator')

printt('Starting the chain')
logging.info('Starting the chain')
chain.start('aleph')

chain.wait_for_finalization(10, catchup=True, catchup_delta=5) # run normally for short time
chain.wait_for_finalization(0, finalized_delta=10, catchup=True, catchup_delta=5) # run normally for short time

result = chain.nodes[0].update_finality_version(session=3, sudo_phrase='//0') # update will happen at block 90
assert result.is_success

chain.wait_for_finalization(BLOCKS_PER_STAGE, catchup=True, catchup_delta=5) # run normally for around 1 session after updating abft
chain.wait_for_finalization(0, finalized_delta=BLOCKS_PER_STAGE, catchup=True, catchup_delta=5) # run normally for around 1 session after updating abft

printt('Stopping all nodes')
logging.info('Stopping all nodes')
chain.stop(nodes=range(8))

sleep(10)

printt('Starting all nodes except one')
logging.info('Starting all nodes except one')
chain.start('aleph-recovered', nodes=range(7)) # restart all except the last

f1 = chain.get_highest_finalized()
assert f1 >= BLOCKS_PER_STAGE

chain.wait_for_finalization(2 * BLOCKS_PER_STAGE, catchup=True, catchup_delta=5, nodes=range(7))
chain.wait_for_finalization(0, finalized_delta=2 * BLOCKS_PER_STAGE, catchup=True, catchup_delta=5, nodes=range(7))
f2 = chain.get_highest_finalized(nodes=range(7))
assert f2 >= 2 * BLOCKS_PER_STAGE

print('Ok')
logging.info('Ok')

0 comments on commit 3c1c12d

Please sign in to comment.