code: def test_upgrade_and_change_pg(serve_instance):
      """Test re-deploying a deployment with different PG bundles and strategy."""
  
      @serve.deployment(
          num_replicas=1,
          placement_group_bundles=[{"CPU": 1}, {"CPU": 0.1}],
          placement_group_strategy="STRICT_PACK",
      )
      class D:
          def get_pg(self) -> PlacementGroup:
              return get_current_placement_group()
  
      h = serve.run(D.bind(), name="pg_test")
  
      # Check that the original replica is created with the expected PG config.
      assert len(get_all_live_placement_group_names()) == 1
      original_pg = h.get_pg.remote().result()
      assert original_pg.bundle_specs == [{"CPU": 1}, {"CPU": 0.1}]
      assert _get_pg_strategy(original_pg) == "STRICT_PACK"
  
      # Re-deploy with a new PG config.
      D = D.options(
          placement_group_bundles=[{"CPU": 2}, {"CPU": 0.2}],
          placement_group_strategy="SPREAD",
      )
  
      h = serve.run(D.bind(), name="pg_test")
      assert len(get_all_live_placement_group_names()) == 1
      new_pg = h.get_pg.remote().result()
      assert new_pg.bundle_specs == [{"CPU": 2}, {"CPU": 0.2}]
      assert _get_pg_strategy(new_pg) == "SPREAD"
  
      # Verify that all placement groups are deleted when the deployment is deleted.
      serve.delete("pg_test")
      assert len(get_all_live_placement_group_names()) == 0
  
file_path: ray/python/ray/serve/tests/test_replica_placement_group.py
imports: import os
  import sys
  import pytest
  import ray
  from ray import serve
  from ray._private.test_utils import wait_for_condition
  from ray.serve._private.utils import get_all_live_placement_group_names
  from ray.serve.context import _get_global_client
  from ray.util.placement_group import PlacementGroup, get_current_placement_group
  from ray.util.scheduling_strategies import PlacementGroupSchedulingStrategy
label_desc: Use image node_id 3 for calling a global function with example usage: test_upgrade_and_change_pg(serve_instance) and returns: get_current_placement_group