From 71ffc472a3835839f0728ff28671d7b74f574a28 Mon Sep 17 00:00:00 2001 From: Felipe Gasper Date: Wed, 26 Nov 2025 16:37:47 -0500 Subject: [PATCH] save --- internal/verifier/change_stream.go | 2 +- internal/verifier/list_namespaces.go | 22 ++++++---- internal/verifier/migration_verifier_test.go | 42 ++++++++++++++++++++ 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/internal/verifier/change_stream.go b/internal/verifier/change_stream.go index ad7fbabe..81732825 100644 --- a/internal/verifier/change_stream.go +++ b/internal/verifier/change_stream.go @@ -87,7 +87,7 @@ func (csr *ChangeStreamReader) GetChangeStreamFilter() (pipeline mongo.Pipeline) {{"$match", util.ExcludePrefixesQuery( "ns.db", append( - slices.Clone(MongosyncMetaDBPrefixes), + slices.Clone(ExcludedDBPrefixes), csr.metaDB.Name(), ), )}}, diff --git a/internal/verifier/list_namespaces.go b/internal/verifier/list_namespaces.go index 2ba1682a..7608469f 100644 --- a/internal/verifier/list_namespaces.go +++ b/internal/verifier/list_namespaces.go @@ -12,20 +12,26 @@ import ( "go.mongodb.org/mongo-driver/v2/mongo/options" ) +const ( + // ExcludedSystemCollPrefix is the prefix of system collections, + // which we ignore. + ExcludedSystemCollPrefix = "system." + + // MongoDBInternalDBPrefix is the prefix for MongoDB-internal databases. + // (e.g., Atlas’s availability canary) + MongoDBInternalDBPrefix = "__mdb_internal" +) + var ( - MongosyncMetaDBPrefixes = mslices.Of( + ExcludedDBPrefixes = mslices.Of( + // mongosync metadata: "mongosync_internal_", "mongosync_reserved_", + MongoDBInternalDBPrefix, ) -) -var ( // ExcludedSystemDBs are system databases that are excluded from verification. ExcludedSystemDBs = []string{"admin", "config", "local"} - - // ExcludedSystemCollPrefix is the prefix of system collections, - // which we ignore. - ExcludedSystemCollPrefix = "system." ) // ListAllUserNamespaces lists all the user collections on a cluster, @@ -52,7 +58,7 @@ func ListAllUserNamespaces( dbNames, err := client.ListDatabaseNames(ctx, bson.D{ {"$and", []bson.D{ {{"name", bson.D{{"$nin", excluded}}}}, - util.ExcludePrefixesQuery("name", MongosyncMetaDBPrefixes), + util.ExcludePrefixesQuery("name", ExcludedDBPrefixes), }}, }) diff --git a/internal/verifier/migration_verifier_test.go b/internal/verifier/migration_verifier_test.go index 4d70ccd8..e714491e 100644 --- a/internal/verifier/migration_verifier_test.go +++ b/internal/verifier/migration_verifier_test.go @@ -2240,6 +2240,48 @@ func (suite *IntegrationTestSuite) TestGenerationalRechecking() { suite.Require().NoError(runner.Await()) } +func (suite *IntegrationTestSuite) TestMongoDBInternalDB() { + ctx := suite.Context() + + dbName := MongoDBInternalDBPrefix + "internalDBTest" + + _, err := suite.srcMongoClient. + Database(dbName). + Collection("foo"). + InsertOne(ctx, bson.D{}) + suite.Require().NoError(err) + + verifier := suite.BuildVerifier() + runner := RunVerifierCheck(ctx, suite.T(), verifier) + + // Dry run generation 0 to make sure change stream reader is started. + suite.Require().NoError(runner.AwaitGenerationEnd()) + + status, err := verifier.GetVerificationStatus(ctx) + suite.Require().NoError(err) + + suite.Assert().Zero(status.FailedTasks, "gen0 should have no failed tasks: %+v", status) + + _, err = suite.srcMongoClient. + Database(dbName). + Collection("foo"). + InsertOne(ctx, bson.D{}) + suite.Require().NoError(err) + + suite.Require().NoError(runner.StartNextGeneration()) + suite.Require().NoError(runner.AwaitGenerationEnd()) + status, err = verifier.GetVerificationStatus(ctx) + suite.Require().NoError(err) + suite.Assert().Zero(status.FailedTasks, "gen1 should have no failed tasks: %+v", status) + + suite.Require().NoError(verifier.WritesOff(ctx)) + suite.Require().NoError(runner.Await()) + + status, err = verifier.GetVerificationStatus(ctx) + suite.Require().NoError(err) + suite.Assert().Zero(status.FailedTasks, "end should have no failed tasks: %+v", status) +} + func (suite *IntegrationTestSuite) TestVerifierWithFilter() { zerolog.SetGlobalLevel(zerolog.DebugLevel)