Stop the embedded MongoDB once - #16190
Conversation
The lifecycle bean stops the server when the application context closes, and the JVM shutdown hook - which is there for a context that never closes - stops it again when the process exits. Flapdoodle removes the process directory as it tears the server down, so the second teardown failed on the files the first one had already deleted, and every run of an application or a test that uses a real mongod ended with a TearDownException on a shutdown thread. CI reports it as an error against a build whose tests all passed. Stopping the flapdoodle server is idempotent now, as stopping the in-memory one already was, and so is starting one that is already running. Both are covered.
🚨 TestLens detected 9 failed tests 🚨Here is what you can do:
Test SummaryCI - Groovy Joint Validation Build / Build Grails with Groovy snapshot (shard 1) > :grails-data-mongodb-core:test
🏷️ Commit: 3cb9462 Test FailuresMongoTransactionSpec > test a REQUIRES_NEW inner transaction commits independently of a rolled back outer transaction (:grails-data-mongodb-core:test in CI - Groovy Joint Validation Build / Build Grails with Groovy snapshot (shard 1))MongoTransactionSpec > test a committed transaction persists all writes atomically (:grails-data-mongodb-core:test in CI - Groovy Joint Validation Build / Build Grails with Groovy snapshot (shard 1))MongoTransactionSpec > test a findOneAndDelete via the MongoEntity API participates in the transaction (:grails-data-mongodb-core:test in CI - Groovy Joint Validation Build / Build Grails with Groovy snapshot (shard 1))MongoTransactionSpec > test a per-transaction timeout is rejected rather than silently ignored (:grails-data-mongodb-core:test in CI - Groovy Joint Validation Build / Build Grails with Groovy snapshot (shard 1))MongoTransactionSpec > test a rolled back transaction discards a native Long id entity (id generation is non-transactional) (:grails-data-mongodb-core:test in CI - Groovy Joint Validation Build / Build Grails with Groovy snapshot (shard 1))MongoTransactionSpec > test a rolled back transaction discards all writes on the server (:grails-data-mongodb-core:test in CI - Groovy Joint Validation Build / Build Grails with Groovy snapshot (shard 1))MongoTransactionSpec > test native Long identifier generation works for entities committed in a transaction (:grails-data-mongodb-core:test in CI - Groovy Joint Validation Build / Build Grails with Groovy snapshot (shard 1))MongoTransactionSpec > test read-your-writes within an active transaction (:grails-data-mongodb-core:test in CI - Groovy Joint Validation Build / Build Grails with Groovy snapshot (shard 1))MongoTransactionSpec > test writes across multiple collections roll back together (:grails-data-mongodb-core:test in CI - Groovy Joint Validation Build / Build Grails with Groovy snapshot (shard 1))Rerun ControlsNote Checks are currently running using the configuration below. Select tests to mute in this pull request: 🔲 MongoTransactionSpec > test a REQUIRES_NEW inner transaction commits independently of a rolled back outer transaction Reuse successful test results: 🔲 ♻️ Only rerun the tests that failed or were muted before Click the checkbox to trigger a rerun: 🔲 Rerun jobs Learn more about TestLens at testlens.app/docs. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 8.0.x #16190 +/- ##
==================================================
- Coverage 53.7560% 53.7448% -0.0113%
+ Complexity 19829 19819 -10
==================================================
Files 2086 2086
Lines 99667 99673 +6
Branches 17603 17605 +2
==================================================
- Hits 53577 53569 -8
- Misses 38428 38437 +9
- Partials 7662 7667 +5
🚀 New features to boost your workflow:
|
|
Folded into #16192, which already carries this commit — one review rather than two. The stop-once fix belongs with that change anyway: the four specifications it moves onto an embedded server start and stop one routinely, so a teardown that fails the second time would be noise on every run. |
Every run that starts a real mongod ends with this on a shutdown thread, against a build whose
tests all passed:
The server is stopped twice.
EmbeddedMongoLifecyclestops it when the application context closes,and the JVM shutdown hook - which is there for a context that never closes - stops it again when the
process exits. Flapdoodle removes the process directory as it tears the server down, so the second
teardown fails on the files the first one deleted.
Stopping is idempotent now, and so is starting a server that is already running. The in-memory
backend already tolerated both; a spec covers each.