-
Notifications
You must be signed in to change notification settings - Fork 365
Add round-trip test for time-series with a TTL index #777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2188,6 +2188,67 @@ func setupTimeseriesWithMixedSchema(dbName string, collName string) error { | |
return nil | ||
} | ||
|
||
func TestRestoreTimeseriesCollectionsWithTTL(t *testing.T) { | ||
testtype.SkipUnlessTestType(t, testtype.IntegrationTestType) | ||
ctx := context.Background() | ||
|
||
sessionProvider, _, err := testutil.GetBareSessionProvider() | ||
require.NoError(t, err, "should find cluster") | ||
|
||
defer sessionProvider.Close() | ||
|
||
session, err := sessionProvider.GetSession() | ||
require.NoError(t, err, "should find session") | ||
|
||
testutil.SkipUnlessFCVAtLeast(t, session, "7.0") | ||
|
||
dbName := t.Name() | ||
|
||
db := session.Database(dbName) | ||
require.NoError(t, db.Drop(ctx), "should drop db") | ||
|
||
err = db.CreateCollection( | ||
ctx, | ||
"coll", | ||
mopt.CreateCollection(). | ||
SetTimeSeriesOptions( | ||
mopt.TimeSeries(). | ||
SetTimeField("time"). | ||
SetMetaField("meta"), | ||
), | ||
) | ||
require.NoError(t, err, "should create collection") | ||
|
||
_, err = db.Collection("coll").Indexes().CreateOne( | ||
ctx, | ||
mongo.IndexModel{ | ||
Keys: bson.D{{"time", 1}}, | ||
Options: mopt.Index(). | ||
SetPartialFilterExpression( | ||
bson.D{{"meta", 123123}}, | ||
).SetExpireAfterSeconds( | ||
123123, | ||
), | ||
}, | ||
) | ||
require.NoError(t, err, "should create index") | ||
|
||
withArchiveMongodump(t, func(file string) { | ||
args := []string{ | ||
DropOption, | ||
ArchiveOption + "=" + file, | ||
} | ||
|
||
restore, err := getRestoreWithArgs(args...) | ||
require.NoError(t, err, "restore should run") | ||
defer restore.Close() | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there any specific checks related to restoration of the TTL index that we should include in this test? Like checking if the index was restored with the right TTL for example There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doh! Yes, I should add that. |
||
result := restore.Restore() | ||
require.NoError(t, result.Err, "can run mongorestore (result: %+v)", result) | ||
require.EqualValues(t, 0, result.Failures, "mongorestore reports 0 failures") | ||
}) | ||
} | ||
|
||
func TestRestoreTimeseriesCollections(t *testing.T) { | ||
testtype.SkipUnlessTestType(t, testtype.IntegrationTestType) | ||
ctx := context.Background() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should we call this GetFCVFatal or similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nvm this is in use already and renaming requires renaming everything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, renaming is easy enough with IDEs … I’ll call it
GetFCVOrPanic
.