code: def test_shutdown_remote(start_and_shutdown_ray_cli_function):
      """Check that serve.shutdown() works on a remote Ray cluster."""
  
      deploy_serve_script = (
          "import ray\n"
          "from ray import serve\n"
          "\n"
          'ray.init(address="auto", namespace="x")\n'
          "serve.start()\n"
          "\n"
          "@serve.deployment\n"
          "def f(*args):\n"
          '   return "got f"\n'
          "\n"
          "serve.run(f.bind())\n"
      )
  
      shutdown_serve_script = (
          "import ray\n"
          "from ray import serve\n"
          "\n"
          'ray.init(address="auto", namespace="x")\n'
          "serve.shutdown()\n"
      )
  
      # Cannot use context manager due to tmp file's delete flag issue in Windows
      # https://stackoverflow.com/a/15590253
      deploy_file = NamedTemporaryFile(
          mode="w+", delete=False, suffix=".py"
      )
      shutdown_file = NamedTemporaryFile(
          mode="w+", delete=False, suffix=".py"
      )
  
      try:
          deploy_file.write(deploy_serve_script)
          deploy_file.close()
  
          shutdown_file.write(shutdown_serve_script)
          shutdown_file.close()
  
          # Ensure Serve can be restarted and shutdown with for loop
          for _ in range(2):
              subprocess.check_output(["python", deploy_file.name])
              assert (
                  requests.get("http://localhost:8000/f").text
                  == "got f"
              )
              subprocess.check_output(["python", shutdown_file.name])
              with pytest.raises(requests.exceptions.ConnectionError):
                  requests.get("http://localhost:8000/f")
      finally:
          os.unlink(deploy_file.name)
          os.unlink(shutdown_file.name)
  
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 6 for calling a global function with example usage: test_shutdown_remote(start_and_shutdown_ray_cli_function) without return types