Skip to content

Comments

TOOLS-4075 Add integration test for restoring TTL collMod oplog#891

Open
tdq45gj wants to merge 4 commits intomasterfrom
TOOLS-4075-collMod-TTL
Open

TOOLS-4075 Add integration test for restoring TTL collMod oplog#891
tdq45gj wants to merge 4 commits intomasterfrom
TOOLS-4075-collMod-TTL

Conversation

@tdq45gj
Copy link
Contributor

@tdq45gj tdq45gj commented Feb 23, 2026

This commit adds integration tests for verifying that mongodump+mongorestore handles a collMod oplog that converts a non-TTL index into TTL correctly. This was a bug fixed in TOOLS-4071.

@tdq45gj tdq45gj marked this pull request as ready for review February 23, 2026 16:19
@tdq45gj tdq45gj requested a review from a team as a code owner February 23, 2026 16:20
@tdq45gj tdq45gj requested review from nickweinberger and removed request for a team February 23, 2026 16:20
Copy link
Collaborator

@nickweinberger nickweinberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core logic from the restore test looks good, left a couple questions partly for my own understanding and partly as suggestions. Approving % addressing these questions at your discretion.

err = session.Database(testDB).Collection(testCollName).Drop(ctx)
require.NoError(t, err)

err = session.Database(testDB).CreateCollection(ctx, testCollName)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it necessary to drop and create the collection?

defer failpoint.Reset()

go func() {
convertIndexToTTL(ctx, t)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Know you're following existing patterns here but I think calling testify's require (which convertIndexToTTL does) within a goroutine is bad practice in go. I think on failure it only exits the goroutine but not the whole test, so the test keeps running and it can cause weird panics that are harder to debug. Up to you whether you want to address or just note as tech debt.

Comment on lines +426 to +430
if cmp, err := testutil.CompareFCV(fcv, "6.0"); err != nil || cmp < 0 {
if err != nil {
t.Errorf("error getting FCV: %v", err)
}
t.Skipf("Requires server with FCV 6.0 or later; found %v", fcv)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why exactly 6.0+ required? Maybe useful to add into the error.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would also ideally put this in a helper for reusability, but I haven't worked much w/ the tools testing so don't know if that's worth it.

}
}

func TestOplogDumpCollModTTL(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this test intended as a generator for the restore test's testdata fixtures (like TestOplogDumpBypassDocumentValidation) ? If so, might benefit from a comment. Otherwise, mind explaining just what this test is doing?

Comment on lines +897 to +902
if cmp, err := testutil.CompareFCV(fcv, "6.0"); err != nil || cmp < 0 {
if err != nil {
t.Errorf("error getting FCV: %v", err)
}
t.Skipf("Requires server with FCV 6.0 or later; found %v", fcv)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about helper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants