diff --git a/internal/verifier/compare.go b/internal/verifier/compare.go index 3172c0d4..85fbfca0 100644 --- a/internal/verifier/compare.go +++ b/internal/verifier/compare.go @@ -721,13 +721,16 @@ func transformPipelineForToHashedIndexKey( func (verifier *Verifier) compareOneDocument(srcClientDoc, dstClientDoc bson.Raw, namespace string) ([]VerificationResult, error) { match := bytes.Equal(srcClientDoc, dstClientDoc) if match { + // Happy path! The documents binary-match. return nil, nil } + docID := getDocIdFromComparison(verifier.docCompareMethod, srcClientDoc) + if verifier.docCompareMethod == DocCompareToHashedIndexKey { // With hash comparison, mismatches are opaque. return []VerificationResult{{ - ID: getDocIdFromComparison(verifier.docCompareMethod, srcClientDoc), + ID: docID, Details: Mismatch, Cluster: ClusterTarget, NameSpace: namespace, @@ -746,13 +749,15 @@ func (verifier *Verifier) compareOneDocument(srcClientDoc, dstClientDoc bson.Raw // If we're respecting field order we have just done a binary compare so we have fields in different order. return []VerificationResult{{ - ID: srcClientDoc.Lookup("_id"), - Details: Mismatch + fmt.Sprintf(" : Document %s has fields in different order", srcClientDoc.Lookup("_id")), + ID: docID, + Details: Mismatch + " : only field order differs", Cluster: ClusterTarget, NameSpace: namespace, dataSize: int32(dataSize), }}, nil } - results := mismatchResultsToVerificationResults(mismatch, srcClientDoc, dstClientDoc, namespace, srcClientDoc.Lookup("_id"), "" /* fieldPrefix */) + + results := mismatchResultsToVerificationResults(mismatch, srcClientDoc, dstClientDoc, namespace, docID, "" /* fieldPrefix */) + return results, nil } diff --git a/internal/verifier/migration_verifier_test.go b/internal/verifier/migration_verifier_test.go index 8159c19c..396077bf 100644 --- a/internal/verifier/migration_verifier_test.go +++ b/internal/verifier/migration_verifier_test.go @@ -25,6 +25,7 @@ import ( "github.com/10gen/migration-verifier/internal/testutil" "github.com/10gen/migration-verifier/internal/types" "github.com/10gen/migration-verifier/internal/util" + "github.com/10gen/migration-verifier/internal/verifier/recheck" "github.com/10gen/migration-verifier/mbson" "github.com/10gen/migration-verifier/mslices" "github.com/10gen/migration-verifier/option" @@ -1739,6 +1740,14 @@ func (suite *IntegrationTestSuite) TestVerifierDocMismatches() { _, _, err = verifier.reportDocumentMismatches(ctx, builder) suite.Require().NoError(err) + for _, specimen := range mslices.Of("100000", "100001") { + suite.Assert().Contains( + builder.String(), + specimen, + "summary should show all mismatched-content doc IDs", + ) + } + suite.Assert().Contains( builder.String(), "100009", @@ -1751,6 +1760,12 @@ func (suite *IntegrationTestSuite) TestVerifierDocMismatches() { "summary should show the # of missing docs shown", ) + suite.Assert().Contains( + builder.String(), + " 2 ", + "summary should show the total # of content-mismatched documents", + ) + suite.Assert().Contains( builder.String(), " 18 ", @@ -1762,6 +1777,22 @@ func (suite *IntegrationTestSuite) TestVerifierDocMismatches() { "100019", "summary should NOT show a late mismatch", ) + + rechecks := suite.fetchRecheckDocs(ctx, verifier) + recheckDocIDs := lo.Map( + rechecks, + func(r recheck.Doc, _ int) int { + num, err := mbson.CastRawValue[int32](r.PrimaryKey.DocumentID) + suite.Require().NoError(err) + return int(num) + }, + ) + + suite.Assert().ElementsMatch( + lo.RangeFrom(100000, 20), + recheckDocIDs, + "all docs should be enqueued for recheck", + ) } func (suite *IntegrationTestSuite) TestVerifierCompareIndexSpecs() {