use of com.netflix.titus.grpc.protogen.DeletePolicyRequest in project titus-control-plane by Netflix.
the class AggregatingAutoScalingService method deleteAutoScalingPolicy.
@Override
public Completable deleteAutoScalingPolicy(DeletePolicyRequest request, CallMetadata callMetadata) {
ScalingPolicyID policyId = request.getId();
Observable<Empty> observable = getScalingPolicyInAllCells(policyId, callMetadata).flatMap(response -> singleCellCall(response.getCell(), (client, responseObserver) -> client.deleteAutoScalingPolicy(request, responseObserver), callMetadata));
return observable.toCompletable();
}
use of com.netflix.titus.grpc.protogen.DeletePolicyRequest in project titus-control-plane by Netflix.
the class AutoScalingGrpcTest method testDeletePolicyById.
/**
* Test that a policy can be deleted.
*
* @throws Exception
*/
@Test(timeout = TEST_TIMEOUT_MS)
public void testDeletePolicyById() throws Exception {
// Put a policy
String jobId = "Titus-1";
PutPolicyRequest putPolicyRequest = AutoScalingTestUtils.generatePutPolicyRequest(jobId, PolicyType.StepScaling);
TestStreamObserver<ScalingPolicyID> putResponse = new TestStreamObserver<>();
client.setAutoScalingPolicy(putPolicyRequest, putResponse);
ScalingPolicyID scalingPolicyID = putResponse.takeNext(TIMEOUT_MS, TimeUnit.MILLISECONDS);
assertThat(!scalingPolicyID.getId().isEmpty());
// Delete the policy
TestStreamObserver<Empty> deletePolicyResult = new TestStreamObserver<>();
DeletePolicyRequest deletePolicyRequest = DeletePolicyRequest.newBuilder().setId(scalingPolicyID).build();
client.deleteAutoScalingPolicy(deletePolicyRequest, deletePolicyResult);
deletePolicyResult.awaitDone();
assertThat(deletePolicyResult.hasError()).isFalse();
// Make sure it's set to Deleting or Deleted state
TestStreamObserver<GetPolicyResult> getResponse = new TestStreamObserver<>();
client.getScalingPolicy(scalingPolicyID, getResponse);
GetPolicyResult getPolicyResult = getResponse.takeNext(TIMEOUT_MS, TimeUnit.MILLISECONDS);
log.info("Got result {}", getPolicyResult);
assertThat(getPolicyResult.getItemsCount()).isEqualTo(1);
assertThat(isDeletingState(getPolicyResult.getItems(0).getPolicyState()));
}
Aggregations