Unified test runner should clean up databases/collections between test runs

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: Unified Test Runner
    • None
    • Dotnet Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      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

            Assignee:
            Unassigned
            Reporter:
            Adelin Mbida Owona
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: