[BF] test_heartbeat_awaited_flag

XMLWordPrintableJSON

    • Type: Build Failure
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Tests
    • None
    • Python Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Name of Failure:

      Task test-server-version-pypy3.11-sync-noauth-nossl-standalone-cov on build variant mongodb-v8.0 failed due to test test.test_streaming_protocol.TestStreamingProtocol.test_heartbeat_awaited_flag.

      Link to task:

      https://spruce.corp.mongodb.com/task/mongo_python_driver_mongodb_v8.0_test_server_version_pypy3.11_sync_noauth_nossl_standalone_cov_d03d621ef5fe567f941f4c28395a376a1899f77c_26_08_05_19_42_43/tests?execution=0

      Context of when and why the failure occurred:

      This appears to be a flake, not a new regression. The task passed on the 9 runs immediately preceding this one (revisions bf1c57750e through 674203727b, 2026-07-27 through 2026-08-05), then failed on revision d03d621ef5 (2026-08-05). Reliability data for this task over the last 28 days (2026-07-17 to 2026-08-14) shows 18 successes out of 28 total runs, with an earlier cluster of 4 failures around 2026-07-24. The test waits up to 10 seconds for a ServerHeartbeatFailedEvent to be published after triggering a failCommand that closes the connection on heartbeat commands, and times out without seeing the event — consistent with a timing-sensitive test rather than a product defect.

      Stack trace:

      FAILURE: AssertionError: Didn't ever published failed event ()
      self = <test.test_streaming_protocol.TestStreamingProtocol testMethod=test_heartbeat_awaited_flag>
      
          @client_context.require_failCommand_appName
          def test_heartbeat_awaited_flag(self):
              hb_listener = HeartbeatEventListener()
              client = self.single_client(
                  event_listeners=[hb_listener],
                  heartbeatFrequencyMS=500,
                  appName="heartbeatEventAwaitedFlag",
              )
              # Force a connection.
              client.admin.command("ping")
      
              def hb_succeeded(event):
                  return isinstance(event, monitoring.ServerHeartbeatSucceededEvent)
      
              def hb_failed(event):
                  return isinstance(event, monitoring.ServerHeartbeatFailedEvent)
      
              fail_heartbeat = {
                  "mode": {"times": 2},
                  "data": {
                      "failCommands": [HelloCompat.LEGACY_CMD, "hello"],
                      "closeConnection": True,
                      "appName": "heartbeatEventAwaitedFlag",
                  },
              }
              with self.fail_point(fail_heartbeat):
      >           wait_until(lambda: hb_listener.matching(hb_failed), "published failed event")
      test/test_streaming_protocol.py:203:
      _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
      predicate = <function TestStreamingProtocol.test_heartbeat_awaited_flag.<locals>.<lambda> at 0x00000000206f03e0>
      success_description = 'published failed event', timeout = 10
          def wait_until(predicate, success_description, timeout=10):
              start = time.time()
              interval = min(float(timeout) / 100, 0.1)
              while True:
                  if iscoroutinefunction(predicate):
                      retval = predicate()
                  else:
                      retval = predicate()
                  if retval:
                      return retval
      
                  if time.time() - start > timeout:
      >               raise AssertionError("Didn't ever %s" % success_description)
      E               AssertionError: Didn't ever published failed event
      test/utils.py:80: AssertionError
      

            Assignee:
            Steve Silvester
            Reporter:
            Steve Silvester
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: