Search in sources :

Example 6 with AutoScalingResource

use of com.netflix.titus.runtime.endpoint.v3.rest.AutoScalingResource in project titus-control-plane by Netflix.

the class AutoScalingResourceTest method getPoliciesForJobFromTwoCells.

@Test
public void getPoliciesForJobFromTwoCells() {
    ScalingPolicyID policy1 = ScalingPolicyID.newBuilder().setId(POLICY_1).build();
    ScalingPolicyID policy2 = ScalingPolicyID.newBuilder().setId(POLICY_2).build();
    ScalingPolicyResult policyOneResult = ScalingPolicyResult.newBuilder().setId(policy1).setJobId(JOB_1).build();
    ScalingPolicyResult policyTwoResult = ScalingPolicyResult.newBuilder().setId(policy2).setJobId(JOB_2).build();
    CellWithPolicies cellOneService = new CellWithPolicies(Collections.singletonList(policyOneResult));
    CellWithPolicies cellTwoService = new CellWithPolicies(Collections.singletonList(policyTwoResult));
    cellOne.getServiceRegistry().addService(cellOneService);
    cellTwo.getServiceRegistry().addService(cellTwoService);
    final AutoScalingResource autoScalingResource = new AutoScalingResource(service, callMetadataResolver);
    final GetPolicyResult scalingPolicyForJob = autoScalingResource.getScalingPolicyForJob(JOB_2);
    assertThat(scalingPolicyForJob).isNotNull();
    assertThat(scalingPolicyForJob.getItemsCount()).isEqualTo(1);
    assertThat(scalingPolicyForJob.getItems(0).getJobId()).isEqualTo(JOB_2);
}
Also used : ScalingPolicyID(com.netflix.titus.grpc.protogen.ScalingPolicyID) ScalingPolicyResult(com.netflix.titus.grpc.protogen.ScalingPolicyResult) AutoScalingResource(com.netflix.titus.runtime.endpoint.v3.rest.AutoScalingResource) GetPolicyResult(com.netflix.titus.grpc.protogen.GetPolicyResult) Test(org.junit.Test)

Aggregations

ScalingPolicyID (com.netflix.titus.grpc.protogen.ScalingPolicyID)6 ScalingPolicyResult (com.netflix.titus.grpc.protogen.ScalingPolicyResult)6 AutoScalingResource (com.netflix.titus.runtime.endpoint.v3.rest.AutoScalingResource)6 Test (org.junit.Test)6 GetPolicyResult (com.netflix.titus.grpc.protogen.GetPolicyResult)5 Response (javax.ws.rs.core.Response)2 DoubleValue (com.google.protobuf.DoubleValue)1 UpdatePolicyRequest (com.netflix.titus.grpc.protogen.UpdatePolicyRequest)1