66@pytest .mark .asyncio
77class TestTopicWriterAsyncIO :
88 async def test_send_message (self , driver : ydb .aio .Driver , topic_path ):
9- writer = driver .topic_client .writer (
10- topic_path , producer_and_message_group_id = "test"
11- )
9+ writer = driver .topic_client .writer (topic_path , producer_id = "test" )
1210 await writer .write (ydb .TopicWriterMessage (data = "123" .encode ()))
1311 await writer .close ()
1412
1513 async def test_wait_last_seqno (self , driver : ydb .aio .Driver , topic_path ):
1614 async with driver .topic_client .writer (
1715 topic_path ,
18- producer_and_message_group_id = "test" ,
16+ producer_id = "test" ,
1917 auto_seqno = False ,
2018 ) as writer :
2119 await writer .write_with_ack (
@@ -24,16 +22,28 @@ async def test_wait_last_seqno(self, driver: ydb.aio.Driver, topic_path):
2422
2523 async with driver .topic_client .writer (
2624 topic_path ,
27- producer_and_message_group_id = "test" ,
28- get_last_seqno = True ,
25+ producer_id = "test" ,
2926 ) as writer2 :
3027 init_info = await writer2 .wait_init ()
3128 assert init_info .last_seqno == 5
3229
30+ async def test_random_producer_id (
31+ self , driver : ydb .aio .Driver , topic_path , topic_reader : ydb .TopicReaderAsyncIO
32+ ):
33+ async with driver .topic_client .writer (topic_path ) as writer :
34+ await writer .write (ydb .TopicWriterMessage (data = "123" .encode ()))
35+ async with driver .topic_client .writer (topic_path ) as writer :
36+ await writer .write (ydb .TopicWriterMessage (data = "123" .encode ()))
37+
38+ batch1 = await topic_reader .receive_batch ()
39+ batch2 = await topic_reader .receive_batch ()
40+
41+ assert batch1 .messages [0 ].producer_id != batch2 .messages [0 ].producer_id
42+
3343 async def test_auto_flush_on_close (self , driver : ydb .aio .Driver , topic_path ):
3444 async with driver .topic_client .writer (
3545 topic_path ,
36- producer_and_message_group_id = "test" ,
46+ producer_id = "test" ,
3747 auto_seqno = False ,
3848 ) as writer :
3949 last_seqno = 0
@@ -45,41 +55,37 @@ async def test_auto_flush_on_close(self, driver: ydb.aio.Driver, topic_path):
4555
4656 async with driver .topic_client .writer (
4757 topic_path ,
48- producer_and_message_group_id = "test" ,
49- get_last_seqno = True ,
58+ producer_id = "test" ,
5059 ) as writer :
5160 init_info = await writer .wait_init ()
5261 assert init_info .last_seqno == last_seqno
5362
5463
5564class TestTopicWriterSync :
5665 def test_send_message (self , driver_sync : ydb .Driver , topic_path ):
57- writer = driver_sync .topic_client .writer (
58- topic_path , producer_and_message_group_id = "test"
59- )
66+ writer = driver_sync .topic_client .writer (topic_path , producer_id = "test" )
6067 writer .write (ydb .TopicWriterMessage (data = "123" .encode ()))
6168 writer .close ()
6269
6370 def test_wait_last_seqno (self , driver_sync : ydb .Driver , topic_path ):
6471 with driver_sync .topic_client .writer (
6572 topic_path ,
66- producer_and_message_group_id = "test" ,
73+ producer_id = "test" ,
6774 auto_seqno = False ,
6875 ) as writer :
6976 writer .write_with_ack (ydb .TopicWriterMessage (data = "123" .encode (), seqno = 5 ))
7077
7178 with driver_sync .topic_client .writer (
7279 topic_path ,
73- producer_and_message_group_id = "test" ,
74- get_last_seqno = True ,
80+ producer_id = "test" ,
7581 ) as writer2 :
7682 init_info = writer2 .wait_init ()
7783 assert init_info .last_seqno == 5
7884
7985 def test_auto_flush_on_close (self , driver_sync : ydb .Driver , topic_path ):
8086 with driver_sync .topic_client .writer (
8187 topic_path ,
82- producer_and_message_group_id = "test" ,
88+ producer_id = "test" ,
8389 auto_seqno = False ,
8490 ) as writer :
8591 last_seqno = 0
@@ -89,8 +95,23 @@ def test_auto_flush_on_close(self, driver_sync: ydb.Driver, topic_path):
8995
9096 with driver_sync .topic_client .writer (
9197 topic_path ,
92- producer_and_message_group_id = "test" ,
93- get_last_seqno = True ,
98+ producer_id = "test" ,
9499 ) as writer :
95100 init_info = writer .wait_init ()
96101 assert init_info .last_seqno == last_seqno
102+
103+ def test_random_producer_id (
104+ self ,
105+ driver_sync : ydb .aio .Driver ,
106+ topic_path ,
107+ topic_reader_sync : ydb .TopicReader ,
108+ ):
109+ with driver_sync .topic_client .writer (topic_path ) as writer :
110+ writer .write (ydb .TopicWriterMessage (data = "123" .encode ()))
111+ with driver_sync .topic_client .writer (topic_path ) as writer :
112+ writer .write (ydb .TopicWriterMessage (data = "123" .encode ()))
113+
114+ batch1 = topic_reader_sync .receive_batch ()
115+ batch2 = topic_reader_sync .receive_batch ()
116+
117+ assert batch1 .messages [0 ].producer_id != batch2 .messages [0 ].producer_id
0 commit comments