@@ -80,17 +80,44 @@ async fn partitioned_table_sync_succeeds_with_inherited_primary_keys() {
8080 ) ;
8181
8282 let table_states = state_store. get_table_replication_states ( ) . await ;
83- for ( table_id, state) in & table_states {
84- if partition_table_ids. contains ( table_id) {
85- assert ! (
86- matches!(
87- state. as_type( ) ,
88- TableReplicationPhaseType :: SyncDone | TableReplicationPhaseType :: Ready
89- ) ,
90- "Partition {} should be in SyncDone or Ready state, but was in {:?}" ,
91- table_id,
92- state. as_type( )
93- ) ;
94- }
83+
84+ assert_eq ! (
85+ table_states. len( ) ,
86+ partition_table_ids. len( ) ,
87+ "Expected {} partition states, but found {}" ,
88+ partition_table_ids. len( ) ,
89+ table_states. len( )
90+ ) ;
91+
92+ for & partition_id in & partition_table_ids {
93+ let state = table_states
94+ . get ( & partition_id)
95+ . unwrap_or_else ( || panic ! ( "Partition {} should have a state" , partition_id) ) ;
96+ assert ! (
97+ matches!(
98+ state. as_type( ) ,
99+ TableReplicationPhaseType :: SyncDone | TableReplicationPhaseType :: Ready
100+ ) ,
101+ "Partition {} should be in SyncDone or Ready state, but was in {:?}" ,
102+ partition_id,
103+ state. as_type( )
104+ ) ;
95105 }
106+
107+ assert ! (
108+ !table_states. contains_key( & parent_table_id) ,
109+ "Parent table {} should not be tracked since parent partitioned tables are excluded from processing" ,
110+ parent_table_id
111+ ) ;
112+
113+ let parent_table_rows = table_rows
114+ . iter ( )
115+ . filter ( |( table_id, _) | * * table_id == parent_table_id)
116+ . map ( |( _, rows) | rows. len ( ) )
117+ . sum :: < usize > ( ) ;
118+ assert_eq ! (
119+ parent_table_rows, 0 ,
120+ "Parent table {} should have no data since it's excluded from processing and all data goes to partitions, but found {} rows" ,
121+ parent_table_id, parent_table_rows
122+ ) ;
96123}
0 commit comments