@@ -1553,6 +1553,63 @@ func (suite *IntegrationTestSuite) TestVerifierWithFilter() {
15531553 <- checkDoneChan
15541554}
15551555
1556+ func (suite * IntegrationTestSuite ) TestChangesOnDstBeforeSrc () {
1557+ ctx := suite .Context ()
1558+ collName := "mycoll"
1559+
1560+ srcDB := suite .srcMongoClient .Database (suite .DBNameForTest ())
1561+ dstDB := suite .dstMongoClient .Database (suite .DBNameForTest ())
1562+ suite .Require ().NoError (srcDB .CreateCollection (ctx , collName ))
1563+ suite .Require ().NoError (dstDB .CreateCollection (ctx , collName ))
1564+
1565+ verifier := suite .BuildVerifier ()
1566+ runner := RunVerifierCheck (ctx , suite .T (), verifier )
1567+
1568+ // Dry run generation 0 to make sure change stream reader is started.
1569+ suite .Require ().NoError (runner .AwaitGenerationEnd ())
1570+
1571+ suite .Require ().NoError (runner .StartNextGeneration ())
1572+ // Insert two documents in generation 1. They should be batched and become a verify task in generation 2.
1573+ _ , err := dstDB .Collection (collName ).InsertOne (ctx , bson.D {{"_id" , 1 }})
1574+ suite .Require ().NoError (err )
1575+ _ , err = dstDB .Collection (collName ).InsertOne (ctx , bson.D {{"_id" , 2 }})
1576+ suite .Require ().NoError (err )
1577+ suite .Require ().NoError (runner .AwaitGenerationEnd ())
1578+
1579+ // Run generation 2 and get verification status.
1580+ suite .Require ().NoError (runner .StartNextGeneration ())
1581+ suite .Require ().NoError (runner .AwaitGenerationEnd ())
1582+ status , err := verifier .GetVerificationStatus (ctx )
1583+ suite .Require ().NoError (err )
1584+ suite .Assert ().Equal (
1585+ 1 ,
1586+ status .FailedTasks ,
1587+ )
1588+
1589+ // Patch up only one of the two mismatched documents in generation 3.
1590+ suite .Require ().NoError (runner .StartNextGeneration ())
1591+ _ , err = srcDB .Collection (collName ).InsertOne (ctx , bson.D {{"_id" , 1 }})
1592+ suite .Require ().NoError (err )
1593+ suite .Require ().NoError (runner .AwaitGenerationEnd ())
1594+ status , err = verifier .GetVerificationStatus (ctx )
1595+ suite .Require ().NoError (err )
1596+ suite .Assert ().Equal (
1597+ 1 ,
1598+ status .FailedTasks ,
1599+ )
1600+
1601+ // Patch up both of the 2 mismatched documents in generation 4.
1602+ suite .Require ().NoError (runner .StartNextGeneration ())
1603+ _ , err = srcDB .Collection (collName ).InsertOne (ctx , bson.D {{"_id" , 2 }})
1604+ suite .Require ().NoError (err )
1605+ suite .Require ().NoError (runner .AwaitGenerationEnd ())
1606+
1607+ // Everything should match by the end of it.
1608+ status , err = verifier .GetVerificationStatus (ctx )
1609+ suite .Require ().NoError (err )
1610+ suite .Assert ().Zero (status .FailedTasks )
1611+ }
1612+
15561613func (suite * IntegrationTestSuite ) TestBackgroundInIndexSpec () {
15571614 ctx := suite .Context ()
15581615
0 commit comments