@@ -22,7 +22,7 @@ async fn partitioned_table_sync_succeeds_with_inherited_primary_keys() {
22
22
( "p3" , "FROM (200) TO (300)" ) ,
23
23
] ;
24
24
25
- let ( _parent_table_id , partition_table_ids) =
25
+ let ( parent_table_id , partition_table_ids) =
26
26
create_partitioned_table ( & database, table_name. clone ( ) , & partition_specs)
27
27
. await
28
28
. expect ( "Failed to create partitioned table" ) ;
@@ -80,17 +80,44 @@ async fn partitioned_table_sync_succeeds_with_inherited_primary_keys() {
80
80
) ;
81
81
82
82
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
+ . expect ( & format ! ( "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
+ ) ;
95
105
}
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
+ ) ;
96
123
}
0 commit comments