Testing, operations, and ecosystem
Latest stable Based on Bluetape4k release 1.11.0
1.11.0 test structure
Section titled “1.11.0 test structure”AbstractReactiveMongoTest lazily starts a MongoDBServer Testcontainer and registers spring.data.mongodb.uri dynamically. AbstractReactiveMongoCoroutineTest adds a test scope with Dispatchers.IO and a CoroutineName.
ReactiveMongoOperationsCoroutinesTest uses a real Spring Boot context and MongoDB to verify:
- insert and save;
- Flow, optional, and required reads;
- count and exists;
- update-first, update-multi, and upsert;
- remove, find-and-modify, and find-and-remove;
- distinct and aggregation;
- collection existence, creation, and removal.
The three query-DSL test classes compare BSON structures without a server. Run the fast DSL checks first, then serialize the Docker-backed suite with other Testcontainers work.
Isolate test data
Section titled “Isolate test data”The integration suite uses the dedicated test_users collection. Give each test a unique business key such as email and remove only documents created by that test. Assertions against a shared collection’s absolute count are sensitive to execution order and parallelism.
./gradlew :bluetape4k-spring-boot-mongodb:test \ --no-build-cache --no-configuration-cacheOperational signals
Section titled “Operational signals”The module adds no metrics, so use Spring Boot and MongoDB driver observation.
| Signal | Possible problem |
|---|---|
| Server-selection time | Topology change, DNS/network issues, no primary |
| Pool wait and in-use connections | Pool exhaustion, long query, slow Flow consumer |
| Command latency and error code | Missing index, timeout, duplicate key, write concern |
| Cancellation and request latency | Client disconnect, deadline, excessive result size |
| Active subscriptions during shutdown | Tailable cursor or coroutine scope not closed |
Choose the MongoDB layer
Section titled “Choose the MongoDB layer”| Need | Starting point |
|---|---|
Spring Data mapping, ReactiveMongoOperations, and coroutines | This module |
| Spring Data repository interface | Spring Data reactive/coroutine repository |
| Direct MongoDB Kotlin driver, codec, and collection control | bluetape4k-mongodb |
| Spring Boot client, properties, and health configuration | Spring Boot MongoDB auto-configuration |
Both bluetape4k modules can be present, but avoid casually mixing Spring Data mapping and native codec mapping in one repository. Assign document wire format and transaction/session ownership to one clear layer.
Source and tests
Section titled “Source and tests”AbstractReactiveMongoTest.ktAbstractReactiveMongoCoroutineTest.ktMongoTestApplication.ktReactiveMongoOperationsCoroutinesTest.ktUser.kt
Next step
Section titled “Next step”After choosing the layer, return to Auto-configuration and ownership boundaries and pin the beans and settings owned by the application.