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
2 changes: 1 addition & 1 deletion internal/verifier/change_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
),
)}},
Expand Down
22 changes: 14 additions & 8 deletions internal/verifier/list_namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
}},
})

Expand Down
42 changes: 42 additions & 0 deletions internal/verifier/migration_verifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down