mirror of
https://github.com/aljazceru/plugins.git
synced 2025-12-23 16:14:20 +01:00
summary: logs PeerThred activity to debug
This will eliminate a potential flakyness of the tests because we can use that log as a marker to wait for the PeerThread.
This commit is contained in:
@@ -46,6 +46,7 @@ class PeerThread(threading.Thread):
|
|||||||
rpcpeers = plugin.rpc.listpeers()
|
rpcpeers = plugin.rpc.listpeers()
|
||||||
trace_availability(plugin, rpcpeers)
|
trace_availability(plugin, rpcpeers)
|
||||||
plugin.persist.sync()
|
plugin.persist.sync()
|
||||||
|
plugin.log("[PeerThread] Peerstate availability persisted and synced. Sleeping now..." , 'debug')
|
||||||
time.sleep(plugin.avail_interval)
|
time.sleep(plugin.avail_interval)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
plugin.log("[PeerThread] " + str(ex), 'warn')
|
plugin.log("[PeerThread] " + str(ex), 'warn')
|
||||||
|
|||||||
@@ -25,16 +25,16 @@ def get_stub():
|
|||||||
|
|
||||||
|
|
||||||
def test_summary_peer_thread(node_factory):
|
def test_summary_peer_thread(node_factory):
|
||||||
# in order to give the PeerThread a chance in a unit test
|
# Set a low PeerThread interval so we can test quickly.
|
||||||
# we need to give it a low interval
|
opts = {'summary-availability-interval': 0.5}
|
||||||
opts = {'summary-availability-interval': 0.1}
|
|
||||||
opts.update(pluginopt)
|
opts.update(pluginopt)
|
||||||
l1, l2 = node_factory.line_graph(2, opts=opts)
|
l1, l2 = node_factory.line_graph(2, opts=opts)
|
||||||
|
|
||||||
# when
|
# when
|
||||||
s1 = l1.rpc.summary()
|
s1 = l1.rpc.summary()
|
||||||
l2.stop() # we stop l2 and
|
l2.stop() # we stop l2 and
|
||||||
time.sleep(0.5) # wait a bit for the PeerThread to see it
|
l1.daemon.logsearch_start = len(l1.daemon.logs)
|
||||||
|
l1.daemon.wait_for_log(r".*availability persisted and synced.*")
|
||||||
s2 = l1.rpc.summary()
|
s2 = l1.rpc.summary()
|
||||||
|
|
||||||
# then
|
# then
|
||||||
@@ -172,17 +172,18 @@ def test_summary_avail_leadwin():
|
|||||||
|
|
||||||
# checks whether the peerstate is persistent
|
# checks whether the peerstate is persistent
|
||||||
def test_summary_persist(node_factory):
|
def test_summary_persist(node_factory):
|
||||||
# in order to give the PeerThread a chance in a unit test
|
# Set a low PeerThread interval so we can test quickly.
|
||||||
# we need to give it a low interval
|
opts = {'summary-availability-interval': 0.5, 'may_reconnect': True}
|
||||||
opts = {'summary-availability-interval': 0.1, 'may_reconnect': True}
|
|
||||||
opts.update(pluginopt)
|
opts.update(pluginopt)
|
||||||
l1, l2 = node_factory.line_graph(2, opts=opts)
|
l1, l2 = node_factory.line_graph(2, opts=opts)
|
||||||
|
|
||||||
# when
|
# when
|
||||||
time.sleep(0.5) # wait a bit for the PeerThread to capture data
|
l1.daemon.wait_for_log(r".*availability persisted and synced.*")
|
||||||
s1 = l1.rpc.summary()
|
s1 = l1.rpc.summary()
|
||||||
l1.restart()
|
l1.restart()
|
||||||
l1.connect(l2)
|
l1.connect(l2)
|
||||||
|
l1.daemon.logsearch_start = len(l1.daemon.logs)
|
||||||
|
l1.daemon.wait_for_log(r".*availability persisted and synced.*")
|
||||||
s2 = l1.rpc.summary()
|
s2 = l1.rpc.summary()
|
||||||
|
|
||||||
# then
|
# then
|
||||||
|
|||||||
Reference in New Issue
Block a user