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());
}
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);
}
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();
}
Aggregations