spring-data-mongodb
spring-data-mongodb copied to clipboard
Disabling test for fullDocumentBeforeChange and not supported version of MongoDB
Field fullDocumentBeforeChange on $changeStream introduced on version 6.0, disabling failing JUnit.
- [x] You have read the Spring Data contribution guidelines.
- [x] You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
- [x] You submit test cases (unit or integration tests) that back your changes.
- [x] You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).
Please spend some time describing the problem here since the current arrangement does not seem to cause any trouble.
Try to run tests using MongoDB version which is not supporting fullDocumentBeforeChange field (<6.0) - JUnit is failing. It would be good to cleanup (remove it) but for now I've disabled it.
works as expected for 5.0.14
I'll provide error logs today evening or tomorrow (for version 4.X)
MongoDB server version: 4.2.3
2023-01-19 21:34:36,528 ERROR rContainer$DecoratingLoggingErrorHandler: 282 - Unexpected error occurred while listening to MongoDB org.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 40415 (Location40415): 'BSON field '$changeStream.fullDocumentBeforeChange' is an unknown field.' on server 127.0.0.1:27017. The full response is {"operationTime": {"$timestamp": {"t": 1674160476, "i": 1}}, "ok": 0.0, "errmsg": "BSON field '$changeStream.fullDocumentBeforeChange' is an unknown field.", "code": 40415, "codeName": "Location40415", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1674160476, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}}
Documentation: https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStream/
On drivers it was introduced on version 4.7 on which full support for MongoDB 6.0 was added: https://github.com/mongodb/mongo-java-driver/blob/4.7.x/driver-core/src/main/com/mongodb/client/model/changestream/ChangeStreamDocument.java
https://www.mongodb.com/docs/drivers/java/sync/current/whats-new/#std-label-version-4.7.0
I see, so instead of disabling the test @EnableIfMongoServerVersion(isGreaterThanEqual = "5.0", isLessThan = "6.0") would solve the issue.
Correct, if it's working somehow for version 5 even if Mongo is supporting this field from version 6. I'll update PR today.