code: def test_basic(ray_autoscaling_cluster):
      """Test that max_replicas_per_node is honored."""
  
      ray.init()
  
      @serve.deployment
      class D:
          def __call__(self):
              return "hello"
  
      serve.run(
          D.options(
              num_replicas=6, max_replicas_per_node=3, name="deploy1"
          ).bind(),
          name="app1",
          route_prefix="/deploy1",
      )
      serve.run(
          D.options(
              num_replicas=2, max_replicas_per_node=1, name="deploy2"
          ).bind(),
          name="app2",
          route_prefix="/deploy2",
      )
  
      # 2 worker nodes should be started.
      # Each worker node should run 3 deploy1 replicas
      # and 1 deploy2 replicas.
      assert len(ray.nodes()) == 3
      node_to_deployment_to_num_replicas = (
          get_node_to_deployment_to_num_replicas()
      )
  
      assert len(node_to_deployment_to_num_replicas) == 2
      for (
          _,
          deployment_to_num_replicas,
      ) in node_to_deployment_to_num_replicas.items():
          assert deployment_to_num_replicas["deploy1"] == 3
          assert deployment_to_num_replicas["deploy2"] == 1
  
file_path: ray/python/ray/serve/tests/test_max_replicas_per_node.py
imports: import sys
  from collections import defaultdict
  import pytest
  import ray
  from ray import serve
  from ray.util.state import list_actors
label_desc: Use image node_id 2 for calling a global function with example usage: test_basic(ray_autoscaling_cluster) and returns: str