code: def test_scale_up(ray_cluster):
      cluster = ray_cluster
      cluster.add_node(num_cpus=1)
      cluster.connect(namespace=SERVE_NAMESPACE)
      # By default, Serve controller and proxy actors use 0 CPUs,
      # so initially there should only be room for 1 replica.
  
      app_config = {
          "name": "default",
          "import_path": "ray.serve.tests.test_cluster.pid_app",
          "deployments": [{"name": "pid", "num_replicas": 1}],
      }
      serve.start()
      client = serve.context._connect()
      client.deploy_apps(
          ServeDeploySchema(**{"applications": [app_config]})
      )
  
      client._wait_for_application_running("default")
      pids1 = get_pids(1, deployment_name="pid", app_name="default")
  
      app_config["deployments"][0]["num_replicas"] = 3
      client.deploy_apps(
          ServeDeploySchema(**{"applications": [app_config]})
      )
  
      # Check that a new replica has not started in 1.0 seconds.  This
      # doesn't guarantee that a new replica won't ever be started, but
      # 1.0 seconds is a reasonable upper bound on replica startup time.
      with pytest.raises(TimeoutError):
          client._wait_for_application_running("default", timeout_s=1)
      assert (
          get_pids(1, deployment_name="pid", app_name="default")
          == pids1
      )
  
      # Add a node with another CPU, another replica should get placed.
      cluster.add_node(num_cpus=1)
      with pytest.raises(TimeoutError):
          client._wait_for_application_running("default", timeout_s=1)
      pids2 = get_pids(2, deployment_name="pid", app_name="default")
      assert pids1.issubset(pids2)
  
      # Add a node with another CPU, the final replica should get placed
      # and the deploy goal should be done.
      cluster.add_node(num_cpus=1)
      client._wait_for_application_running("default")
      pids3 = get_pids(3, deployment_name="pid", app_name="default")
      assert pids2.issubset(pids3)
  
imports: import os
  import sys
  import time
  from collections import defaultdict
  import pytest
  import requests
  import ray
  from ray import serve
  from ray._private.test_utils import SignalActor, wait_for_condition
  from ray.cluster_utils import Cluster
  from ray.exceptions import RayActorError
  from ray.serve._private.common import DeploymentID, ReplicaState
  from ray.serve._private.constants import SERVE_NAMESPACE
  from ray.serve._private.deployment_state import ReplicaStartupStatus
  from ray.serve._private.utils import get_head_node_id
  from ray.serve.context import _get_global_client
  from ray.serve.handle import RayServeHandle
  from ray.serve.schema import ServeDeploySchema
label_desc: Use image node_id 3 for calling a global function with example usage: test_scale_up(ray_cluster) without return types