def test_proto(self, application_status): status_info = StatusOverview( app_status=ApplicationStatusInfo( status=application_status, message="context about this status", deployment_timestamp=time.time(), ), deployment_statuses=[ DeploymentStatusInfo( name="name1", status=DeploymentStatus.UPDATING, message="deployment updating", ), DeploymentStatusInfo(name="name2", status=DeploymentStatus.HEALTHY, message=""), DeploymentStatusInfo( name="name3", status=DeploymentStatus.UNHEALTHY, message="this deployment is unhealthy", ), ], ) serialized_proto = status_info.to_proto().SerializeToString() deserialized_proto = StatusOverviewProto.FromString(serialized_proto) reconstructed_info = StatusOverview.from_proto(deserialized_proto) assert status_info == reconstructed_info
def get_valid_deployment_status_schema(self): return { "deployment_1": DeploymentStatusInfo(DeploymentStatus.HEALTHY), "deployment_2": DeploymentStatusInfo( DeploymentStatus.UNHEALTHY, "This is an unhealthy deployment." ), "deployment_3": DeploymentStatusInfo(DeploymentStatus.UPDATING), }
def test_proto(self, status): deployment_status_info = DeploymentStatusInfo( name="test_name", status=status, message="context about status") serialized_proto = deployment_status_info.to_proto().SerializeToString( ) deserialized_proto = DeploymentStatusInfoProto.FromString( serialized_proto) reconstructed_info = DeploymentStatusInfo.from_proto( deserialized_proto) assert deployment_status_info == reconstructed_info
def test_valid_deployment_status_schema(self): # Ensure valid DeploymentStatusSchemas can be generated deployment_status_schemas = { "deployment_1": DeploymentStatusInfo(DeploymentStatus.HEALTHY), "deployment_2": DeploymentStatusInfo(DeploymentStatus.UNHEALTHY, "This is an unhealthy deployment."), "deployment_3": DeploymentStatusInfo(DeploymentStatus.UPDATING), } for name, status_info in deployment_status_schemas.items(): status_info_to_schema(name, status_info)
def get_deployment_statuses(self) -> Dict[str, DeploymentStatusInfo]: proto = DeploymentStatusInfoList.FromString( ray.get(self._controller.get_deployment_statuses.remote()) ) return { deployment_status_info.name: DeploymentStatusInfo.from_proto( deployment_status_info ) for deployment_status_info in proto.deployment_status_infos }
def get_valid_serve_status_schema(self): return StatusOverview( app_status=ApplicationStatusInfo( status="DEPLOYING", message="", deployment_timestamp=time.time(), ), deployment_statuses=[ DeploymentStatusInfo( name="deployment_1", status="HEALTHY", message="", ), DeploymentStatusInfo( name="deployment_2", status="UNHEALTHY", message="this deployment is deeply unhealthy", ), ], )
def test_equality_mismatched_deployment_statuses(self): """Check that StatusOverviews with different numbers of statuses are unequal.""" status_info_few_deployments = StatusOverview( app_status=self.get_valid_serve_application_status_info(), deployment_statuses=[ DeploymentStatusInfo(name="1", status=DeploymentStatus.HEALTHY), DeploymentStatusInfo(name="2", status=DeploymentStatus.UNHEALTHY), ], ) status_info_many_deployments = StatusOverview( app_status=self.get_valid_serve_application_status_info(), deployment_statuses=[ DeploymentStatusInfo(name="1", status=DeploymentStatus.HEALTHY), DeploymentStatusInfo(name="2", status=DeploymentStatus.UNHEALTHY), DeploymentStatusInfo(name="3", status=DeploymentStatus.UNHEALTHY), DeploymentStatusInfo(name="4", status=DeploymentStatus.UPDATING), ], ) assert status_info_few_deployments != status_info_many_deployments
def test_deployment_status_required(self): with pytest.raises(TypeError): DeploymentStatusInfo(name="test_name")
def test_name_required(self): with pytest.raises(TypeError): DeploymentStatusInfo(status=DeploymentStatus.HEALTHY)