code: def test_app_deploy_failed_and_redeploy(mocked_application_state):
      """Test DEPLOYING -> DEPLOY_FAILED -> (redeploy) -> DEPLOYING -> RUNNING"""
      app_state, deployment_state_manager = mocked_application_state
      d1_id = DeploymentID("d1", "test_app")
      d2_id = DeploymentID("d2", "test_app")
      app_state.deploy({"d1": deployment_info("d1")})
      assert app_state.status == ApplicationStatus.DEPLOYING
  
      # Before status of deployment changes, app should still be DEPLOYING
      app_state.update()
      assert app_state.status == ApplicationStatus.DEPLOYING
  
      # Mark deployment unhealthy -> app should be DEPLOY_FAILED
      deployment_state_manager.set_deployment_unhealthy(d1_id)
      app_state.update()
      assert app_state.status == ApplicationStatus.DEPLOY_FAILED
  
      # Message and status should not change
      deploy_failed_msg = app_state._status_msg
      assert len(deploy_failed_msg) != 0
      app_state.update()
      assert app_state.status == ApplicationStatus.DEPLOY_FAILED
      assert app_state._status_msg == deploy_failed_msg
  
      app_state.deploy(
          {"d1": deployment_info("d1"), "d2": deployment_info("d2")}
      )
      assert app_state.status == ApplicationStatus.DEPLOYING
      assert app_state._status_msg != deploy_failed_msg
  
      # After one update, deployments {d1, d2} should be created
      app_state.update()
      assert deployment_state_manager.get_deployment(d1_id)
      assert deployment_state_manager.get_deployment(d2_id)
      assert app_state.status == ApplicationStatus.DEPLOYING
  
      deployment_state_manager.set_deployment_healthy(d1_id)
      deployment_state_manager.set_deployment_healthy(d2_id)
      app_state.update()
      assert app_state.status == ApplicationStatus.RUNNING
  
      # Message and status should not change
      running_msg = app_state._status_msg
      assert running_msg != deploy_failed_msg
      app_state.update()
      assert app_state.status == ApplicationStatus.RUNNING
      assert app_state._status_msg == running_msg
  
imports: import sys
  from typing import Dict, List, Tuple
  from unittest.mock import Mock, PropertyMock, patch
  import pytest
  from ray.exceptions import RayTaskError
  from ray.serve._private.application_state import ApplicationState, ApplicationStateManager, override_deployment_info
  from ray.serve._private.common import ApplicationStatus, DeploymentID, DeploymentStatus, DeploymentStatusInfo, DeploymentStatusTrigger
  from ray.serve._private.config import DeploymentConfig, ReplicaConfig
  from ray.serve._private.deploy_utils import deploy_args_to_deployment_info
  from ray.serve._private.deployment_info import DeploymentInfo
  from ray.serve._private.test_utils import MockKVStore
  from ray.serve._private.utils import get_random_string
  from ray.serve.exceptions import RayServeException
  from ray.serve.schema import DeploymentSchema, ServeApplicationSchema
label_desc: Use image node_id 6 for calling a global function with example usage: test_app_deploy_failed_and_redeploy(mocked_application_state) without return types