code: def test_node_failure_detector_when_gcs_server_restart(
      ray_start_cluster_head_with_external_redis,
  ):
      """Checks that the node failure detector is correct when gcs server restart.
  
      We set the cluster to timeout nodes after 2 seconds of heartbeats. We then
      kill gcs server and remove the worker node and restart gcs server again to
      check that the removed node will die finally.
      """
      cluster = ray_start_cluster_head_with_external_redis
      worker = cluster.add_node()
      cluster.wait_for_nodes()
  
      # Make sure both head and worker node are alive.
      nodes = ray.nodes()
      assert len(nodes) == 2
      assert nodes[0]["alive"] and nodes[1]["alive"]
  
      to_be_removed_node = None
      for node in nodes:
          if node["RayletSocketName"] == worker.raylet_socket_name:
              to_be_removed_node = node
      assert to_be_removed_node is not None
  
      head_node = cluster.head_node
      gcs_server_process = head_node.all_processes["gcs_server"][
          0
      ].process
      gcs_server_pid = gcs_server_process.pid
      # Kill gcs server.
      cluster.head_node.kill_gcs_server()
      # Wait to prevent the gcs server process becoming zombie.
      gcs_server_process.wait()
      wait_for_pid_to_exit(gcs_server_pid, 1000)
  
      raylet_process = worker.all_processes["raylet"][0].process
      raylet_pid = raylet_process.pid
      # Remove worker node.
      cluster.remove_node(worker, allow_graceful=False)
      # Wait to prevent the raylet process becoming zombie.
      raylet_process.wait()
      wait_for_pid_to_exit(raylet_pid)
  
      # Restart gcs server process.
      cluster.head_node.start_gcs_server()
  
      def condition():
          nodes = ray.nodes()
          assert len(nodes) == 2
          for node in nodes:
              if node["NodeID"] == to_be_removed_node["NodeID"]:
                  return not node["alive"]
          return False
  
      # Wait for the removed node dead.
      wait_for_condition(condition, timeout=10)
  
imports: import sys
  import os
  import threading
  from time import sleep
  import pytest
  import ray
  from ray._private.utils import get_or_create_event_loop
  from ray.util.scheduling_strategies import PlacementGroupSchedulingStrategy
  import ray._private.gcs_utils
  from ray._private import ray_constants
  from ray._private.test_utils import convert_actor_state, enable_external_redis, generate_system_config_map, wait_for_condition, wait_for_pid_to_exit, run_string_as_driver
  from ray.job_submission import JobSubmissionClient, JobStatus
  from ray._raylet import GcsClient
  import psutil
label_desc: Use image node_id 5 for calling a global function with example usage: test_node_failure_detector_when_gcs_server_restart(ray_start_cluster_head_with_external_redis) and returns: False, unknown