code: def test_drain_and_undrain_http_proxy_actors(
      monkeypatch, shutdown_ray, call_ray_stop_only  # noqa: F811
  ):
      """Test the state transtion of the proxy actor between
      HEALTHY, DRAINING and DRAINED
      """
      monkeypatch.setenv("RAY_SERVE_PROXY_MIN_DRAINING_PERIOD_S", "10")
  
      cluster = Cluster()
      head_node = cluster.add_node(num_cpus=0)
      cluster.add_node(num_cpus=1)
      cluster.add_node(num_cpus=1)
      cluster.wait_for_nodes()
      ray.init(address=head_node.address)
      serve.start(http_options={"location": "EveryNode"})
  
      @serve.deployment
      class HelloModel:
          def __call__(self):
              return "hello"
  
      serve.run(HelloModel.options(num_replicas=2).bind())
  
      # 3 proxies, 1 controller, 2 replicas.
      wait_for_condition(lambda: len(ray._private.state.actors()) == 6)
      assert len(ray.nodes()) == 3
  
      client = _get_global_client()
      serve_details = ServeInstanceDetails(
          **ray.get(
              client._controller.get_serve_instance_details.remote()
          )
      )
      proxy_actor_ids = {
          proxy.actor_id for _, proxy in serve_details.proxies.items()
      }
      assert len(proxy_actor_ids) == 3
  
      serve.run(HelloModel.options(num_replicas=1).bind())
      # 1 proxy should be draining
  
      def check_proxy_status(proxy_status_to_count):
          serve_details = ServeInstanceDetails(
              **ray.get(
                  client._controller.get_serve_instance_details.remote()
              )
          )
          proxy_status_list = [
              proxy.status for _, proxy in serve_details.proxies.items()
          ]
          print(
              "all proxies!!!",
              [proxy for _, proxy in serve_details.proxies.items()],
          )
          current_status = {
              status: proxy_status_list.count(status)
              for status in proxy_status_list
          }
          return current_status == proxy_status_to_count, current_status
  
      wait_for_condition(
          condition_predictor=check_proxy_status,
          proxy_status_to_count={
              ProxyStatus.HEALTHY: 2,
              ProxyStatus.DRAINING: 1,
          },
      )
  
      serve.run(HelloModel.options(num_replicas=2).bind())
      # The draining proxy should become healthy.
      wait_for_condition(
          condition_predictor=check_proxy_status,
          proxy_status_to_count={ProxyStatus.HEALTHY: 3},
      )
      serve_details = ServeInstanceDetails(
          **ray.get(
              client._controller.get_serve_instance_details.remote()
          )
      )
      {
          proxy.actor_id for _, proxy in serve_details.proxies.items()
      } == proxy_actor_ids
  
      serve.run(HelloModel.options(num_replicas=1).bind())
      # 1 proxy should be draining and eventually be drained.
      wait_for_condition(
          condition_predictor=check_proxy_status,
          timeout=40,
          proxy_status_to_count={ProxyStatus.HEALTHY: 2},
      )
  
      # Clean up serve.
      serve.shutdown()
  
imports: import os
  import subprocess
  import sys
  from contextlib import contextmanager
  from tempfile import NamedTemporaryFile
  import pytest
  import requests
  import ray
  import ray._private.state
  import ray.actor
  from ray import serve
  from ray._private.test_utils import SignalActor, wait_for_condition
  from ray.cluster_utils import AutoscalingCluster, Cluster
  from ray.exceptions import RayActorError
  from ray.serve._private.common import ProxyStatus
  from ray.serve._private.constants import SERVE_DEFAULT_APP_NAME
  from ray.serve._private.logging_utils import get_serve_logs_dir
  from ray.serve._private.utils import get_head_node_id
  from ray.serve.context import _get_global_client
  from ray.serve.schema import ServeInstanceDetails
  from ray.tests.conftest import call_ray_stop_only
label_desc: Use image node_id 9 for calling a global function with example usage: test_drain_and_undrain_http_proxy_actors(monkeypatch, shutdown_ray, call_ray_stop_only) and returns: unknown,  current_status, str