-
Notifications
You must be signed in to change notification settings - Fork 50
fix: expire index already exists not triggering on v7 (#98) #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughException handling in MongoDB helper methods updated to match exceptions using CodeName property instead of substring matching in ErrorMessage, improving reliability across MongoDB versions 4.4 through 7.0+. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@ntark Thank you for the PR with the fix to this issue. LGTM! Merging. |
Add unit tests for PR #99 to verify MongoDB error code handling works correctly across different MongoDB versions. Tests validate: - VerifyCollectionExists handles NamespaceExists (error code 48) - VerifyExpireTTLSetup handles IndexOptionsConflict (error code 85) - Race condition handling when collections are created concurrently - TTL index creation, updates, and removal scenarios - Error code validation to ensure MongoDB driver compatibility The tests use the actual MongoDB driver behavior to confirm that CodeName-based exception filtering is more reliable than string matching and works across MongoDB versions 4.x through 7.x. Changes: - Add NSubstitute 5.3.0 for mocking support - Add MongoDbHelperErrorHandlingTests.cs with 12 comprehensive tests - Update GlobalUsings.cs to include NSubstitute All 27 tests pass (15 existing + 12 new).
#100) * test: add comprehensive unit tests for MongoDB error handling Add unit tests for PR #99 to verify MongoDB error code handling works correctly across different MongoDB versions. Tests validate: - VerifyCollectionExists handles NamespaceExists (error code 48) - VerifyExpireTTLSetup handles IndexOptionsConflict (error code 85) - Race condition handling when collections are created concurrently - TTL index creation, updates, and removal scenarios - Error code validation to ensure MongoDB driver compatibility The tests use the actual MongoDB driver behavior to confirm that CodeName-based exception filtering is more reliable than string matching and works across MongoDB versions 4.x through 7.x. Changes: - Add NSubstitute 5.3.0 for mocking support - Add MongoDbHelperErrorHandlingTests.cs with 12 comprehensive tests - Update GlobalUsings.cs to include NSubstitute All 27 tests pass (15 existing + 12 new). * ci: skip NuGet package generation during test runs Update the GitHub Actions workflow to add `-p:GeneratePackageOnBuild=false` to the dotnet test command. This prevents unnecessary package creation during CI test runs, improving build performance. The project has `<GeneratePackageOnBuild>true</GeneratePackageOnBuild>` set, which causes packages to be created on every build, including test runs. Packages are still properly created during the "Pack" step for releases. Benefits: - Faster CI test execution - Cleaner build output - Packages only created when actually needed (Release builds) * test: address CodeRabbit review suggestions Apply all CodeRabbit nitpick suggestions to improve test quality: 1. **Test Isolation**: Add [NonParallelizable] attribute to prevent concurrent test execution issues when using shared database name 2. **Dependency Management**: Add PrivateAssets="all" to NSubstitute package reference to prevent transitive dependency exposure 3. **Cleanup Optimization**: Remove redundant DropDatabase calls within test methods since cleanup is handled by [TearDown] 4. **Cross-Version Compatibility**: Fix TTL assertion type handling to support MongoDB's Int64/Double serialization variations across server versions by using Convert.ToInt64() 5. **Race Condition Testing**: Improve authenticity of race condition test by using Parallel.Invoke() to force genuine concurrent collection creation attempts, exercising the actual NamespaceExists error path All 12 tests continue to pass. These changes improve test robustness, reduce runtime overhead, and ensure compatibility across MongoDB versions.
Update version and release notes for v7.2.0 release: Changes: - MongoDB v7.x compatibility fix using error codes (#98, #99) Thanks to @ntark for the PR! - Comprehensive unit tests for error handling (#100) - CI workflow optimization Updated files: - CHANGES.md: Added v7.2.0 release notes with contributor attribution - README.md: Updated "What's New" section and added link to CHANGES.md - Serilog.Sinks.MongoDB.csproj: Bumped version to 7.2.0, updated copyright year to 2025, and updated PackageReleaseNotes
Chose to compare by
CodeNamefor claity vsex.Code == 85.Change is Backwards-Compatible.
Closes #98