-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: Unified Test Runner
Problem
The unified test runner (UnifiedTestRunner) creates fresh driver objects (clients, databases) for each test run, but does NOT drop the underlying MongoDB databases and collections. This causes test pollution where collections created by one test variant persist and affect subsequent test variants.
Impact
This particularly affects tests that assume collections don't exist:
- create_collection.json test fails intermittently on MongoDB < 7.0 (error 48 "collection already exists")
- MongoDB 7.0+ made createCollection idempotent, masking the issue
- Each unified spec test generates TWO xUnit test cases (async=True and async=False)
- Collections created by the first test case interferes with the next test case which doesn't expect the collection to exist.
Current Workaround
Skipped create_collection.json tests for MongoDB < 7.0 in CSHARP-3124 (OpenTelemetry implementation).
Root Cause
Location: tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedEntityMap.cs:289-308 (Dispose method)
The Dispose() method:
- Closes client connections
- Does NOT drop databases
- Does NOT drop collections
Proposed Solution
Update UnifiedEntityMap.Dispose() to clean up databases created during the test:
1. Track which databases were created via CreateDatabase() entity operation
2. Drop those databases in Dispose() method
3. Ensure cleanup happens even if test fails
Constraints
- Verify this doesn't break other spec test suites that may depend on persistence