code: def test_raylet_tempfiles(shutdown_only):
      expected_socket_files = (
          {"plasma_store", "raylet"}
          if sys.platform != "win32"
          else set()
      )
  
      ray.init(num_cpus=0)
      node = ray._private.worker._global_node
      top_levels = set(os.listdir(node.get_session_dir_path()))
      assert top_levels.issuperset({"sockets", "logs"})
      log_files_expected = {
          "log_monitor.log",
          "monitor.log",
          "raylet.out",
          "raylet.err",
          "gcs_server.out",
          "gcs_server.err",
          "dashboard.log",
          "dashboard_agent.log",
      }
  
      def check_all_log_file_exists():
          for expected in log_files_expected:
              log_files = set(os.listdir(node.get_logs_dir_path()))
              if expected not in log_files:
                  raise RuntimeError(f"File {expected} not found!")
          return True
  
      wait_for_condition(check_all_log_file_exists)
      # Get the list of log files again since the previous one
      # might have the stale information.
      log_files = set(os.listdir(node.get_logs_dir_path()))
      assert log_files_expected.issubset(log_files)
      assert log_files.issuperset(log_files_expected)
  
      socket_files = set(os.listdir(node.get_sockets_dir_path()))
      assert socket_files == expected_socket_files
      ray.shutdown()
  
      ray.init(num_cpus=2)
      node = ray._private.worker._global_node
      top_levels = set(os.listdir(node.get_session_dir_path()))
      assert top_levels.issuperset({"sockets", "logs"})
      time.sleep(3)  # wait workers to start
      log_files = set(os.listdir(node.get_logs_dir_path()))
  
      assert log_files.issuperset(log_files_expected)
  
      # Check numbers of worker log file.
      assert (
          sum(
              1
              for filename in log_files
              if filename.startswith("worker")
          )
          == 4
      )
  
      socket_files = set(os.listdir(node.get_sockets_dir_path()))
      assert socket_files.issuperset(expected_socket_files)
  
file_path: ray/python/ray/tests/test_tempfile.py
imports: import os
  import shutil
  import sys
  import time
  import pytest
  import ray
  from ray._private.test_utils import check_call_ray, wait_for_condition
label_desc: Use image node_id 7 for calling a global function with example usage: test_raylet_tempfiles(shutdown_only) and returns: True