Commit b9b66e94 authored by Philippe B.'s avatar Philippe B. 🏂 Committed by Seb Mondet

Tests/python: check node connectivity

parent 43f52fa9
Pipeline #104446608 passed with stages
in 59 minutes and 46 seconds
import datetime
import time
import json
import os
import shutil
......@@ -658,3 +659,14 @@ class Client:
'on', 'behalf', 'of', src, 'with',
'signatures'] + signatures
return self.run(cmd)
def check_node_listening(self):
timeout = 0.5
attempts = 5
for _ in range(attempts):
try:
self.get_protocol()
return True
except Exception: # pylint: disable=broad-except
time.sleep(timeout)
return False
......@@ -195,7 +195,10 @@ class Sandbox:
node.run()
client = Client(local_client, local_admin_client, rpc_port=rpc_node,
use_tls=bool(use_tls))
time.sleep(0.1)
if not client.check_node_listening():
node.kill()
assert False, f"# Node {node_id} isn't listening to RPC"
# make sure node didn't fail at startup
assert node.poll() is None, 'Seems node failed at startup'
......
import time
import pytest
from tools import utils, constants
......@@ -47,7 +46,7 @@ class TestDoubleEndorsement:
def test_restart_node_2(self, sandbox):
sandbox.node(2).run()
time.sleep(2)
assert sandbox.client(2).check_node_listening()
def test_bake_node_2(self, sandbox):
"""Client 2 bakes block B at level 3, not communicated to 0 and 1"""
......@@ -65,7 +64,8 @@ class TestDoubleEndorsement:
def test_restart_all(self, sandbox):
sandbox.node(0).run()
sandbox.node(1).run()
time.sleep(4)
sandbox.client(0).check_node_listening()
sandbox.client(1).check_node_listening()
def test_check_level(self, sandbox):
"""All nodes are at level 3, head is either block A or B"""
......
import time
import pytest
from tools import utils
......@@ -56,7 +55,7 @@ class TestFork:
def test_restart_node_2(self, sandbox):
sandbox.node(2).run()
time.sleep(2)
assert sandbox.client(2).check_node_listening()
def test_bake_node_2(self, sandbox):
"""Client 2 bakes block B at level 2, not communicated to 0 and 1"""
......@@ -75,7 +74,8 @@ class TestFork:
def test_restart_all(self, sandbox):
sandbox.node(0).run()
sandbox.node(1).run()
time.sleep(2)
assert sandbox.client(0).check_node_listening()
assert sandbox.client(1).check_node_listening()
# def test_check_head(self, sandbox, session):
# """All nodes are at level 3, head should be hash1"""
......
......@@ -49,7 +49,7 @@ class TestMultiNodeSnapshot:
def test_rerun_group1(self, sandbox):
for i in GROUP1:
sandbox.node(i).run()
time.sleep(2)
sandbox.client(i).check_node_listening()
def test_level(self, sandbox):
for i in GROUP1 + GROUP2:
......
......@@ -80,7 +80,7 @@ class TestMultiNodeStorageReconstruction:
time.sleep(2)
sandbox.node(2).reconstruct()
sandbox.node(2).run()
time.sleep(2)
assert sandbox.client(2).check_node_listening()
def test_available_blocks(self, sandbox, session):
# We should now success requesting those reconstructed blocks
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment