aboutsummaryrefslogtreecommitdiff
path: root/qa/rpc-tests
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2017-02-24 17:02:38 -0500
committerJohn Newbery <john@johnnewbery.com>2017-03-09 09:26:48 -0500
commit2a9c7c74dc557a0a1d8ef11b783aa134a00fe484 (patch)
tree3ec409efddbfdc97173b2c468e78868ce6fc972a /qa/rpc-tests
parentb0dec4a04a2d9415bfb4996404900e2c173b41d0 (diff)
downloadbitcoin-2a9c7c74dc557a0a1d8ef11b783aa134a00fe484.tar.xz
Use logging in test_framework/util.py
Diffstat (limited to 'qa/rpc-tests')
-rw-r--r--qa/rpc-tests/test_framework/util.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py
index c22e57bcef..23ac324510 100644
--- a/qa/rpc-tests/test_framework/util.py
+++ b/qa/rpc-tests/test_framework/util.py
@@ -19,12 +19,15 @@ import tempfile
import time
import re
import errno
+import logging
from . import coverage
from .authproxy import AuthServiceProxy, JSONRPCException
COVERAGE_DIR = None
+logger = logging.getLogger("TestFramework.utils")
+
# The maximum number of nodes a single test can spawn
MAX_NODES = 8
# Don't assign rpc or p2p ports lower than this
@@ -237,6 +240,7 @@ def initialize_chain(test_dir, num_nodes, cachedir):
break
if create_cache:
+ logger.debug("Creating data directories from cached datadir")
#find and delete old cache directories if any exist
for i in range(MAX_NODES):
@@ -250,11 +254,9 @@ def initialize_chain(test_dir, num_nodes, cachedir):
if i > 0:
args.append("-connect=127.0.0.1:"+str(p2p_port(0)))
bitcoind_processes[i] = subprocess.Popen(args)
- if os.getenv("PYTHON_DEBUG", ""):
- print("initialize_chain: bitcoind started, waiting for RPC to come up")
+ logger.debug("initialize_chain: bitcoind started, waiting for RPC to come up")
wait_for_bitcoind_start(bitcoind_processes[i], rpc_url(i), i)
- if os.getenv("PYTHON_DEBUG", ""):
- print("initialize_chain: RPC successfully started")
+ logger.debug("initialize_chain: RPC successfully started")
rpcs = []
for i in range(MAX_NODES):
@@ -316,12 +318,10 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=
args = [ binary, "-datadir="+datadir, "-server", "-keypool=1", "-discover=0", "-rest", "-logtimemicros", "-debug", "-mocktime="+str(get_mocktime()) ]
if extra_args is not None: args.extend(extra_args)
bitcoind_processes[i] = subprocess.Popen(args, stderr=stderr)
- if os.getenv("PYTHON_DEBUG", ""):
- print("start_node: bitcoind started, waiting for RPC to come up")
+ logger.debug("initialize_chain: bitcoind started, waiting for RPC to come up")
url = rpc_url(i, rpchost)
wait_for_bitcoind_start(bitcoind_processes[i], url, i)
- if os.getenv("PYTHON_DEBUG", ""):
- print("start_node: RPC successfully started")
+ logger.debug("initialize_chain: RPC successfully started")
proxy = get_rpc_proxy(url, i, timeout=timewait)
if COVERAGE_DIR:
@@ -367,10 +367,11 @@ def log_filename(dirname, n_node, logname):
return os.path.join(dirname, "node"+str(n_node), "regtest", logname)
def stop_node(node, i):
+ logger.debug("Stopping node %d" % i)
try:
node.stop()
except http.client.CannotSendRequest as e:
- print("WARN: Unable to stop node: " + repr(e))
+ logger.exception("Unable to stop node")
return_code = bitcoind_processes[i].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT)
assert_equal(return_code, 0)
del bitcoind_processes[i]