26
26
@pytest .fixture
27
27
def kikimr (request ):
28
28
kikimr_conf = StreamingOverKikimrConfig (
29
- cloud_mode = True , node_count = {"/cp" : TenantConfig (1 ), "/compute" : TenantConfig (2 )}
29
+ cloud_mode = True , node_count = {"/cp" : TenantConfig (1 ), "/compute" : TenantConfig (3 )}
30
30
)
31
31
kikimr = StreamingOverKikimr (kikimr_conf )
32
32
kikimr .compute_plane .fq_config ['row_dispatcher' ]['enabled' ] = True
@@ -686,39 +686,41 @@ def test_restart_compute_node(self, kikimr, client):
686
686
client .create_yds_connection (
687
687
YDS_CONNECTION , os .getenv ("YDB_DATABASE" ), os .getenv ("YDB_ENDPOINT" ), shared_reading = True
688
688
)
689
- self .init_topics ("test_restart_compute_node" )
689
+ self .init_topics ("test_restart_compute_node" , partitions_count = 4 )
690
690
691
691
sql = Rf'''
692
692
INSERT INTO { YDS_CONNECTION } .`{ self .output_topic } `
693
693
SELECT Cast(time as String) FROM { YDS_CONNECTION } .`{ self .input_topic } `
694
694
WITH (format=json_each_row, SCHEMA (time Int32 NOT NULL));'''
695
695
696
696
query_id = start_yds_query (kikimr , client , sql )
697
- wait_actor_count (kikimr , "FQ_ROW_DISPATCHER_SESSION" , 1 )
697
+ wait_actor_count (kikimr , "FQ_ROW_DISPATCHER_SESSION" , 4 )
698
698
699
- data = ['{"time": 101, "data": "hello1"}' , '{"time": 102, "data": "hello2"}' ]
699
+ write_stream (self .input_topic , [Rf'''{{"time": { c } }}''' for c in range (100 , 102 )], "partition_key1" )
700
+ write_stream (self .input_topic , [Rf'''{{"time": { c } }}''' for c in range (102 , 104 )], "partition_key2" )
701
+ write_stream (self .input_topic , [Rf'''{{"time": { c } }}''' for c in range (104 , 106 )], "partition_key3" )
702
+ write_stream (self .input_topic , [Rf'''{{"time": { c } }}''' for c in range (106 , 108 )], "partition_key4" )
700
703
701
- self .write_stream (data )
702
- expected = ['101' , '102' ]
703
- assert self .read_stream (len (expected ), topic_path = self .output_topic ) == expected
704
+ expected = [Rf'''{ c } ''' for c in range (100 , 108 )]
705
+ assert sorted (self .read_stream (len (expected ), topic_path = self .output_topic )) == expected
704
706
705
707
kikimr .compute_plane .wait_completed_checkpoints (
706
- query_id , kikimr .compute_plane .get_completed_checkpoints (query_id ) + 1
707
- )
708
-
709
- wait_actor_count (kikimr , "DQ_PQ_READ_ACTOR" , 1 )
710
- wait_actor_count (kikimr , "FQ_ROW_DISPATCHER_SESSION" , 1 )
708
+ query_id , kikimr .compute_plane .get_completed_checkpoints (query_id ) + 2 )
711
709
712
710
node_index = 2
713
711
logging .debug ("Restart compute node {}" .format (node_index ))
714
712
kikimr .compute_plane .kikimr_cluster .nodes [node_index ].stop ()
715
713
kikimr .compute_plane .kikimr_cluster .nodes [node_index ].start ()
716
714
kikimr .compute_plane .wait_bootstrap (node_index )
717
715
718
- data = ['{"time": 103, "data": "hello3"}' , '{"time": 104, "data": "hello4"}' ]
719
- self .write_stream (data )
720
- expected = ['103' , '104' ]
721
- assert self .read_stream (len (expected ), topic_path = self .output_topic ) == expected
716
+ write_stream (self .input_topic , [Rf'''{{"time": { c } }}''' for c in range (108 , 110 )], "partition_key1" )
717
+ write_stream (self .input_topic , [Rf'''{{"time": { c } }}''' for c in range (110 , 112 )], "partition_key2" )
718
+ write_stream (self .input_topic , [Rf'''{{"time": { c } }}''' for c in range (112 , 114 )], "partition_key3" )
719
+ write_stream (self .input_topic , [Rf'''{{"time": { c } }}''' for c in range (114 , 116 )], "partition_key4" )
720
+
721
+ expected = [Rf'''{ c } ''' for c in range (108 , 116 )]
722
+ assert sorted (self .read_stream (len (expected ), topic_path = self .output_topic )) == expected
723
+
722
724
kikimr .compute_plane .wait_completed_checkpoints (
723
725
query_id , kikimr .compute_plane .get_completed_checkpoints (query_id ) + 1
724
726
)
@@ -729,10 +731,31 @@ def test_restart_compute_node(self, kikimr, client):
729
731
kikimr .compute_plane .kikimr_cluster .nodes [node_index ].start ()
730
732
kikimr .compute_plane .wait_bootstrap (node_index )
731
733
732
- data = ['{"time": 105, "data": "hello5"}' , '{"time": 106, "data": "hello6"}' ]
733
- self .write_stream (data )
734
- expected = ['105' , '106' ]
735
- assert self .read_stream (len (expected ), topic_path = self .output_topic ) == expected
734
+ write_stream (self .input_topic , [Rf'''{{"time": { c } }}''' for c in range (116 , 118 )], "partition_key1" )
735
+ write_stream (self .input_topic , [Rf'''{{"time": { c } }}''' for c in range (118 , 120 )], "partition_key2" )
736
+ write_stream (self .input_topic , [Rf'''{{"time": { c } }}''' for c in range (120 , 122 )], "partition_key3" )
737
+ write_stream (self .input_topic , [Rf'''{{"time": { c } }}''' for c in range (122 , 124 )], "partition_key4" )
738
+
739
+ expected = [Rf'''{ c } ''' for c in range (116 , 124 )]
740
+ assert sorted (self .read_stream (len (expected ), topic_path = self .output_topic )) == expected
741
+
742
+ kikimr .compute_plane .wait_completed_checkpoints (
743
+ query_id , kikimr .compute_plane .get_completed_checkpoints (query_id ) + 2
744
+ )
745
+
746
+ node_index = 3
747
+ logging .debug ("Restart compute node {}" .format (node_index ))
748
+ kikimr .compute_plane .kikimr_cluster .nodes [node_index ].stop ()
749
+ kikimr .compute_plane .kikimr_cluster .nodes [node_index ].start ()
750
+ kikimr .compute_plane .wait_bootstrap (node_index )
751
+
752
+ write_stream (self .input_topic , [Rf'''{{"time": { c } }}''' for c in range (124 , 126 )], "partition_key1" )
753
+ write_stream (self .input_topic , [Rf'''{{"time": { c } }}''' for c in range (126 , 128 )], "partition_key2" )
754
+ write_stream (self .input_topic , [Rf'''{{"time": { c } }}''' for c in range (128 , 130 )], "partition_key3" )
755
+ write_stream (self .input_topic , [Rf'''{{"time": { c } }}''' for c in range (130 , 132 )], "partition_key4" )
756
+
757
+ expected = [Rf'''{ c } ''' for c in range (124 , 132 )]
758
+ assert sorted (self .read_stream (len (expected ), topic_path = self .output_topic )) == expected
736
759
737
760
stop_yds_query (client , query_id )
738
761
wait_actor_count (kikimr , "FQ_ROW_DISPATCHER_SESSION" , 0 )
0 commit comments