Skip to content

Commit 2b7e4ab

Browse files
committed
Binary search waiting for channels to sync
1 parent 79cc56a commit 2b7e4ab

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

server/tests/test_e2e.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414

1515
LOG: logging.Logger = logging.getLogger(__name__)
1616

17-
WAIT_SECONDS = 5
18-
WAIT_ATTEMPTS = 10
17+
MAX_WAIT_ATTEMPTS = 25
1918

2019

2120
def fullSetupDockerCompose() -> DockerCompose:
@@ -65,19 +64,26 @@ def test_smoke(self) -> None:
6564
# wait for channels to sync
6665
LOG.info("CF URL: %s", cf_url)
6766
cf_client = ChannelFinderClient(BaseURL=cf_url)
68-
for number_of_seconds in range(WAIT_ATTEMPTS):
67+
self.wait_for_sync(cf_client)
68+
channels = cf_client.find(name="*")
69+
assert len(channels) == 24
70+
assert channels[0]["name"] == "IOC1-1::li"
71+
72+
def wait_for_sync(self, cf_client):
73+
seconds_to_wait = 1
74+
total_seconds_waited = 0
75+
for _ in range(MAX_WAIT_ATTEMPTS):
6976
try:
7077
channels = cf_client.find(name="*")
7178
LOG.info(
7279
"Found %s in %s seconds",
7380
len(channels),
74-
number_of_seconds * WAIT_SECONDS,
81+
total_seconds_waited,
7582
)
7683
if len(channels) == 24:
7784
break
7885
except Exception as e:
7986
LOG.error(e)
80-
time.sleep(WAIT_SECONDS)
81-
channels = cf_client.find(name="*")
82-
assert len(channels) == 24
83-
assert channels[0]["name"] == "IOC1-1::li"
87+
time.sleep(seconds_to_wait)
88+
total_seconds_waited += seconds_to_wait
89+
seconds_to_wait *= 2

0 commit comments

Comments
 (0)