code: def test_log_file_exists(shutdown_only):
      """Verify all log files exist as specified in
      https://docs.ray.io/en/master/ray-observability/ray-logging.html#logging-directory-structure # noqa
      """
      ray.init(num_cpus=1)
      session_dir = ray._private.worker.global_worker.node.address_info[
          "session_dir"
      ]
      session_path = Path(session_dir)
      log_dir_path = session_path / "logs"
  
      log_rotating_component = [
          (ray_constants.PROCESS_TYPE_DASHBOARD, [".log", ".err"]),
          (ray_constants.PROCESS_TYPE_DASHBOARD_AGENT, [".log"]),
          (
              ray_constants.PROCESS_TYPE_RUNTIME_ENV_AGENT,
              [".log", ".out", ".err"],
          ),
          (ray_constants.PROCESS_TYPE_LOG_MONITOR, [".log", ".err"]),
          (
              ray_constants.PROCESS_TYPE_MONITOR,
              [".log", ".out", ".err"],
          ),
          (
              ray_constants.PROCESS_TYPE_PYTHON_CORE_WORKER_DRIVER,
              [".log"],
          ),
          (ray_constants.PROCESS_TYPE_PYTHON_CORE_WORKER, [".log"]),
          # Below components are not log rotating now.
          (ray_constants.PROCESS_TYPE_RAYLET, [".out", ".err"]),
          (ray_constants.PROCESS_TYPE_GCS_SERVER, [".out", ".err"]),
          (ray_constants.PROCESS_TYPE_WORKER, [".out", ".err"]),
      ]
  
      # Run the basic workload.
      @ray.remote
      def f():
          for i in range(10):
              print(f"test {i}")
  
      # Create a runtime env to make sure dashboard agent is alive.
      ray.get(
          f.options(
              runtime_env={"env_vars": {"A": "a", "B": "b"}}
          ).remote()
      )
  
      paths = list(log_dir_path.iterdir())
  
      def component_and_suffix_exists(component, paths):
          component, suffixes = component
          for path in paths:
              filename = path.stem
              suffix = path.suffix
              if component in filename:
                  # core-worker log also contains "worker keyword". We ignore this case.
                  if (
                      component == ray_constants.PROCESS_TYPE_WORKER
                      and ray_constants.PROCESS_TYPE_PYTHON_CORE_WORKER
                      in filename
                  ):
                      continue
                  if suffix in suffixes:
                      return True
                  else:
                      # unexpected suffix.
                      return False
  
          return False
  
      for component in log_rotating_component:
          assert component_and_suffix_exists(component, paths), (
              component,
              paths,
          )
  
imports: import io
  import os
  import re
  import subprocess
  import sys
  import tempfile
  import time
  import logging
  from collections import Counter, defaultdict
  from contextlib import redirect_stderr, redirect_stdout
  from pathlib import Path
  from unittest.mock import Mock, MagicMock
  import pytest
  import ray
  from ray._private import ray_constants
  from ray._private.log_monitor import LOG_NAME_UPDATE_INTERVAL_S, RAY_LOG_MONITOR_MANY_FILES_THRESHOLD, LogFileInfo, LogMonitor, is_proc_alive
  from ray._private.test_utils import get_log_batch, get_log_message, get_log_data, init_log_pubsub, run_string_as_driver, wait_for_condition
  from ray.cross_language import java_actor_class
  from ray.autoscaler._private.cli_logger import cli_logger
label_desc: Use image node_id 5 for calling a global function with example usage: test_log_file_exists(shutdown_only) and returns: False, True, False