Search in sources :

Example 26 with ApplicationSLA

use of com.netflix.titus.api.model.ApplicationSLA in project titus-control-plane by Netflix.

the class DefaultApplicationSlaManagementServiceTest method testGetApplicationBySchedulerName.

@Test
public void testGetApplicationBySchedulerName() throws Exception {
    ApplicationSLA myApp = ApplicationSlaSample.CriticalSmallKubeScheduler.build();
    when(storage.findBySchedulerName(myApp.getSchedulerName())).thenReturn(Observable.just(myApp));
    List<ApplicationSLA> result = new ArrayList<>(slaManagementService.getApplicationSLAsForScheduler(myApp.getSchedulerName()));
    assertThat(result).hasSize(1);
    assertThat(result.get(0).getAppName()).isEqualTo(myApp.getAppName());
    assertThat(result.get(0).getSchedulerName()).isEqualTo(myApp.getSchedulerName());
}
Also used : ApplicationSLA(com.netflix.titus.api.model.ApplicationSLA) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 27 with ApplicationSLA

use of com.netflix.titus.api.model.ApplicationSLA in project titus-control-plane by Netflix.

the class ApplicationSlaStoreCacheTest method testFindByName.

@Test
public void testFindByName() throws Exception {
    ApplicationSLA applicationSLA = initSet.get(0);
    ApplicationSLA result = store.findByName(applicationSLA.getAppName()).toBlocking().first();
    assertThat(result).isEqualTo(applicationSLA);
}
Also used : ApplicationSLA(com.netflix.titus.api.model.ApplicationSLA) Test(org.junit.Test)

Example 28 with ApplicationSLA

use of com.netflix.titus.api.model.ApplicationSLA in project titus-control-plane by Netflix.

the class InMemoryApplicationSlaStoreTest method testStoreAndRetrieveCapacityGroups.

@Test
public void testStoreAndRetrieveCapacityGroups() {
    ApplicationSlaStore store = createStore();
    ApplicationSLA capacityGroup1 = DefaultFlex.build();
    ApplicationSLA capacityGroup2 = CriticalSmall.builder().withSchedulerName(SCHEDULER_NAME_KUBE_SCHEDULER).build();
    List<ApplicationSLA> capacityGroups = Arrays.asList(capacityGroup1, capacityGroup2);
    // Create initial
    capacityGroups.forEach(capacityGroup -> assertThat(store.create(capacityGroup).toCompletable().await(TIMEOUT, TimeUnit.MILLISECONDS)).isTrue());
    List<ApplicationSLA> result;
    // find all
    result = store.findAll().toList().timeout(TIMEOUT, TimeUnit.MILLISECONDS).toBlocking().first();
    assertThat(result).containsExactlyInAnyOrder(capacityGroup1, capacityGroup2);
    // find by name
    result = store.findByName(capacityGroup1.getAppName()).toList().timeout(TIMEOUT, TimeUnit.MILLISECONDS).toBlocking().first();
    assertThat(result).containsExactlyInAnyOrder(capacityGroup1);
    // find by scheduler name
    result = store.findBySchedulerName(SCHEDULER_NAME_FENZO).toList().timeout(TIMEOUT, TimeUnit.MILLISECONDS).toBlocking().first();
    assertThat(result).containsExactlyInAnyOrder(capacityGroup1);
    result = store.findBySchedulerName(SCHEDULER_NAME_KUBE_SCHEDULER).toList().timeout(TIMEOUT, TimeUnit.MILLISECONDS).toBlocking().first();
    assertThat(result).containsExactlyInAnyOrder(capacityGroup2);
    // find by non-existent scheduler name
    result = store.findBySchedulerName("").toList().timeout(TIMEOUT, TimeUnit.MILLISECONDS).toBlocking().first();
    assertThat(result).isEmpty();
    // update scheduler name and verify
    ApplicationSLA updatedCapacityGroup = ApplicationSLA.newBuilder(capacityGroup1).withSchedulerName(SCHEDULER_NAME_KUBE_SCHEDULER).build();
    assertThat(store.create(updatedCapacityGroup).toCompletable().await(TIMEOUT, TimeUnit.MILLISECONDS)).isTrue();
    result = store.findAll().toList().timeout(TIMEOUT, TimeUnit.MILLISECONDS).toBlocking().first();
    assertThat(result).containsExactlyInAnyOrder(updatedCapacityGroup, capacityGroup2);
    // remove
    assertThat(store.remove(updatedCapacityGroup.getAppName()).toCompletable().await(TIMEOUT, TimeUnit.MILLISECONDS)).isTrue();
    assertThat(store.remove(capacityGroup2.getAppName()).toCompletable().await(TIMEOUT, TimeUnit.MILLISECONDS)).isTrue();
    assertThat(store.findAll().toList().timeout(TIMEOUT, TimeUnit.MILLISECONDS).toBlocking().first()).isEmpty();
}
Also used : ApplicationSLA(com.netflix.titus.api.model.ApplicationSLA) ApplicationSlaStore(com.netflix.titus.api.store.v2.ApplicationSlaStore) Test(org.junit.Test)

Aggregations

ApplicationSLA (com.netflix.titus.api.model.ApplicationSLA)28 Test (org.junit.Test)9 List (java.util.List)5 NotFoundException (com.netflix.titus.api.store.v2.exception.NotFoundException)4 Pair (com.netflix.titus.common.util.tuple.Pair)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 Job (com.netflix.titus.api.jobmanager.model.job.Job)3 Task (com.netflix.titus.api.jobmanager.model.job.Task)3 CollectionsExt (com.netflix.titus.common.util.CollectionsExt)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 TaskAttributes (com.netflix.titus.api.jobmanager.TaskAttributes)2 JobDescriptor (com.netflix.titus.api.jobmanager.model.job.JobDescriptor)2 TaskState (com.netflix.titus.api.jobmanager.model.job.TaskState)2 BatchJobExt (com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt)2 ResourceDimension (com.netflix.titus.api.model.ResourceDimension)2 Tier (com.netflix.titus.api.model.Tier)2 ApplicationSlaStore (com.netflix.titus.api.store.v2.ApplicationSlaStore)2 TitusChangeAction (com.netflix.titus.master.jobmanager.service.common.action.TitusChangeAction)2