- test terminating initialization after seeing a certain log line.
(self)
| 45 | self.wait_until(lambda: all(i["synced"] and i["best_block_height"] == height for i in node.getindexinfo().values())) |
| 46 | |
| 47 | def init_stress_test_interrupt(self): |
| 48 | """ |
| 49 | - test terminating initialization after seeing a certain log line. |
| 50 | """ |
| 51 | self.start_node(0) |
| 52 | node = self.nodes[0] |
| 53 | self.generate(node, 200, sync_fun=self.no_op) |
| 54 | self.stop_node(0) |
| 55 | |
| 56 | def sigterm_node(): |
| 57 | if platform.system() == 'Windows': |
| 58 | # Don't call Python's terminate() since it calls |
| 59 | # TerminateProcess(), which unlike SIGTERM doesn't allow |
| 60 | # bitcoind to perform any shutdown logic. |
| 61 | os.kill(node.process.pid, signal.CTRL_BREAK_EVENT) |
| 62 | else: |
| 63 | node.process.terminate() |
| 64 | assert_equal(0, node.process.wait()) |
| 65 | |
| 66 | reindex_log_line = b'Reindexing block file blk00000.dat' |
| 67 | lines_to_terminate_after = [ |
| 68 | b'Validating signatures for all blocks', |
| 69 | b'scheduler thread start', |
| 70 | b'Starting HTTP server', |
| 71 | b'Loading P2P addresses', |
| 72 | b'Loading banlist', |
| 73 | b'Loading block index', |
| 74 | b'Checking all blk files are present', |
| 75 | b'Loaded best chain:', |
| 76 | b'init message: Verifying blocks', |
| 77 | b'init message: Starting network threads', |
| 78 | b'net thread start', |
| 79 | b'addcon thread start', |
| 80 | b'initload thread start', |
| 81 | b'txidx thread start', |
| 82 | b'blkfltbscidx thread start', |
| 83 | b'coinstatsidx thread start', |
| 84 | b'txospenderidx thread start', |
| 85 | b'msghand thread start', |
| 86 | b'net thread start', |
| 87 | b'addcon thread start', |
| 88 | ] |
| 89 | if self.is_wallet_compiled(): |
| 90 | lines_to_terminate_after.append(b'Verifying wallet') |
| 91 | lines_to_terminate_after.append(reindex_log_line) |
| 92 | |
| 93 | for terminate_line in lines_to_terminate_after: |
| 94 | self.log.info(f"Starting node and will terminate after line {terminate_line}") |
| 95 | with node.busy_wait_for_debug_log([terminate_line]): |
| 96 | extra_args = [*ALL_INDEX_ARGS] |
| 97 | if terminate_line == reindex_log_line: |
| 98 | extra_args += ['-reindex'] |
| 99 | if platform.system() == 'Windows': |
| 100 | # CREATE_NEW_PROCESS_GROUP is required in order to be able |
| 101 | # to terminate the child without terminating the test. |
| 102 | node.start(extra_args=extra_args, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP) |
| 103 | else: |
| 104 | node.start(extra_args=extra_args) |
no test coverage detected