code: def test_health_check_failure_makes_deployment_unhealthy_transition(
      serve_instance,
  ):
      """
      If a deployment transitions to unhealthy, then continues to fail health check after
      being restarted, the deployment should be unhealthy.
      """
  
      class Toggle:
          def __init__(self):
              self._should_fail = False
  
          def set_should_fail(self):
              self._should_fail = True
  
          def should_fail(self):
              return self._should_fail
  
      @serve.deployment(
          health_check_period_s=1, health_check_timeout_s=1
      )
      class WillBeUnhealthy:
          def __init__(self, toggle):
              self._toggle = toggle
  
          def check_health(self):
              if ray.get(self._toggle.should_fail.remote()):
                  raise Exception("intended to fail")
  
          def __call__(self, *args):
              return ray.get_runtime_context().current_actor
  
      def check_status(expected_status: DeploymentStatus):
          app_status = serve.status().applications[
              SERVE_DEFAULT_APP_NAME
          ]
          assert (
              app_status.deployments["WillBeUnhealthy"].status
              == expected_status
          )
          return True
  
      toggle = ray.remote(Toggle).remote()
      serve.run(WillBeUnhealthy.bind(toggle))
  
      # Check that deployment is healthy initially
      assert check_status(DeploymentStatus.HEALTHY)
  
      ray.get(toggle.set_should_fail.remote())
  
      # Check that deployment is now unhealthy
      wait_for_condition(
          check_status, expected_status=DeploymentStatus.UNHEALTHY
      )
  
      # Check that deployment stays unhealthy
      for _ in range(5):
          assert check_status(DeploymentStatus.UNHEALTHY)
  
imports: import pytest
  import ray
  from ray import serve
  from ray._private.test_utils import wait_for_condition
  from ray.exceptions import RayError
  from ray.serve._private.common import DeploymentStatus
  from ray.serve._private.constants import REPLICA_HEALTH_CHECK_UNHEALTHY_THRESHOLD, SERVE_DEFAULT_APP_NAME
label_desc: Use image node_id 10 for calling a global function with example usage: test_health_check_failure_makes_deployment_unhealthy_transition(serve_instance) and returns: True, self, ray