Skip to content

Commit fad8cf6

Browse files
author
MarcoFalke
committed
[qa] Use single cache dir for chains
1 parent fa2d68f commit fad8cf6

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,9 @@ linux-build
103103
win32-build
104104
qa/pull-tester/run-bitcoind-for-test.sh
105105
qa/pull-tester/tests_config.py
106-
qa/pull-tester/cache/*
107106
qa/pull-tester/test.*/*
108107
qa/tmp
109-
cache/
108+
qa/cache/*
110109
share/BitcoindComparisonTool.jar
111110

112111
!src/leveldb*/Makefile

qa/pull-tester/rpc-tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ def runtests():
192192
coverage = RPCCoverage()
193193
print("Initializing coverage directory at %s\n" % coverage.dir)
194194
flags = ["--srcdir=%s/src" % BUILDDIR] + passon_args
195+
flags.append("--cachedir=%s/qa/cache" % BUILDDIR)
195196
if coverage:
196197
flags.append(coverage.flag)
197198

qa/rpc-tests/test_framework/test_framework.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def setup_chain(self):
4747
if self.setup_clean_chain:
4848
initialize_chain_clean(self.options.tmpdir, self.num_nodes)
4949
else:
50-
initialize_chain(self.options.tmpdir, self.num_nodes)
50+
initialize_chain(self.options.tmpdir, self.num_nodes, self.options.cachedir)
5151

5252
def setup_nodes(self):
5353
return start_nodes(self.num_nodes, self.options.tmpdir)
@@ -108,6 +108,8 @@ def main(self):
108108
help="Don't stop bitcoinds after the test execution")
109109
parser.add_option("--srcdir", dest="srcdir", default=os.path.normpath(os.path.dirname(os.path.realpath(__file__))+"/../../../src"),
110110
help="Source directory containing bitcoind/bitcoin-cli (default: %default)")
111+
parser.add_option("--cachedir", dest="cachedir", default=os.path.normpath(os.path.dirname(os.path.realpath(__file__))+"/../../cache"),
112+
help="Directory for caching pregenerated datadirs")
111113
parser.add_option("--tmpdir", dest="tmpdir", default=tempfile.mkdtemp(prefix="test"),
112114
help="Root directory for datadirs")
113115
parser.add_option("--tracerpc", dest="trace_rpc", default=False, action="store_true",

qa/rpc-tests/test_framework/util.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def wait_for_bitcoind_start(process, url, i):
193193
raise # unkown JSON RPC exception
194194
time.sleep(0.25)
195195

196-
def initialize_chain(test_dir, num_nodes):
196+
def initialize_chain(test_dir, num_nodes, cachedir):
197197
"""
198198
Create a cache of a 200-block-long chain (with wallet) for MAX_NODES
199199
Afterward, create num_nodes copies from the cache
@@ -202,20 +202,20 @@ def initialize_chain(test_dir, num_nodes):
202202
assert num_nodes <= MAX_NODES
203203
create_cache = False
204204
for i in range(MAX_NODES):
205-
if not os.path.isdir(os.path.join('cache', 'node'+str(i))):
205+
if not os.path.isdir(os.path.join(cachedir, 'node'+str(i))):
206206
create_cache = True
207207
break
208208

209209
if create_cache:
210210

211211
#find and delete old cache directories if any exist
212212
for i in range(MAX_NODES):
213-
if os.path.isdir(os.path.join("cache","node"+str(i))):
214-
shutil.rmtree(os.path.join("cache","node"+str(i)))
213+
if os.path.isdir(os.path.join(cachedir,"node"+str(i))):
214+
shutil.rmtree(os.path.join(cachedir,"node"+str(i)))
215215

216216
# Create cache directories, run bitcoinds:
217217
for i in range(MAX_NODES):
218-
datadir=initialize_datadir("cache", i)
218+
datadir=initialize_datadir(cachedir, i)
219219
args = [ os.getenv("BITCOIND", "bitcoind"), "-server", "-keypool=1", "-datadir="+datadir, "-discover=0" ]
220220
if i > 0:
221221
args.append("-connect=127.0.0.1:"+str(p2p_port(0)))
@@ -257,13 +257,13 @@ def initialize_chain(test_dir, num_nodes):
257257
wait_bitcoinds()
258258
disable_mocktime()
259259
for i in range(MAX_NODES):
260-
os.remove(log_filename("cache", i, "debug.log"))
261-
os.remove(log_filename("cache", i, "db.log"))
262-
os.remove(log_filename("cache", i, "peers.dat"))
263-
os.remove(log_filename("cache", i, "fee_estimates.dat"))
260+
os.remove(log_filename(cachedir, i, "debug.log"))
261+
os.remove(log_filename(cachedir, i, "db.log"))
262+
os.remove(log_filename(cachedir, i, "peers.dat"))
263+
os.remove(log_filename(cachedir, i, "fee_estimates.dat"))
264264

265265
for i in range(num_nodes):
266-
from_dir = os.path.join("cache", "node"+str(i))
266+
from_dir = os.path.join(cachedir, "node"+str(i))
267267
to_dir = os.path.join(test_dir, "node"+str(i))
268268
shutil.copytree(from_dir, to_dir)
269269
initialize_datadir(test_dir, i) # Overwrite port/rpcport in bitcoin.conf

0 commit comments

Comments
 (0)