Skip to content

Commit

Permalink
test: Remove python3.5 workaround in authproxy
Browse files Browse the repository at this point in the history
Also, move the burden of checking for a timeout to the client and
disable the timeout on the server. This should avoid intermittent issues
in slow tests (for example mining_getblocktemplate_longpoll.py, or
feature_dbcrash.py), or possibly when the server is running slow (for
example in valgrind).  There shouldn't be any downside in tests caused
by a high rpcservertimeout.
  • Loading branch information
MarcoFalke committed Mar 31, 2023
1 parent 5c2bb2b commit fae66fc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
8 changes: 5 additions & 3 deletions test/functional/feature_dbcrash.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ def set_test_params(self):
self.supports_cli = False

# Set -maxmempool=0 to turn off mempool memory sharing with dbcache
# Set -rpcservertimeout=900 to reduce socket disconnects in this
# long-running test
self.base_args = ["-limitdescendantsize=0", "-maxmempool=0", "-rpcservertimeout=900", "-dbbatchsize=200000"]
self.base_args = [
"-limitdescendantsize=0",
"-maxmempool=0",
"-dbbatchsize=200000",
]

# Set different crash ratios and cache sizes. Note that not all of
# -dbcache goes to the in-memory coins cache.
Expand Down
23 changes: 3 additions & 20 deletions test/functional/test_framework/authproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ def __getattr__(self, name):

def _request(self, method, path, postdata):
'''
Do a HTTP request, with retry if we get disconnected (e.g. due to a timeout).
This is a workaround for https://bugs.python.org/issue3566 which is fixed in Python 3.5.
Do a HTTP request.
'''
headers = {'Host': self.__url.hostname,
'User-Agent': USER_AGENT,
Expand All @@ -106,24 +105,8 @@ def _request(self, method, path, postdata):
# TODO: Find out why the connection would disconnect occasionally and make it reusable on Windows
# Avoid "ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine"
self._set_conn()
try:
self.__conn.request(method, path, postdata, headers)
return self._get_response()
except (BrokenPipeError, ConnectionResetError):
# Python 3.5+ raises BrokenPipeError when the connection was reset
# ConnectionResetError happens on FreeBSD
self.__conn.close()
self.__conn.request(method, path, postdata, headers)
return self._get_response()
except OSError as e:
# Workaround for a bug on macOS. See https://bugs.python.org/issue33450
retry = '[Errno 41] Protocol wrong type for socket' in str(e)
if retry:
self.__conn.close()
self.__conn.request(method, path, postdata, headers)
return self._get_response()
else:
raise
self.__conn.request(method, path, postdata, headers)
return self._get_response()

def get_request(self, *args, **argsn):
AuthServiceProxy.__id_count += 1
Expand Down
2 changes: 2 additions & 0 deletions test/functional/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,8 @@ def write_config(config_path, *, n, chain, extra_config="", disable_autoconnect=
f.write("[{}]\n".format(chain_name_conf_section))
f.write("port=" + str(p2p_port(n)) + "\n")
f.write("rpcport=" + str(rpc_port(n)) + "\n")
# Disable server-side timeouts to avoid intermittent issues
f.write("rpcservertimeout=99000\n")
f.write("rpcdoccheck=1\n")
f.write("fallbackfee=0.0002\n")
f.write("server=1\n")
Expand Down

0 comments on commit fae66fc

Please sign in to comment.