Skip to content

Commit 7b4de89

Browse files
committed
okay windows will you work now
1 parent 7fadb44 commit 7b4de89

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

tests/test_ros2_pubsub_sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
test_wait_for_value,
1818
test_wait_new,
1919
test_wait_next,
20+
test_reliable_extremely_fast,
2021
)
2122

2223
import asyncio_for_robotics.ros2 as aros
23-
from asyncio_for_robotics.core._logger import setup_logger
2424
from asyncio_for_robotics.ros2.session import SynchronousSession, set_auto_session
2525

2626
logger = logging.getLogger("asyncio_for_robotics.test")

tests/test_ros2_pubsub_thr.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,11 @@ async def test_listen_too_fast(pub: Publisher, sub: aros.Sub[String]):
141141
last_payload = f"hello{sample_count}"
142142
pub.publish(String(data=last_payload))
143143
put_count += 1
144+
await asyncio.sleep(0.001)
144145
last_payload = f"hello{sample_count}"
145146
pub.publish(String(data=last_payload))
146147
put_count += 1
147-
await asyncio.sleep(0.01)
148+
await asyncio.sleep(0.001)
148149

149150
assert put_count / 2 == sample_count == max_iter
150151

@@ -172,8 +173,9 @@ async def test_reliable_too_fast(pub: Publisher, sub: aros.Sub[String]):
172173
put_queue = [str(v) for v in data]
173174
received_buf = []
174175
listener = sub.listen_reliable(fresh=True, queue_size=len(data) * 2)
175-
await asyncio.sleep(0.1)
176+
await asyncio.sleep(0.001)
176177
pub.publish(String(data=put_queue.pop()))
178+
await asyncio.sleep(0.001)
177179
pub.publish(String(data=put_queue.pop()))
178180
async with soft_timeout(2):
179181
async for sample in listener:
@@ -183,12 +185,35 @@ async def test_reliable_too_fast(pub: Publisher, sub: aros.Sub[String]):
183185
break
184186
if put_queue != []:
185187
pub.publish(String(data=put_queue.pop()))
188+
await asyncio.sleep(0.001)
186189
if put_queue != []:
187190
pub.publish(String(data=put_queue.pop()))
191+
await asyncio.sleep(0.001)
188192

189193
received_buf.reverse()
190194
assert data == received_buf
191195

196+
async def test_reliable_extremely_fast(pub: Publisher, sub: aros.Sub[String]):
197+
data = list(range(200))
198+
put_queue = [str(v) for v in data]
199+
received_buf = []
200+
listener = sub.listen_reliable(fresh=True, queue_size=len(data) * 2)
201+
pub.publish(String(data=put_queue.pop()))
202+
pub.publish(String(data=put_queue.pop()))
203+
async with soft_timeout(2):
204+
async for sample in listener:
205+
payload = int(sample.data)
206+
received_buf.append(payload)
207+
if len(received_buf) >= len(data):
208+
break
209+
if put_queue != []:
210+
pub.publish(String(data=put_queue.pop()))
211+
if put_queue != []:
212+
pub.publish(String(data=put_queue.pop()))
213+
214+
received_buf.reverse()
215+
assert set(data) == set(received_buf)
216+
192217

193218
async def test_freshness(pub: Publisher, sub: aros.Sub[String]):
194219
payload = "hello"

tests/test_zenoh_pubsub.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ async def test_listen_too_fast(pub: zenoh.Publisher, sub: Sub):
114114
sample_count = 0
115115
put_count = 2
116116
max_iter = 20
117-
await asyncio.sleep(0.01)
117+
await asyncio.sleep(0.001)
118118
async for sample in sub.listen():
119119
sample_count += 1
120120
assert sample.payload.to_string() == last_payload
@@ -123,10 +123,11 @@ async def test_listen_too_fast(pub: zenoh.Publisher, sub: Sub):
123123
last_payload = f"hello{sample_count}"
124124
pub.put(last_payload)
125125
put_count += 1
126+
await asyncio.sleep(0.001)
126127
last_payload = f"hello{sample_count}"
127128
pub.put(last_payload)
128129
put_count += 1
129-
await asyncio.sleep(0.01)
130+
await asyncio.sleep(0.001)
130131

131132
assert put_count / 2 == sample_count == max_iter
132133

@@ -192,7 +193,6 @@ async def test_reliable_extremely_fast(pub: zenoh.Publisher, sub: Sub):
192193
if put_queue != []:
193194
pub.put(put_queue.pop())
194195

195-
received_buf.reverse()
196196
assert set(data) == set(received_buf)
197197

198198

0 commit comments

Comments
 (0)