code: def test_hosted_external_dashboard_url(
      override_url, shutdown_only, monkeypatch
  ):
      """
      Test setting external dashboard URL through environment variable.
      """
      with monkeypatch.context() as m:
          if override_url:
              m.setenv(
                  RAY_OVERRIDE_DASHBOARD_URL,
                  override_url,
              )
  
          expected_localhost_url = "127.0.0.1:8265"
          if not override_url:
              # No external dashboard url
              expected_dashboard_url = "127.0.0.1:8265"
          elif "://" in override_url:
              # External dashboard url with https protocol included
              expected_dashboard_url = override_url[
                  override_url.index("://") + 3 :
              ]
          else:
              # External dashboard url with no protocol
              expected_dashboard_url = override_url
  
          info = ray.init(dashboard_port=8265)
          assert info.dashboard_url == expected_dashboard_url
          assert (
              info.address_info["webui_url"] == expected_dashboard_url
          )
          assert (
              ray._private.worker._global_node.webui_url
              == expected_localhost_url
          )
          assert (
              ray_address_to_api_server_url("auto")
              == "http://" + expected_localhost_url
          )
  
imports: import logging
  import os
  import sys
  import unittest.mock
  import tempfile
  import shutil
  from unittest.mock import patch
  import pytest
  import ray
  from ray._private.ray_constants import RAY_OVERRIDE_DASHBOARD_URL, DEFAULT_RESOURCES
  from ray.air.util.node import _get_node_id_from_node_ip
  import ray._private.services
  from ray._private.services import get_node_ip_address
  from ray.dashboard.utils import ray_address_to_api_server_url
  from ray._private.test_utils import get_current_unused_port, run_string_as_driver, wait_for_condition
  from ray.util.client.ray_client_helpers import ray_start_client_server
label_desc: Use image node_id 8 for calling a global function with example usage: test_hosted_external_dashboard_url(override_url, shutdown_only, monkeypatch) without return types