コード例 #1
0
 def issue_historical_queries_with_snapshot(network, snapshot_tx_interval):
     network.txs.issue(network, number_txs=1)
     for _ in range(1, snapshot_tx_interval):
         network.txs.issue(network, number_txs=1, repeat=True)
         last_tx = network.txs.get_last_tx(priv=True)
         try:
             network.wait_for_snapshot_committed_for(
                 seqno=last_tx[1]["seqno"])
             break
         except TimeoutError:
             continue
コード例 #2
0
ファイル: recovery.py プロジェクト: jumaffre/CCF
def check_snapshots(args, network):
    primary, _ = network.find_primary()
    seqno = find_recovery_tx_seqno(primary)

    if seqno:
        # Check that primary node has produced a snapshot. The wait timeout is larger than the
        # signature interval, so the snapshots should become available within the timeout.
        assert args.sig_ms_interval < 3000
        if not network.wait_for_snapshot_committed_for(
                seqno, timeout=3, on_all_nodes=True):
            raise ValueError(
                f"No snapshot found after seqno={seqno} on primary {primary.local_node_id}"
            )
コード例 #3
0
def test_add_node_from_snapshot(
    network, args, copy_ledger_read_only=True, from_backup=False
):
    # Before adding the node from a snapshot, override at least one app entry
    # and wait for a new committed snapshot covering that entry, so that there
    # is at least one historical entry to verify.
    network.txs.issue(network, number_txs=1)
    for _ in range(1, args.snapshot_tx_interval):
        network.txs.issue(network, number_txs=1, repeat=True)
        last_tx = network.txs.get_last_tx(priv=True)
        if network.wait_for_snapshot_committed_for(seqno=last_tx[1]["seqno"]):
            break

    target_node = None
    snapshots_dir = None
    if from_backup:
        primary, target_node = network.find_primary_and_any_backup()
        # Retrieve snapshot from primary as only primary node
        # generates snapshots
        snapshots_dir = network.get_committed_snapshots(primary)

    new_node = network.create_node("local://localhost")
    network.join_node(
        new_node,
        args.package,
        args,
        copy_ledger_read_only=copy_ledger_read_only,
        target_node=target_node,
        snapshots_dir=snapshots_dir,
        from_snapshot=True,
    )
    network.trust_node(new_node, args)

    with new_node.client() as c:
        r = c.get("/node/state")
        assert (
            r.body.json()["startup_seqno"] != 0
        ), "Node started from snapshot but reports startup seqno of 0"

    # Finally, verify all app entries on the new node, including historical ones
    # from the historical ledger
    network.txs.verify(node=new_node, include_historical=copy_ledger_read_only)

    return network