Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Add automated test (python) for irreversible mode #6843

Merged
merged 11 commits into from
Mar 6, 2019
5 changes: 4 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ target_include_directories( plugin_test PUBLIC
${CMAKE_SOURCE_DIR}/plugins/net_plugin/include
${CMAKE_SOURCE_DIR}/plugins/chain_plugin/include
${CMAKE_BINARY_DIR}/unittests/include/ )

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/core_symbol.py.in ${CMAKE_CURRENT_BINARY_DIR}/core_symbol.py)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testUtils.py ${CMAKE_CURRENT_BINARY_DIR}/testUtils.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/WalletMgr.py ${CMAKE_CURRENT_BINARY_DIR}/WalletMgr.py COPYONLY)
Expand All @@ -40,6 +40,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nodeos_run_test.py ${CMAKE_CURRENT_BI
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nodeos_run_remote_test.py ${CMAKE_CURRENT_BINARY_DIR}/nodeos_run_remote_test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nodeos_under_min_avail_ram.py ${CMAKE_CURRENT_BINARY_DIR}/nodeos_under_min_avail_ram.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nodeos_voting_test.py ${CMAKE_CURRENT_BINARY_DIR}/nodeos_voting_test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nodeos_irreversible_mode_test.py ${CMAKE_CURRENT_BINARY_DIR}/nodeos_irreversible_mode_test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/consensus-validation-malicious-producers.py ${CMAKE_CURRENT_BINARY_DIR}/consensus-validation-malicious-producers.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/validate-dirty-db.py ${CMAKE_CURRENT_BINARY_DIR}/validate-dirty-db.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/launcher_test.py ${CMAKE_CURRENT_BINARY_DIR}/launcher_test.py COPYONLY)
Expand Down Expand Up @@ -104,6 +105,8 @@ set_property(TEST nodeos_voting_bnet_lr_test PROPERTY LABELS long_running_tests)
add_test(NAME nodeos_under_min_avail_ram_lr_test COMMAND tests/nodeos_under_min_avail_ram.py -v --wallet-port 9904 --clean-run --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST nodeos_under_min_avail_ram_lr_test PROPERTY LABELS long_running_tests)

add_test(NAME nodeos_irreversible_mode_lr_test COMMAND tests/nodeos_irreversible_mode_test.py -v --clean-run --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST nodeos_irreversible_mode_lr_test PROPERTY LABELS long_running_tests)

if(ENABLE_COVERAGE_TESTING)

Expand Down
13 changes: 8 additions & 5 deletions tests/Cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def launch(self, pnodes=1, totalNodes=1, prodCount=1, topo="mesh", p2pPlugin="ne
producerNodes={}
producers=[]
for append in range(ord('a'),ord('a')+numProducers):
name="defproducer" + chr(append)
name="defproducer" + chr(append)
producers.append(name)

# first group starts at 0
Expand Down Expand Up @@ -440,7 +440,7 @@ def waitOnClusterSync(self, timeout=None, blockType=BlockType.head, blockAdvanci
assert(len(self.nodes) > 0)
node=self.nodes[0]
targetBlockNum=node.getBlockNum(blockType) #retrieve node 0's head or irrevercible block number
targetBlockNum+=blockAdvancing
targetBlockNum+=blockAdvancing
if Utils.Debug:
Utils.Print("%s block number on root node: %d" % (blockType.type, targetBlockNum))
if targetBlockNum == -1:
Expand Down Expand Up @@ -1430,7 +1430,7 @@ def getInfos(self, silentErrors=False, exitOnError=False):
def reportStatus(self):
if hasattr(self, "biosNode") and self.biosNode is not None:
self.biosNode.reportStatus()
if hasattr(self, "nodes"):
if hasattr(self, "nodes"):
for node in self.nodes:
try:
node.reportStatus()
Expand Down Expand Up @@ -1523,10 +1523,10 @@ def identifyCommon(blockLogs, blockNameExtensions, first, last):
commonBlockLogs=[]
commonBlockNameExtensions=[]
for i in range(numNodes):
if (len(blockLogs[i]) >= last):
if (len(blockLogs[i]) >= last):
commonBlockLogs.append(blockLogs[i][first:last])
commonBlockNameExtensions.append(blockNameExtensions[i])
return (commonBlockLogs,commonBlockNameExtensions)
return (commonBlockLogs,commonBlockNameExtensions)

# compare the contents of the blockLogs for the given common block number span
def compareCommon(blockLogs, blockNameExtensions, first, last):
Expand Down Expand Up @@ -1567,3 +1567,6 @@ def stripValues(lowestMaxes,greaterThan):
first=lowestMaxes[0]+1
lowestMaxes=stripValues(lowestMaxes,lowestMaxes[0])

@staticmethod
def getDataDir(nodeId):
return os.path.abspath(os.path.join(Cluster.__dataDir, "node_%02d" % (nodeId)))
14 changes: 11 additions & 3 deletions tests/Node.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def getEosAccount(self, name, exitOnError=False, returnType=ReturnType.json, avo
msg="( getEosAccount(name=%s) )" % (name);
return self.processCleosCmd(cmd, cmdDesc, silentErrors=False, exitOnError=exitOnError, exitMsg=msg, returnType=returnType)
else:
assert returnType == ReturnType.json, "MongoDB only supports a returnType of ReturnType.json"
assert returnType == ReturnType.json, "MongoDB only supports a returnType of ReturnType.json"
return self.getEosAccountFromDb(name, exitOnError=exitOnError)

def getEosAccountFromDb(self, name, exitOnError=False):
Expand Down Expand Up @@ -1198,9 +1198,13 @@ def kill(self, killSignal):
if Utils.Debug: Utils.Print("Killing node: %s" % (self.cmd))
assert(self.pid is not None)
try:
os.kill(self.pid, killSignal)
if self.popenProc is not None:
self.popenProc.send_signal(killSignal)
self.popenProc.wait()
else:
os.kill(self.pid, killSignal)
except OSError as ex:
Utils.Print("ERROR: Failed to kill node (%d)." % (self.cmd), ex)
Utils.Print("ERROR: Failed to kill node (%s)." % (self.cmd), ex)
return False

# wait for kill validation
Expand Down Expand Up @@ -1360,6 +1364,10 @@ def isNodeAlive():
Utils.Print("Node relaunch was successfull.")
else:
Utils.Print("ERROR: Node relaunch Failed.")
# Ensure the node process is really killed
if self.popenProc:
self.popenProc.send_signal(signal.SIGTERM)
self.popenProc.wait()
self.pid=None
return False

Expand Down
Loading