mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-11 23:30:05 +02:00
tests: Expand HTTP coverage to assert libevent behavior
Covers: - http pipelining - rpcservertimeout Testing this requires adding an option to TestNode to force the test framework to establish a new HTTP connection for every RPC. Otherwise, attempting to reuse a persistent connection would cause framework RPCs during startup and shutdown to fail. - "chunked" Transfer-Encoding
This commit is contained in:
@@ -75,6 +75,7 @@ class AuthServiceProxy():
|
||||
self.__service_url = service_url
|
||||
self._service_name = service_name
|
||||
self.ensure_ascii = ensure_ascii # can be toggled on the fly by tests
|
||||
self.reuse_http_connections = True
|
||||
self.__url = urllib.parse.urlparse(service_url)
|
||||
user = None if self.__url.username is None else self.__url.username.encode('utf8')
|
||||
passwd = None if self.__url.password is None else self.__url.password.encode('utf8')
|
||||
@@ -92,6 +93,8 @@ class AuthServiceProxy():
|
||||
raise AttributeError
|
||||
if self._service_name is not None:
|
||||
name = "%s.%s" % (self._service_name, name)
|
||||
if not self.reuse_http_connections:
|
||||
self._set_conn()
|
||||
return AuthServiceProxy(self.__service_url, name, connection=self.__conn)
|
||||
|
||||
def _request(self, method, path, postdata):
|
||||
@@ -102,6 +105,8 @@ class AuthServiceProxy():
|
||||
'User-Agent': USER_AGENT,
|
||||
'Authorization': self.__auth_header,
|
||||
'Content-type': 'application/json'}
|
||||
if not self.reuse_http_connections:
|
||||
self._set_conn()
|
||||
self.__conn.request(method, path, postdata, headers)
|
||||
return self._get_response()
|
||||
|
||||
|
||||
@@ -156,6 +156,7 @@ class TestNode():
|
||||
self.process = None
|
||||
self.rpc_connected = False
|
||||
self.rpc = None
|
||||
self.reuse_http_connections = True # Must be set before calling get_rpc_proxy() i.e. before restarting node
|
||||
self.url = None
|
||||
self.log = logging.getLogger('TestFramework.node%d' % i)
|
||||
# Cache perf subprocesses here by their data output filename.
|
||||
@@ -280,6 +281,7 @@ class TestNode():
|
||||
timeout=self.rpc_timeout // 2, # Shorter timeout to allow for one retry in case of ETIMEDOUT
|
||||
coveragedir=self.coverage_dir,
|
||||
)
|
||||
rpc.auth_service_proxy_instance.reuse_http_connections = self.reuse_http_connections
|
||||
rpc.getblockcount()
|
||||
# If the call to getblockcount() succeeds then the RPC connection is up
|
||||
if self.version_is_at_least(190000) and wait_for_import:
|
||||
|
||||
Reference in New Issue
Block a user