code: def test_autoscaler_v2_stream_events(
      ray_start_cluster_head_with_env_vars,
  ):
      """
      Test in autoscaler v2, autoscaler events are streamed directly from
      events file
      """
  
      script = """
  import ray
  import time
  from ray.core.generated.event_pb2 import Event as RayEvent
  from ray._private.event.event_logger import get_event_logger
  
  ray.init("auto")
  
  # Get event logger to write autoscaler events.
  log_dir = ray._private.worker.global_worker.node.get_logs_dir_path()
  event_logger = get_event_logger(RayEvent.SourceType.AUTOSCALER, log_dir)
  event_logger.info("Test autoscaler event")
  
  # Block and sleep
  time.sleep(3)
      """
  
      proc = run_string_as_driver_nonblocking(script)
  
      def verify():
          out_str = proc.stdout.read().decode("ascii")
          print(out_str)
          assert out_str and "Test autoscaler event" in out_str
          return True
  
      wait_for_condition(verify)
  
imports: import os
  import re
  import signal
  import subprocess
  import sys
  import time
  import pytest
  import ray
  from ray._private.test_utils import run_string_as_driver, run_string_as_driver_nonblocking, wait_for_condition
label_desc: Use image node_id 12 for calling a global function with example usage: test_autoscaler_v2_stream_events(ray_start_cluster_head_with_env_vars) and returns: True