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 all commits
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
10 changes: 8 additions & 2 deletions .github/workflows/e2e-tests-main-devnet.yml
Original file line number Diff line number Diff line change
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
20 changes: 17 additions & 3 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 @@ -30,12 +37,15 @@ def printt(s): print(ctime() + ' | ' + s)
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 @@ -50,6 +60,10 @@ def printt(s): print(ctime() + ' | ' + s)
chain.wait_for_finalization(0)
printt('Waiting for authorities')
chain.wait_for_authorities()
if state_pruning is not None and state_pruning.isnumeric():
bound = min(256, int(state_pruning))
printt(f'Pruning turned on. Waiting for {bound} blocks to finalize')
chain.wait_for_finalization(bound)

printt('Killing one validator and one nonvalidator')
chain.stop(nodes=[3, 4])
Expand Down
24 changes: 19 additions & 5 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 @@ -28,12 +35,15 @@ def printt(s): print(ctime() + ' | ' + s)
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 @@ -44,6 +54,10 @@ def printt(s): print(ctime() + ' | ' + s)
chain.wait_for_finalization(0)
printt('Waiting for authorities')
chain.wait_for_authorities()
if state_pruning is not None and state_pruning.isnumeric():
bound = min(256, int(state_pruning))
printt(f'Pruning turned on. Waiting for {bound} blocks to finalize')
chain.wait_for_finalization(bound)

delta = 5

Expand All @@ -63,7 +77,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 +87,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)