Skip to content

Commit

Permalink
Do not use allowed-none to isolate as it does not allow future connect
Browse files Browse the repository at this point in the history
  • Loading branch information
linh2931 committed Oct 3, 2024
1 parent f5ef651 commit 8dc0d62
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions tests/nodeos_snapshot_diff_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,32 +155,33 @@ def waitForBlock(node, blockNum, blockType=BlockType.head, timeout=None, reportI
Utils.processSpringUtilCmd("snapshot to-json --input-file {}".format(snapshotFile), "snapshot to-json", silentErrors=False)
snapshotFile = snapshotFile + ".json"

Print("Trim programmable blocklog to snapshot head block num and relaunch programmable node")
nodeProg.kill(signal.SIGTERM)
output=cluster.getBlockLog(progNodeId, blockLogAction=BlockLogAction.trim, first=0, last=ret_head_block_num, throwException=True)
nodeProg.removeState()
nodeProg.rmFromCmd('--p2p-peer-address')

# There is a race condition that at the startup of node, net thread and http
# thread can start to work in different order. If http thread processes schedule_snapshot
# request after net thread starts to sync with the irrNode, schedule_snapshot
# request will miss the scheduled block number. If it is before net thread
# starts to sync with the irrNode, schedule_snapshot request will catch the
# scheduled block number and the snapshot is taken.
#
# "--allowed-connection none" is for isolating the node such that net thread
# does not initiate sync at the startup.
# "--plugin eosio::net_api_plugin" is for handling net connet request.
addSwapFlags={"--allowed-connection": "none", "--plugin": "eosio::net_api_plugin"}

isRelaunchSuccess = nodeProg.relaunch(chainArg="--replay", addSwapFlags=addSwapFlags, timeout=relaunchTimeout)
# Shut down irreversible node so that nodeProg won't sync up when starting up
Print("Kill irreversible node")
nodeIrr.kill(signal.SIGTERM)

Print("Trim programmable blocklog to snapshot head block num and relaunch programmable node")
nodeProg.kill(signal.SIGTERM)
output=cluster.getBlockLog(progNodeId, blockLogAction=BlockLogAction.trim, first=0, last=ret_head_block_num, throwException=True)
nodeProg.removeState()
nodeProg.rmFromCmd('--p2p-peer-address')

isRelaunchSuccess = nodeProg.relaunch(chainArg="--replay", addSwapFlags={}, timeout=relaunchTimeout)
assert isRelaunchSuccess, "Failed to relaunch programmable node"

Print("Schedule snapshot (node 2)")
ret = nodeProg.scheduleSnapshotAt(ret_head_block_num)
assert ret is not None, "Snapshot scheduling failed"

nodeProg.processUrllibRequest("net", "connect", "localhost:9877")
# Start irreversible node so that nodeProg can sync up with it
Print("Restart irreversible node")
nodeIrr.relaunch()

Print("Wait for programmable node lib to advance")
waitForBlock(nodeProg, ret_head_block_num, blockType=BlockType.lib)
Expand Down

0 comments on commit 8dc0d62

Please sign in to comment.