mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 14:24:09 +01:00
pytest: fix flake due to cln-grpc starting before "public key" message.
e.g. ``` lightningd-1: 2022-03-28T11:02:12.476Z DEBUG plugin-cln-grpc: add_pem_file processed 1 valid and 0 invalid certs lightningd-1: 2022-03-28T11:02:12.478Z DEBUG plugin-cln-grpc: Connecting to \"lightning-rpc\" and serving grpc on 0.0.0.0:36331 lightningd-1: 2022-03-28T11:02:12.478Z DEBUG connectd: REPLY WIRE_CONNECTD_ACTIVATE_REPLY with 0 fds lightningd-1: 2022-03-28T11:02:12.478Z INFO lightningd: -------------------------------------------------- lightningd-1: 2022-03-28T11:02:12.478Z INFO lightningd: Server started with public key ``` Which means we don't see it, since start() swallows it: ``` > raise TimeoutError('Unable to find "{}" in logs.'.format(exs)) E TimeoutError: Unable to find "[re.compile('serving grpc on 0.0.0.0:')]" in logs. ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
09ee28cb51
commit
ae5b98a727
1 changed files with 8 additions and 3 deletions
|
@ -15,6 +15,11 @@ pytestmark = pytest.mark.skipif(
|
|||
)
|
||||
|
||||
|
||||
def wait_for_grpc_start(node):
|
||||
"""This can happen before "public key" which start() swallows"""
|
||||
wait_for(lambda: node.daemon.is_in_log(r'serving grpc on 0.0.0.0:'))
|
||||
|
||||
|
||||
def test_rpc_client(node_factory):
|
||||
l1 = node_factory.get_node()
|
||||
bin_path = Path.cwd() / "target" / "debug" / "examples" / "cln-rpc-getinfo"
|
||||
|
@ -82,7 +87,7 @@ def test_grpc_connect(node_factory):
|
|||
certificate_chain=cert_path.open('rb').read()
|
||||
)
|
||||
|
||||
l1.daemon.wait_for_log(r'serving grpc on 0.0.0.0:')
|
||||
wait_for_grpc_start(l1)
|
||||
channel = grpc.secure_channel(
|
||||
f"localhost:{grpc_port}",
|
||||
creds,
|
||||
|
@ -165,7 +170,7 @@ def test_grpc_wrong_auth(node_factory):
|
|||
"grpc-port": str(grpc_port),
|
||||
})
|
||||
l1.start()
|
||||
l1.daemon.wait_for_log(r'serving grpc on 0.0.0.0:')
|
||||
wait_for_grpc_start(l1)
|
||||
|
||||
def connect(node):
|
||||
p = Path(node.daemon.lightning_dir) / TEST_NETWORK
|
||||
|
@ -193,7 +198,7 @@ def test_grpc_wrong_auth(node_factory):
|
|||
|
||||
l1.stop()
|
||||
l2.start()
|
||||
l2.daemon.wait_for_log(r'serving grpc on 0.0.0.0:')
|
||||
wait_for_grpc_start(l2)
|
||||
|
||||
# This should not work, it's a different node
|
||||
with pytest.raises(Exception, match=r'Socket closed|StatusCode.UNAVAILABLE'):
|
||||
|
|
Loading…
Add table
Reference in a new issue