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

Add retry and timeout in unit test #1504

Closed
wants to merge 1 commit into from
Closed
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
20 changes: 14 additions & 6 deletions plenum/test/consensus/view_change/test_sim_view_change.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from collections import Counter
from functools import partial

import time

import pytest

from plenum.common.messages.internal_messages import NeedViewChange
Expand Down Expand Up @@ -38,7 +40,7 @@ def test_view_change_completes_under_normal_conditions_regression_seeds(seed, la
check_view_change_completes_under_normal_conditions(random, *latency, *filter)


def test_view_change_permutations(random):
def test_view_change_permutations(random: SimRandom):
# Create pool in some random initial state
pool, _ = some_pool(random)
quorums = pool.nodes[0]._data.quorums
Expand All @@ -62,7 +64,7 @@ def test_view_change_permutations(random):
assert len(cps) == 1

# ToDo: this test fails on seeds {440868, 925547, 444939}
def test_new_view_combinations(random):
def test_new_view_combinations(random: SimRandom):
# Create pool in some random initial state
pool, _ = some_pool(random)
quorums = pool.nodes[0]._data.quorums
Expand All @@ -77,10 +79,16 @@ def test_new_view_combinations(random):

# Check that all committed requests are present in final batches
for _ in range(10):
num_votes = quorums.strong.value
votes = random.sample(view_change_messages, num_votes)

cp = pool.nodes[0]._view_changer._new_view_builder.calc_checkpoint(votes)
cp = None
j = 0
while j < 20 and not cp:
num_votes = quorums.strong.value
votes = random.sample(view_change_messages, num_votes)

cp = pool.nodes[0]._view_changer._new_view_builder.calc_checkpoint(votes)
if not cp:
j = j + 1
time.sleep(0.5)
assert cp is not None

batches = pool.nodes[0]._view_changer._new_view_builder.calc_batches(cp, votes)
Expand Down