Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-2068

Replace all uses of isPoolCleared() and clearPoolChan() in tests with testPoolMonitor

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None

      Various mongo/integration package tests currently use a package-global event.PoolMonitor variable poolMonitor to collect connection pool events and the package-global functions isPoolCleared() and clearPoolChan() to manage the collected events. The result is that different tests and test cases can sometimes interact with each others events, causing intermittent assertion failures or timeouts on channel sends (e.g. when the poolMonitor's events channel fills up without being cleared).

      To resolve the unexpected interaction between tests, replace all uses of the package-global poolMonitor with individual instances of the new testPoolMonitor. Also, replace isPoolCleared() with the condition:

      poolClearedEvents := tpm.Events(func(evt *event.PoolEvent) bool {
      	return evt.Type == event.PoolCleared
      })
      len(poolClearedEvents) > 0
      

       

      Also consider moving testPoolMonitor into a shared test utilities package and export it. Use it for similar use cases from other tests, like topology.TestServerConnectionTimeout and topology.TestServerConnectionCancellation.

            Assignee:
            matt.dale@mongodb.com Matt Dale
            Reporter:
            matt.dale@mongodb.com Matt Dale
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: