code: def test_multi_node_metrics_export_port_discovery(ray_start_cluster):
      NUM_NODES = 3
      cluster = ray_start_cluster
      nodes = [cluster.add_node() for _ in range(NUM_NODES)]
      nodes = {
          node.address_info["metrics_export_port"]: node.address_info
          for node in nodes
      }
      cluster.wait_for_nodes()
      ray.init(address=cluster.address)
      node_info_list = ray.nodes()
  
      for node_info in node_info_list:
          metrics_export_port = node_info["MetricsExportPort"]
          address_info = nodes[metrics_export_port]
          assert (
              address_info["raylet_socket_name"]
              == node_info["RayletSocketName"]
          )
  
          # Make sure we can ping Prometheus endpoints.
          def test_prometheus_endpoint():
              response = requests.get(
                  "http://localhost:{}".format(metrics_export_port),
                  # Fail the request early on if connection timeout
                  timeout=1.0,
              )
              return response.status_code == 200
  
          assert wait_until_succeeded_without_exception(
              test_prometheus_endpoint,
              (requests.exceptions.ConnectionError,),
              # The dashboard takes more than 2s to startup.
              timeout_ms=10 * 1000,
          )
  
file_path: ray/python/ray/tests/test_metrics.py
imports: import os
  import platform
  import psutil
  import pytest
  import requests
  import ray
  from ray._private.test_utils import wait_for_condition, wait_until_succeeded_without_exception, get_node_stats
  from ray.core.generated import common_pb2
label_desc: Use image node_id 5 for calling a global function with example usage: test_multi_node_metrics_export_port_discovery(ray_start_cluster) and returns: unknown