code: def test_replica_health_metric(ray_instance):
      """Test replica health metrics"""
  
      @serve.deployment(num_replicas=2)
      def f():
          return "hello"
  
      serve.run(f.bind())
  
      def count_live_replica_metrics():
          resp = requests.get("http://127.0.0.1:9999").text
          resp = resp.split("\n")
          count = 0
          for metrics in resp:
              if "# HELP" in metrics or "# TYPE" in metrics:
                  continue
              if "serve_deployment_replica_healthy" in metrics:
                  if "1.0" in metrics:
                      count += 1
          return count
  
      wait_for_condition(
          lambda: count_live_replica_metrics() == 2,
          timeout=120,
          retry_interval_ms=500,
      )
  
      # Add more replicas
      serve.run(f.options(num_replicas=10).bind())
      wait_for_condition(
          lambda: count_live_replica_metrics() == 10,
          timeout=120,
          retry_interval_ms=500,
      )
  
      # delete the application
      serve.delete(SERVE_DEFAULT_APP_NAME)
      wait_for_condition(
          lambda: count_live_replica_metrics() == 0,
          timeout=120,
          retry_interval_ms=500,
      )
      serve.shutdown()
  
imports: import os
  import subprocess
  import sys
  from contextlib import contextmanager
  from tempfile import NamedTemporaryFile
  import pytest
  import requests
  import ray
  import ray._private.state
  import ray.actor
  from ray import serve
  from ray._private.test_utils import SignalActor, wait_for_condition
  from ray.cluster_utils import AutoscalingCluster, Cluster
  from ray.exceptions import RayActorError
  from ray.serve._private.common import ProxyStatus
  from ray.serve._private.constants import SERVE_DEFAULT_APP_NAME
  from ray.serve._private.logging_utils import get_serve_logs_dir
  from ray.serve._private.utils import get_head_node_id
  from ray.serve.context import _get_global_client
  from ray.serve.schema import ServeInstanceDetails
  from ray.tests.conftest import call_ray_stop_only
label_desc: Use image node_id 5 for calling a global function with example usage: test_replica_health_metric(ray_instance) and returns: str, count