Copilot commented on code in PR #16357:
URL: https://github.com/apache/grails-core/pull/16357#discussion_r4061825234


##########
grails-data-mongodb/core/src/test/groovy/org/apache/grails/data/mongo/core/GrailsDataMongoTckManager.groovy:
##########
@@ -168,6 +177,26 @@ class GrailsDataMongoTckManager extends 
GrailsDataTckManager {
         super.destroy()
     }
 
+    /**
+     * Removes the documents but keeps the collections and their indexes. The 
datastore of the next feature
+     * finds them in place, whereas dropping the database makes it create 
every collection and index again,
+     * and WiredTiger keeps the files of the dropped ones open until its next 
checkpoint.
+     */
+    private void clearDatabase(MongoDatabase database) {
+        for (String collectionName in database.listCollectionNames()) {
+            if (collectionName.startsWith('system.')) {
+                continue
+            }
+            try {
+                database.getCollection(collectionName).deleteMany(new 
Document())
+            }
+            catch (ignored) {
+                // e.g. capped collections do not support deletes
+                database.getCollection(collectionName).drop()

Review Comment:
   The new fallback for capped or otherwise non-deletable collections is 
untested. Add an integration case that creates a capped collection, runs 
cleanup, and verifies that the capped collection is dropped while ordinary 
collections and their data cleanup still succeed; otherwise this newly 
introduced isolation path can regress unnoticed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to