Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A0-1923: add e2e tests for pruning #914

Merged
merged 3 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/e2e-tests-main-devnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
- name: GIT | Checkout source code
uses: actions/checkout@v2

- name: Install Rust toolchain
- name: Install Rust toolchainrun_e2e_testrun_e2e_test
maciejnems marked this conversation as resolved.
Show resolved Hide resolved
uses: actions-rs/toolchain@v1

- name: Install Protoc
Expand Down Expand Up @@ -796,6 +796,9 @@ jobs:
name: Test catching up
runs-on: ubuntu-20.04
needs: build-new-node
strategy:
matrix:
pruning: ['', '--state-pruning 90']
steps:
- name: Checkout source code
uses: actions/checkout@v2
Expand All @@ -815,12 +818,15 @@ jobs:
env:
# Relative to local-tests/ directory
ALEPH_NODE_BINARY: aleph-test-node/aleph-node
run: ./.github/scripts/test_catch_up.sh
run: ./.github/scripts/test_catch_up.sh ${{ matrix.pruning }}

test-multiple-restarts:
name: Test multiple restarts
runs-on: ubuntu-20.04
needs: build-new-node
strategy:
matrix:
pruning: ['', '--state-pruning 2048']
steps:
- name: Checkout source code
uses: actions/checkout@v2
Expand All @@ -840,7 +846,7 @@ jobs:
env:
# Relative to local-tests/ directory
ALEPH_NODE_BINARY: aleph-release-node/aleph-node
run: ./.github/scripts/test_multiple_restarts.sh
run: ./.github/scripts/test_multiple_restarts.sh ${{ matrix.pruning }}

check-runtime-change:
name: Inspect whether runtime version has been changed (compared with main)
Expand Down
3 changes: 1 addition & 2 deletions local-tests/run_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
unit_creation_delay=500,
execution='Native',
rpc_cors='all',
rpc_methods='Unsafe',
state_pruning='archive')
rpc_methods='Unsafe')
addresses = [n.address() for n in chain]
chain.set_flags(bootnodes=addresses[0], public_addr=addresses)

Expand Down
22 changes: 17 additions & 5 deletions local-tests/test_catch_up.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
import sys
from os.path import abspath, join
from time import sleep, ctime
import argparse

from chainrunner import Chain, Seq, generate_keys, check_finalized


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


argParser = argparse.ArgumentParser()
argParser.add_argument("--state-pruning", help="state pruning argument")
state_pruning = argParser.parse_args().state_pruning

# 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 (important use short-session feature):
Expand All @@ -23,19 +30,24 @@ def printt(s): print(ctime() + ' | ' + s)
nonvalidators=all_accounts[4:],
sudo_account_id=keys[phrases[0]],
chain_type='local')
printt('Purging previous chain')
chain.purge()

chain.set_flags('no-mdns',
port=Seq(30334),
validator_port=Seq(30343),
ws_port=Seq(9944),
rpc_port=Seq(9933),
unit_creation_delay=200,
execution='Native',
state_pruning='archive')
execution='Native')
addresses = [n.address() for n in chain]
validator_addresses = [n.validator_address() for n in chain]
chain.set_flags(bootnodes=addresses[0])
chain.set_flags_validator(public_addr=addresses, public_validator_addresses=validator_addresses)
chain.set_flags_validator(public_addr=addresses,
public_validator_addresses=validator_addresses)
if state_pruning is not None:
chain.set_flags('experimental-pruning', state_pruning=state_pruning,
)

chain.set_flags_validator('validator')

Expand All @@ -46,10 +58,10 @@ def printt(s): print(ctime() + ' | ' + s)

chain.start('aleph', nodes=[4, 5])

printt('Waiting for finalization')
chain.wait_for_finalization(0)
printt('Waiting for authorities')
chain.wait_for_authorities()
printt('Waiting for finalization')
chain.wait_for_finalization(90)
maciejnems marked this conversation as resolved.
Show resolved Hide resolved

printt('Killing one validator and one nonvalidator')
chain.stop(nodes=[3, 4])
Expand Down
27 changes: 20 additions & 7 deletions local-tests/test_multiple_restarts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
import sys
from os.path import abspath, join
from time import sleep, ctime
import argparse

from chainrunner import Chain, Seq, generate_keys, check_finalized


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


argParser = argparse.ArgumentParser()
argParser.add_argument("--state-pruning", help="state pruning argument")
state_pruning = argParser.parse_args().state_pruning

# 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 (important DON'T use short-session feature):
Expand All @@ -22,28 +29,34 @@ def printt(s): print(ctime() + ' | ' + s)
sudo_account_id=keys[phrases[0]],
chain_type='local')

printt('Purging previous chain')
chain.purge()

chain.set_flags('no-mdns',
port=Seq(30334),
validator_port=Seq(30343),
ws_port=Seq(9944),
rpc_port=Seq(9933),
unit_creation_delay=200,
execution='Native',
state_pruning='archive')
execution='Native')
addresses = [n.address() for n in chain]
validator_addresses = [n.validator_address() for n in chain]
chain.set_flags(bootnodes=addresses[0])
chain.set_flags_validator(public_addr=addresses, public_validator_addresses=validator_addresses)
chain.set_flags_validator(public_addr=addresses,
public_validator_addresses=validator_addresses)
if state_pruning is not None:
chain.set_flags('experimental-pruning', state_pruning=state_pruning,
)

chain.set_flags_validator('validator')

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

printt('Waiting for finalization')
chain.wait_for_finalization(0)
printt('Waiting for authorities')
chain.wait_for_authorities()
printt('Waiting for finalization')
chain.wait_for_finalization(256)
maciejnems marked this conversation as resolved.
Show resolved Hide resolved

delta = 5

Expand All @@ -63,7 +76,7 @@ def printt(s): print(ctime() + ' | ' + s)
sys.exit(1)

printt('Restarting nodes')
chain[3].start('aleph')
chain.start('aleph', nodes=[3])

printt('Waiting for finalization')
chain.wait_for_finalization(finalized_before_start[3], nodes=[3])
Expand All @@ -73,5 +86,5 @@ def printt(s): print(ctime() + ' | ' + s)

# Check if the murdered node started catching up with reasonable nr of blocks.
if diff <= delta:
printt(f'Too small catch up for validators: {validator_diff}')
maciejnems marked this conversation as resolved.
Show resolved Hide resolved
printt(f'Too small catch up for validators: {diff}')
sys.exit(1)