code: def test_ports_assignment(ray_start_cluster):
      # Make sure value error is raised when there are the same ports.
  
      cluster = ray_start_cluster
      with pytest.raises(ValueError):
          cluster.add_node(
              dashboard_port=30000, metrics_export_port=30000
          )
  
      pre_selected_ports = {
          "redis_port": 30000,
          "object_manager_port": 30001,
          "node_manager_port": 30002,
          "gcs_server_port": 30003,
          "ray_client_server_port": 30004,
          "dashboard_port": 30005,
          "metrics_agent_port": 30006,
          "metrics_export_port": 30007,
          "runtime_env_agent_port": 30008,
      }
  
      # Make sure we can start a node properly.
      head_node = cluster.add_node(**pre_selected_ports)
      cluster.wait_for_nodes()
      cluster.remove_node(head_node)
  
      # Make sure the wrong worker list will raise an exception.
      with pytest.raises(
          ValueError, match="[30000, 30001, 30002, 30003]"
      ):
          head_node = cluster.add_node(
              **pre_selected_ports,
              worker_port_list="30000,30001,30002,30003",
          )
  
      # Make sure the wrong min & max worker will raise an exception
      with pytest.raises(ValueError, match="from 25000 to 35000"):
          head_node = cluster.add_node(
              **pre_selected_ports,
              min_worker_port=25000,
              max_worker_port=35000,
          )
  
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 13 for calling a global function with example usage: test_ports_assignment(ray_start_cluster) without return types