code: def run_release_test(
      test: Test,
      anyscale_project: str,
      result: Result,
      reporters: Optional[List[Reporter]] = None,
      smoke_test: bool = False,
      cluster_id: Optional[str] = None,
      cluster_env_id: Optional[str] = None,
      no_terminate: bool = False,
  ) -> Result:
      old_wd = os.getcwd()
      start_time = time.monotonic()
      command_runner = None
      cluster_manager = None
      pipeline_exception = None
      # non critical for some tests. So separate it from the general one.
      fetch_result_exception = None
      try:
          buildkite_group(
              ":spiral_note_pad: Loading test configuration"
          )
          (
              cluster_manager,
              command_runner,
              artifact_path,
          ) = _load_test_configuration(
              test,
              anyscale_project,
              result,
              smoke_test,
              no_terminate,
          )
          buildkite_group(
              ":nut_and_bolt: Setting up cluster environment"
          )
          (
              prepare_cmd,
              prepare_timeout,
              build_timeout,
              cluster_timeout,
              command_timeout,
          ) = _setup_cluster_environment(
              test,
              result,
              cluster_manager,
              cluster_env_id,
          )
  
          buildkite_group(":bulb: Local environment information")
          _local_environment_information(
              result,
              cluster_manager,
              command_runner,
              build_timeout,
              cluster_timeout,
              no_terminate,
              cluster_id,
              cluster_env_id,
          )
  
          # Upload files
          buildkite_group(":wrench: Preparing remote environment")
          _prepare_remote_environment(
              test,
              command_runner,
              prepare_cmd,
              prepare_timeout,
          )
  
          buildkite_group(":runner: Running test script")
          start_time_unix = time.time()
          _running_test_script(
              test,
              smoke_test,
              command_runner,
              command_timeout,
          )
  
          buildkite_group(":floppy_disk: Fetching results")
          metrics, fetch_result_exception = _fetching_results(
              result,
              command_runner,
              artifact_path,
              smoke_test,
              start_time_unix,
          )
      except Exception as e:
          logger.exception(e)
          buildkite_open_last()
          pipeline_exception = e
          metrics = {}
  
      # Obtain the cluster URL again as it is set after the
      # command was run in case of anyscale jobs
      if isinstance(command_runner, AnyscaleJobRunner):
          result.cluster_url = cluster_manager.get_cluster_url()
          result.cluster_id = cluster_manager.cluster_id
          result.job_url = command_runner.job_manager.job_url
          result.job_id = command_runner.job_manager.job_id
  
      result.last_logs = (
          command_runner.get_last_logs() if command_runner else None
      )
  
      if not no_terminate and cluster_manager:
          buildkite_group(":earth_africa: Terminating cluster")
          cluster_manager.terminate_cluster(wait=False)
  
      if hasattr(command_runner, "cleanup"):
          command_runner.cleanup()
  
      reset_signal_handling()
  
      time_taken = time.monotonic() - start_time
      result.runtime = time_taken
      result.prometheus_metrics = metrics
  
      os.chdir(old_wd)
  
      if not pipeline_exception:
          if require_result(test) and fetch_result_exception:
              pipeline_exception = fetch_result_exception
          else:
              buildkite_group(":mag: Interpreting results")
              # Only handle results if we didn't run into issues earlier
              try:
                  handle_result(test, result)
              except Exception as e:
                  pipeline_exception = e
  
      if pipeline_exception:
          buildkite_group(":rotating_light: Handling errors")
          exit_code, result_status, runtime = handle_exception(
              pipeline_exception,
              result.runtime,
          )
  
          result.return_code = exit_code.value
          result.status = result_status.value
          if runtime is not None:
              result.runtime = runtime
          try:
              raise pipeline_exception
          except Exception:
              if not result.last_logs:
                  result.last_logs = traceback.format_exc()
  
      buildkite_group(":memo: Reporting results", open=True)
      for reporter in reporters or []:
          reporter.report_result(test, result)
  
      if pipeline_exception:
          raise pipeline_exception
  
      return result
  
imports: import os
  import time
  import traceback
  from typing import Optional, List, Tuple
  from ray_release.alerts.handle import handle_result, require_result
  from ray_release.anyscale_util import get_cluster_name
  from ray_release.buildkite.output import buildkite_group, buildkite_open_last
  from ray_release.cluster_manager.cluster_manager import ClusterManager
  from ray_release.cluster_manager.full import FullClusterManager
  from ray_release.cluster_manager.minimal import MinimalClusterManager
  from ray_release.command_runner.job_runner import JobRunner
  from ray_release.command_runner.command_runner import CommandRunner
  from ray_release.command_runner.anyscale_job_runner import AnyscaleJobRunner
  from ray_release.test import Test
  from ray_release.config import DEFAULT_BUILD_TIMEOUT, DEFAULT_CLUSTER_TIMEOUT, DEFAULT_COMMAND_TIMEOUT, DEFAULT_WAIT_FOR_NODES_TIMEOUT, RELEASE_PACKAGE_DIR, DEFAULT_AUTOSUSPEND_MINS
  from ray_release.template import load_test_cluster_compute
  from ray_release.exception import ReleaseTestConfigError, ReleaseTestSetupError, CommandError, PrepareCommandError, CommandTimeout, PrepareCommandTimeout, TestCommandError, TestCommandTimeout, ClusterEnvCreateError
  from ray_release.file_manager.job_file_manager import JobFileManager
  from ray_release.logger import logger
  from ray_release.reporter.reporter import Reporter
  from ray_release.result import Result, ResultStatus, handle_exception
  from ray_release.signal_handling import setup_signal_handling, reset_signal_handling, register_handler
label_desc: Use image node_id 8 for calling a global function with example usage: run_release_test(test, anyscale_project, result, reporters, smoke_test, cluster_id, cluster_env_id, no_terminate) and returns: result