Browse Source

Merge #8744: [0.13.1] qa Backports

d6ebe13 [qa] Refactor RPCTestHandler to prevent TimeoutExpired (MarcoFalke)
ae8c7df [qa] create_cache: Delete temp dir when done (MarcoFalke)
63462c2 [qa] remove root test directory for RPC tests (whythat)
0.13
Wladimir J. van der Laan 8 years ago
parent
commit
8d9e8adc05
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 14
      qa/pull-tester/rpc-tests.py
  2. 10
      qa/rpc-tests/create_cache.py
  3. 5
      qa/rpc-tests/test_framework/test_framework.py
  4. 6
      qa/rpc-tests/wallet-hd.py

14
qa/pull-tester/rpc-tests.py

@ -248,21 +248,27 @@ class RPCTestHandler:
self.num_running += 1 self.num_running += 1
t = self.test_list.pop(0) t = self.test_list.pop(0)
port_seed = ["--portseed=%s" % len(self.test_list)] port_seed = ["--portseed=%s" % len(self.test_list)]
log_stdout = tempfile.SpooledTemporaryFile(max_size=2**16)
log_stderr = tempfile.SpooledTemporaryFile(max_size=2**16)
self.jobs.append((t, self.jobs.append((t,
time.time(), time.time(),
subprocess.Popen((RPC_TESTS_DIR + t).split() + self.flags + port_seed, subprocess.Popen((RPC_TESTS_DIR + t).split() + self.flags + port_seed,
universal_newlines=True, universal_newlines=True,
stdout=subprocess.PIPE, stdout=log_stdout,
stderr=subprocess.PIPE))) stderr=log_stderr),
log_stdout,
log_stderr))
if not self.jobs: if not self.jobs:
raise IndexError('pop from empty list') raise IndexError('pop from empty list')
while True: while True:
# Return first proc that finishes # Return first proc that finishes
time.sleep(.5) time.sleep(.5)
for j in self.jobs: for j in self.jobs:
(name, time0, proc) = j (name, time0, proc, log_out, log_err) = j
if proc.poll() is not None: if proc.poll() is not None:
(stdout, stderr) = proc.communicate(timeout=3) log_out.seek(0), log_err.seek(0)
[stdout, stderr] = [l.read().decode('utf-8') for l in (log_out, log_err)]
log_out.close(), log_err.close()
passed = stderr == "" and proc.returncode == 0 passed = stderr == "" and proc.returncode == 0
self.num_running -= 1 self.num_running -= 1
self.jobs.remove(j) self.jobs.remove(j)

10
qa/rpc-tests/create_cache.py

@ -12,9 +12,15 @@ from test_framework.test_framework import BitcoinTestFramework
class CreateCache(BitcoinTestFramework): class CreateCache(BitcoinTestFramework):
def __init__(self):
super().__init__()
# Test network and test nodes are not required:
self.num_nodes = 0
self.nodes = []
def setup_network(self): def setup_network(self):
# Don't setup any test nodes pass
self.options.noshutdown = True
def run_test(self): def run_test(self):
pass pass

5
qa/rpc-tests/test_framework/test_framework.py

@ -123,7 +123,8 @@ class BitcoinTestFramework(object):
self.add_options(parser) self.add_options(parser)
(self.options, self.args) = parser.parse_args() (self.options, self.args) = parser.parse_args()
self.options.tmpdir += '/' + str(self.options.port_seed) # backup dir variable for removal at cleanup
self.options.root, self.options.tmpdir = self.options.tmpdir, self.options.tmpdir + '/' + str(self.options.port_seed)
if self.options.trace_rpc: if self.options.trace_rpc:
logging.basicConfig(level=logging.DEBUG, stream=sys.stdout) logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)
@ -174,6 +175,8 @@ class BitcoinTestFramework(object):
if not self.options.nocleanup and not self.options.noshutdown and success: if not self.options.nocleanup and not self.options.noshutdown and success:
print("Cleaning up") print("Cleaning up")
shutil.rmtree(self.options.tmpdir) shutil.rmtree(self.options.tmpdir)
if not os.listdir(self.options.root):
os.rmdir(self.options.root)
else: else:
print("Not cleaning up dir %s" % self.options.tmpdir) print("Not cleaning up dir %s" % self.options.tmpdir)

6
qa/rpc-tests/wallet-hd.py

@ -39,8 +39,8 @@ class WalletHDTest(BitcoinTestFramework):
self.nodes[1].importprivkey(self.nodes[0].dumpprivkey(non_hd_add)) self.nodes[1].importprivkey(self.nodes[0].dumpprivkey(non_hd_add))
# This should be enough to keep the master key and the non-HD key # This should be enough to keep the master key and the non-HD key
self.nodes[1].backupwallet(tmpdir + "hd.bak") self.nodes[1].backupwallet(tmpdir + "/hd.bak")
#self.nodes[1].dumpwallet(tmpdir + "hd.dump") #self.nodes[1].dumpwallet(tmpdir + "/hd.dump")
# Derive some HD addresses and remember the last # Derive some HD addresses and remember the last
# Also send funds to each add # Also send funds to each add
@ -63,7 +63,7 @@ class WalletHDTest(BitcoinTestFramework):
print("Restore backup ...") print("Restore backup ...")
self.stop_node(1) self.stop_node(1)
os.remove(self.options.tmpdir + "/node1/regtest/wallet.dat") os.remove(self.options.tmpdir + "/node1/regtest/wallet.dat")
shutil.copyfile(tmpdir + "hd.bak", tmpdir + "/node1/regtest/wallet.dat") shutil.copyfile(tmpdir + "/hd.bak", tmpdir + "/node1/regtest/wallet.dat")
self.nodes[1] = start_node(1, self.options.tmpdir, self.node_args[1]) self.nodes[1] = start_node(1, self.options.tmpdir, self.node_args[1])
#connect_nodes_bi(self.nodes, 0, 1) #connect_nodes_bi(self.nodes, 0, 1)

Loading…
Cancel
Save