diff --git a/tests/TestHarness/Node.py b/tests/TestHarness/Node.py index 8cfab82bac..5061673219 100644 --- a/tests/TestHarness/Node.py +++ b/tests/TestHarness/Node.py @@ -708,37 +708,39 @@ def countInLog(self, searchStr) -> int: count += contents.count(searchStr) return count - # verify only one or two 'Starting block' per block number unless block is restarted + # Verify that we have only one "Starting block" in the log for any block number unless: + # - the block was restarted because it was exhausted, + # - or the second "Starting block" is for a different block time than the first. + # ------------------------------------------------------------------------------------- def verifyStartingBlockMessages(self): dataDir=Utils.getNodeDataDir(self.nodeId) files=Node.findStderrFiles(dataDir) + restarting_exhausted_regexp = re.compile(r"Restarting exhausted speculative block #(\d+)") + starting_block_regexp = re.compile(r"Starting block #(\d+) .*(\d\d:\d\d\.\d\d\d) producer") + for f in files: - blockNumbers = set() - duplicateBlockNumbers = set() - threeStartsFound = False - lastRestartBlockNum = 0 - blockNumber = 0 + notRestartedBlockNumbersAndTimes = {} + duplicateStartFound = False with open(f, 'r') as file: for line in file: - match = re.match(r".*Restarting exhausted speculative block #(\d+)", line) + match = restarting_exhausted_regexp.match(line) if match: - lastRestartBlockNum = match.group(1) - continue - if re.match(r".*unlinkable_block_exception", line): - lastRestartBlockNum = blockNumber + # remove restarted block + notRestartedBlockNumbersAndTimes.pop(match.group(1), None) continue - match = re.match(r".*Starting block #(\d+)", line) + match = starting_block_regexp.match(line) if match: - blockNumber = match.group(1) - if blockNumber != lastRestartBlockNum and blockNumber in duplicateBlockNumbers: - print(f"Duplicate Staring block found: {blockNumber} in {f}") - threeStartsFound = True - if blockNumber != lastRestartBlockNum and blockNumber in blockNumbers: - duplicateBlockNumbers.add(blockNumber) - blockNumbers.add(blockNumber) - - return not threeStartsFound + blockNumber, time = match.group(1), match.group(2) + if blockNumber in notRestartedBlockNumbersAndTimes and notRestartedBlockNumbersAndTimes[blockNumber] == time: + print(f"Duplicate Starting block found: {blockNumber} in {f}") + duplicateStartFound = True + break + notRestartedBlockNumbersAndTimes[blockNumber] = time + if duplicateStartFound: + break + + return not duplicateStartFound def analyzeProduction(self, specificBlockNum=None, thresholdMs=500): dataDir=Utils.getNodeDataDir(self.nodeId)