Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions internal/verifier/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
31 changes: 31 additions & 0 deletions internal/verifier/migration_verifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand All @@ -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 ",
Expand All @@ -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() {
Expand Down