コード例 #1
0
def test_view_change_no_propagate_primary_on_master(replica, tconf):
    ppSeqNo = 100
    replica.isMaster = True
    replica._primaryName = 'SomeNode'
    # next calls emulate simple view_change procedure (replica's watermark related steps)
    emulate_catchup(replica, ppSeqNo)
    emulate_select_primaries(replica)
    assert replica.h == ppSeqNo
    assert replica.H == ppSeqNo + tconf.LOG_SIZE
コード例 #2
0
def test_view_change_no_propagate_primary_on_backup(replica, tconf):
    ppSeqNo = 100
    replica.isMaster = False
    replica._consensus_data.primary_name = 'SomeNode'
    # next calls emulate simple view_change procedure (replica's watermark related steps)
    emulate_catchup(replica, ppSeqNo)
    emulate_select_primaries(replica)
    assert replica.h == 0
    assert replica.H == sys.maxsize
コード例 #3
0
def test_catchup_without_during_vc_with_primary_on_master(replica, tconf):
    # this test emulate situation of simple catchup procedure without view_change
    # (by checkpoints or ledger_statuses)
    ppSeqNo = 100
    replica._primaryName = 'SomeNode'
    replica.isMaster = True
    emulate_catchup(replica, ppSeqNo)
    assert replica.last_ordered_3pc == (replica.viewNo, 100)
    assert replica.h == ppSeqNo
    assert replica.H == ppSeqNo + tconf.LOG_SIZE
コード例 #4
0
def test_catchup_without_during_vc_with_primary_on_master(replica, tconf):
    # this test emulate situation of simple catchup procedure without view_change
    # (by checkpoints or ledger_statuses)
    ppSeqNo = 100
    replica._primaryName = 'SomeNode'
    replica.isMaster = True
    emulate_catchup(replica, ppSeqNo)
    assert replica.last_ordered_3pc == (replica.viewNo, 100)
    assert replica.h == ppSeqNo
    assert replica.H == ppSeqNo + tconf.LOG_SIZE
コード例 #5
0
def test_catchup_without_during_vc_with_primary_on_backup(replica):
    # this test emulate situation of simple catchup procedure without view_change
    # (by checkpoints or ledger_statuses)
    ppSeqNo = 100
    replica._primaryName = 'SomeNode'
    replica.isMaster = False
    emulate_catchup(replica, ppSeqNo)
    assert replica.last_ordered_3pc == (replica.viewNo, 0)
    assert replica.h == 0
    assert replica.H == sys.maxsize
コード例 #6
0
def test_catchup_without_during_vc_with_primary_on_backup(replica):
    # this test emulate situation of simple catchup procedure without view_change
    # (by checkpoints or ledger_statuses)
    ppSeqNo = 100
    replica._primaryName = 'SomeNode'
    replica.isMaster = False
    emulate_catchup(replica, ppSeqNo)
    assert replica.last_ordered_3pc == (replica.viewNo, 0)
    assert replica.h == 0
    assert replica.H == sys.maxsize
コード例 #7
0
def test_view_change_propagate_primary_on_backup(replica):
    ppSeqNo = 100
    replica.isMaster = False
    replica._primaryName = 'SomeNode'
    # next calls emulate view_change for propagate primary situation
    # (when the new node join to the pool)
    emulate_catchup(replica, ppSeqNo)
    emulate_select_primaries(replica)
    replica.on_propagate_primary_done()
    assert replica.h == 0
    assert replica.H == sys.maxsize
コード例 #8
0
def test_view_change_propagate_primary_on_master(replica, tconf):
    ppSeqNo = 100
    replica.isMaster = True
    replica._primaryName = 'SomeNode'
    # next calls emulate view_change for propagate primary situation
    # (when the new node join to the pool)
    emulate_catchup(replica, ppSeqNo)
    emulate_select_primaries(replica)
    replica.on_propagate_primary_done()
    assert replica.h == ppSeqNo
    assert replica.H == ppSeqNo + tconf.LOG_SIZE
コード例 #9
0
def test_catchup_without_vc_and_no_primary_on_backup(replica, tconf):
    ppSeqNo = 100
    replica.isMaster = False
    replica._consensus_data.primary_name = None
    # next calls emulate a catchup without vc when there is no primary selected
    # like it will be called for 'update watermark' procedure
    emulate_catchup(replica, ppSeqNo)
    # select_primaries after allLedgersCaughtUp
    emulate_select_primaries(replica)
    assert replica.h == 0
    assert replica.H == sys.maxsize
コード例 #10
0
def test_catchup_without_vc_and_no_primary_on_master(replica, tconf):
    ppSeqNo = 100
    replica.isMaster = True
    replica._primaryName = None
    # next calls emulate a catchup without vc when there is no primary selected
    # like it will be called for 'update watermark' procedure
    emulate_catchup(replica, ppSeqNo)
    # select_primaries after allLedgersCaughtUp
    emulate_select_primaries(replica)
    assert replica.h == ppSeqNo
    assert replica.H == ppSeqNo + tconf.LOG_SIZE
コード例 #11
0
def test_view_change_propagate_primary_on_backup(replica):
    ppSeqNo = 100
    replica.isMaster = False
    replica._primaryName = 'SomeNode'
    # next calls emulate view_change for propagate primary situation
    # (when the new node join to the pool)
    emulate_catchup(replica, ppSeqNo)
    emulate_select_primaries(replica)
    replica.on_propagate_primary_done()
    assert replica.h == 0
    assert replica.H == sys.maxsize
コード例 #12
0
def test_view_change_propagate_primary_on_master(replica, tconf):
    ppSeqNo = 100
    replica.isMaster = True
    replica._primaryName = 'SomeNode'
    # next calls emulate view_change for propagate primary situation
    # (when the new node join to the pool)
    emulate_catchup(replica, ppSeqNo)
    emulate_select_primaries(replica)
    replica.on_propagate_primary_done()
    assert replica.h == ppSeqNo
    assert replica.H == ppSeqNo + tconf.LOG_SIZE
コード例 #13
0
def test_view_change_no_propagate_primary_on_backup(replica, tconf):
    ppSeqNo = 100
    replica.isMaster = False
    replica._primaryName = 'SomeNode'
    # next calls emulate simple view_change procedure (replica's watermark related steps)
    emulate_catchup(replica, ppSeqNo)
    emulate_select_primaries(replica)
    if replica.viewNo > 0:
        assert replica.h == 0
        assert replica.H == tconf.LOG_SIZE
    else:
        assert replica.h == 0
        assert replica.H == sys.maxsize
コード例 #14
0
def test_view_change_no_propagate_primary_on_backup(replica, tconf):
    ppSeqNo = 100
    replica.isMaster = False
    replica._primaryName = 'SomeNode'
    # next calls emulate simple view_change procedure (replica's watermark related steps)
    emulate_catchup(replica, ppSeqNo)
    emulate_select_primaries(replica)
    if replica.viewNo > 0:
        assert replica.h == 0
        assert replica.H == tconf.LOG_SIZE
    else:
        assert replica.h == 0
        assert replica.H == sys.maxsize
コード例 #15
0
def test_catchup_without_vc_and_no_primary_on_backup(replica, tconf):
    ppSeqNo = 100
    replica.isMaster = False
    replica._primaryName = None
    # next calls emulate a catchup without vc when there is no primary selected
    # like it will be called for 'update watermark' procedure
    emulate_catchup(replica, ppSeqNo)
    # select_primaries after allLedgersCaughtUp
    emulate_select_primaries(replica)
    if replica.viewNo > 0:
        assert replica.h == 0
        assert replica.H == tconf.LOG_SIZE
    else:
        assert replica.h == 0
        assert replica.H == sys.maxsize
コード例 #16
0
def test_catchup_without_during_vc_with_primary_on_backup(replica):
    # this test emulate situation of simple catchup procedure without view_change
    # (by checkpoints or ledger_statuses)
    caughtup_pp_seq_no = 100
    current_pp_seq_no = 50
    replica._ordering_service.last_ordered_3pc = (replica.viewNo,
                                                  current_pp_seq_no)
    replica._ordering_service.first_batch_after_catchup = False
    replica._consensus_data.primary_name = 'SomeNode'
    replica._consensus_data._name = "SomeAnotherNode"
    replica.isMaster = False
    emulate_catchup(replica, caughtup_pp_seq_no)
    assert replica.last_ordered_3pc == (replica.viewNo, current_pp_seq_no)
    assert replica.h == 0
    assert replica.H == sys.maxsize
    assert replica._ordering_service.first_batch_after_catchup
コード例 #17
0
def test_unstash_catchup(replica, msg):
    pre_prepare, _ = msg
    replica.stasher._stash(STASH_CATCH_UP, "reason", *msg)
    assert replica.stasher.stash_size(STASH_CATCH_UP) > 0
    emulate_catchup(replica)
    assert replica.stasher.stash_size(STASH_CATCH_UP) == 0