Skip to content

Commit 4ef7827

Browse files
authored
fix: TopicMessageQuery integration test timeout issue (#982)
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
1 parent 5ec352f commit 4ef7827

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
1919

2020
### Fixed
2121
- Fixed inactivity bot workflow not checking out repository before running (#964)
22+
- Fixed the topic_message_query integarion test
2223

2324
### Breaking Change
2425

tests/integration/topic_message_query_e2e_test.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ def create_topic(client):
5858
def test_topic_message_query_receives_messages(env):
5959
"""Test that topic message query receives a message."""
6060
topic_id = create_topic(env.client)
61-
61+
62+
time.sleep(3)
63+
6264
messages: List[str] = []
6365

6466
def get_message(m: TopicMessage):
@@ -78,6 +80,8 @@ def on_error_handler(e):
7880
on_message=get_message,
7981
on_error=on_error_handler
8082
)
83+
84+
time.sleep(3)
8185

8286
message_receipt = (
8387
TopicMessageSubmitTransaction(
@@ -96,9 +100,9 @@ def on_error_handler(e):
96100
start = datetime.now()
97101

98102
while len(messages) == 0:
99-
if datetime.now() - start > timedelta(seconds=120):
103+
if datetime.now() - start > timedelta(seconds=180):
100104
raise TimeoutError("TopicMessage was not received in time")
101-
time.sleep(1)
105+
time.sleep(5)
102106

103107
assert messages[0] == "Hello, Python SDK!"
104108
handle.cancel()
@@ -113,6 +117,8 @@ def test_topic_message_query_limit(env):
113117
def on_message(m: TopicMessage):
114118
messages.append(m.contents.decode("utf-8"))
115119

120+
time.sleep(3)
121+
116122
query = TopicMessageQuery(
117123
topic_id=topic_id,
118124
start_time=datetime.now(timezone.utc),
@@ -121,6 +127,7 @@ def on_message(m: TopicMessage):
121127

122128
handle = query.subscribe(env.client, on_message=on_message)
123129

130+
time.sleep(3)
124131
# Submit 3 messages
125132
try:
126133
for i in range(3):
@@ -133,9 +140,9 @@ def on_message(m: TopicMessage):
133140
start = datetime.now()
134141

135142
while len(messages) != 2:
136-
if datetime.now() - start > timedelta(seconds=120):
143+
if datetime.now() - start > timedelta(seconds=180):
137144
raise TimeoutError("TopicMessage was not received in time")
138-
time.sleep(1)
145+
time.sleep(5)
139146

140147
# Should stop at limit=2
141148
assert messages == ["msg0", "msg1"]
@@ -149,6 +156,7 @@ def test_topic_message_query_large_message_chunking(env):
149156
"""Test that topic message query receives chunked message."""
150157
topic_id = create_topic(env.client)
151158
messages: List[str] = []
159+
time.sleep(3)
152160

153161
def get_message(m: TopicMessage):
154162
messages.append(m.contents.decode('utf-8'))
@@ -168,7 +176,9 @@ def on_error_handler(e):
168176
on_message=get_message,
169177
on_error=on_error_handler
170178
)
171-
179+
180+
time.sleep(3)
181+
172182
message_receipt = (
173183
TopicMessageSubmitTransaction(
174184
topic_id=topic_id,
@@ -187,9 +197,9 @@ def on_error_handler(e):
187197
start = datetime.now()
188198

189199
while len(messages) == 0:
190-
if datetime.now() - start > timedelta(seconds=120):
200+
if datetime.now() - start > timedelta(seconds=180):
191201
raise TimeoutError("TopicMessage was not received in time")
192-
time.sleep(1)
202+
time.sleep(5)
193203

194204
assert messages[0] == BIG_CONTENT
195205
handle.cancel()

0 commit comments

Comments
 (0)