code: def test_raylet_and_agent_share_fate(shutdown_only):
      """Test raylet and agent share fate."""
  
      ray.init()
      p = init_error_pubsub()
  
      node = ray._private.worker._global_node
      all_processes = node.all_processes
      raylet_proc_info = all_processes[
          ray_constants.PROCESS_TYPE_RAYLET
      ][0]
      raylet_proc = psutil.Process(raylet_proc_info.process.pid)
  
      wait_for_condition(lambda: search_agent(raylet_proc.children()))
      agent_proc = search_agent(raylet_proc.children())
      agent_pid = agent_proc.pid
  
      check_agent_register(raylet_proc, agent_pid)
  
      # The agent should be dead if raylet exits.
      raylet_proc.terminate()
      raylet_proc.wait()
      agent_proc.wait(15)
  
      # No error should be reported for graceful termination.
      errors = get_error_message(p, 1, ray_constants.RAYLET_DIED_ERROR)
      assert len(errors) == 0, errors
  
      ray.shutdown()
  
      ray.init()
      all_processes = ray._private.worker._global_node.all_processes
      raylet_proc_info = all_processes[
          ray_constants.PROCESS_TYPE_RAYLET
      ][0]
      raylet_proc = psutil.Process(raylet_proc_info.process.pid)
      wait_for_condition(lambda: search_agent(raylet_proc.children()))
      agent_proc = search_agent(raylet_proc.children())
      agent_pid = agent_proc.pid
  
      check_agent_register(raylet_proc, agent_pid)
  
      # The raylet should be dead if agent exits.
      agent_proc.kill()
      agent_proc.wait()
      raylet_proc.wait(15)
  
file_path: ray/python/ray/tests/test_runtime_env_agent.py
imports: import sys
  import pytest
  import logging
  import os
  import time
  from typing import List, Tuple
  import ray
  from ray._private.runtime_env.agent.runtime_env_agent import UriType, ReferenceTable
  from ray._private import ray_constants
  from ray._private.test_utils import get_error_message, init_error_pubsub, wait_for_condition
  from ray.runtime_env import RuntimeEnv
  import psutil
label_desc: Use image node_id 4 for calling a global function with example usage: test_raylet_and_agent_share_fate(shutdown_only) without return types