@@ -157,11 +157,11 @@ func (s MongoClickhouseSuite) Test_Simple_Flow_Partitioned() {
157157 RequireEnvCanceled (t , env )
158158}
159159
160- func (s MongoClickhouseSuite ) Test_Snapshot_Partition_Capped_To_Timestamp_Range () {
160+ func (s MongoClickhouseSuite ) Test_Snapshot_Collection_With_Single_Document () {
161161 t := s .T ()
162162 srcDatabase := GetTestDatabase (s .Suffix ())
163- srcTable := "test_partition_cap "
164- dstTable := "test_partition_cap_dst "
163+ srcTable := "test_single_doc_snapshot "
164+ dstTable := "test_single_doc_snapshot_dst "
165165
166166 connectionGen := FlowConnectionGenerationConfig {
167167 FlowJobName : AddSuffix (s , srcTable ),
@@ -170,39 +170,34 @@ func (s MongoClickhouseSuite) Test_Snapshot_Partition_Capped_To_Timestamp_Range(
170170 }
171171 flowConnConfig := s .generateFlowConnectionConfigsDefaultEnv (connectionGen )
172172 flowConnConfig .DoInitialSnapshot = true
173- // 1 row per partition would normally request 100 partitions for 100 docs,
174- // but the 5-second timestamp range should cap it to 5 partitions.
175173 flowConnConfig .SnapshotNumRowsPerPartition = 1
176174 flowConnConfig .Env ["PEERDB_MONGODB_PARALLEL_SNAPSHOTTING" ] = "true"
177175
178176 adminClient := s .Source ().(* MongoSource ).AdminClient ()
179177 collection := adminClient .Database (srcDatabase ).Collection (srcTable )
180178
181- baseTime := time .Date (2026 , 3 , 1 , 0 , 0 , 0 , 0 , time .UTC )
182- docs := make ([]any , 100 )
183- for i := range 100 {
184- // insert 100 docs spread across 5 seconds (20 docs per second)
185- oid := bson .NewObjectIDFromTimestamp (baseTime .Add (time .Duration (i / 20 ) * time .Second ))
186- docs [i ] = bson.D {
187- {Key : "_id" , Value : oid },
188- {Key : "key" , Value : fmt .Sprintf ("value_%d" , i )},
189- }
190- }
191- _ , err := collection .InsertMany (t .Context (), docs )
179+ _ , err := collection .InsertOne (t .Context (), bson.D {{Key : "key" , Value : "value" }})
192180 require .NoError (t , err )
193181
194182 tc := NewTemporalClient (t )
195183 env := ExecutePeerflow (t , tc , flowConnConfig )
196184
197- EnvWaitForEqualTablesWithNames (env , s , "initial load to match " , srcTable , dstTable , "_id,doc" )
185+ EnvWaitForEqualTablesWithNames (env , s , "initial load" , srcTable , dstTable , "_id,doc" )
198186
199187 catalogPool , err := internal .GetCatalogConnectionPoolFromEnv (t .Context ())
200188 require .NoError (t , err )
201189 var partitionCount int
202190 require .NoError (t , catalogPool .QueryRow (t .Context (),
203191 `SELECT COUNT(*) FROM peerdb_stats.qrep_partitions WHERE parent_mirror_name = $1` ,
204192 flowConnConfig .FlowJobName ).Scan (& partitionCount ))
205- require .Equal (t , 5 , partitionCount )
193+ require .Equal (t , 1 , partitionCount )
194+
195+ SetupCDCFlowStatusQuery (t , env , flowConnConfig )
196+
197+ insertRes , err := collection .InsertOne (t .Context (), bson.D {{Key : "cdc_key" , Value : "cdc_value" }})
198+ require .NoError (t , err )
199+ require .True (t , insertRes .Acknowledged )
200+ EnvWaitForEqualTablesWithNames (env , s , "cdc after single doc snapshot" , srcTable , dstTable , "_id,doc" )
206201
207202 env .Cancel (t .Context ())
208203 RequireEnvCanceled (t , env )
@@ -232,7 +227,6 @@ func (s MongoClickhouseSuite) Test_Snapshot_Empty_Collection() {
232227 env := ExecutePeerflow (t , tc , flowConnConfig )
233228 SetupCDCFlowStatusQuery (t , env , flowConnConfig )
234229
235- // insert after snapshot to verify CDC still works
236230 collection := adminClient .Database (srcDatabase ).Collection (srcTable )
237231 insertRes , err := collection .InsertOne (t .Context (), bson.D {bson.E {Key : "key" , Value : "val" }}, options .InsertOne ())
238232 require .NoError (t , err )
0 commit comments