Skip to content

Commit 143a9c4

Browse files
committed
Ensure that the namespaced collections in the logs db are removed
Tests create namespaced (by UUID) capped collections for their logs. These collections must be removed at teardown; otherwise, their number will grow without any bound and cause sequential teardowns to take longer and longer.
1 parent 2c7ee85 commit 143a9c4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

mgo.go

+14
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,20 @@ func clearCollections(db *mgo.Database) error {
763763
if err != nil {
764764
return errors.Trace(err)
765765
}
766+
767+
// The "logs" db is special because tests create namespaced capped
768+
// collections for their logs. Contrary to the other DBs where we
769+
// just flush their contents, we need to drop any collection in the
770+
// "logs" db to avoid an unbounded growth of capped collections.
771+
if db.Name == "logs" {
772+
for _, name := range collectionNames {
773+
if err = db.C(name).DropCollection(); err != nil {
774+
return errors.Trace(err)
775+
}
776+
}
777+
return nil
778+
}
779+
766780
for _, name := range collectionNames {
767781
if strings.HasPrefix(name, "system.") {
768782
continue

0 commit comments

Comments
 (0)