Search in sources :

Example 1 with EsPublisher

use of com.netflix.titus.supplementary.taskspublisher.es.EsPublisher in project titus-control-plane by Netflix.

the class TaskEventsGeneratorTest method checkPublisherState.

@Test
public void checkPublisherState() {
    int numTasks = 5;
    final TaskEventsGenerator taskEventsGenerator = new TaskEventsGenerator(mockTitusClient(numTasks), Collections.emptyMap(), titusRuntime);
    try {
        EsPublisher esPublisher = new EsPublisher(taskEventsGenerator, mockElasticSearchClient(), mockEsPublisherConfiguration(), new DefaultRegistry());
        esPublisher.activate();
        final CountDownLatch latch = new CountDownLatch(1);
        Flux.interval(Duration.ofSeconds(1), Schedulers.elastic()).take(1).doOnNext(i -> {
            final int numTasksUpdated = esPublisher.getNumTasksPublished();
            final int numErrors = esPublisher.getNumErrorsInPublishing();
            assertThat(numErrors).isEqualTo(0);
            assertThat(numTasksUpdated).isGreaterThanOrEqualTo(numTasks);
            latch.countDown();
        }).subscribe();
        try {
            latch.await(2, TimeUnit.MINUTES);
        } catch (InterruptedException e) {
            fail("Timeout in checkPublisherState ", e);
        }
    } finally {
        taskEventsGenerator.shutdown();
    }
}
Also used : EsPublisher(com.netflix.titus.supplementary.taskspublisher.es.EsPublisher) BulkEsIndexResp(com.netflix.titus.ext.elasticsearch.model.BulkEsIndexResp) Java6Assertions.assertThat(org.assertj.core.api.Java6Assertions.assertThat) Fail.fail(org.assertj.core.api.Fail.fail) Answer(org.mockito.stubbing.Answer) EmptyLogStorageInfo(com.netflix.titus.runtime.endpoint.common.EmptyLogStorageInfo) EsPublisherConfiguration(com.netflix.titus.supplementary.taskspublisher.config.EsPublisherConfiguration) TitusRuntimes(com.netflix.titus.common.runtime.TitusRuntimes) JobOrTaskUpdate(com.netflix.titus.supplementary.taskspublisher.TitusClient.JobOrTaskUpdate) Duration(java.time.Duration) BulkEsIndexRespItem(com.netflix.titus.ext.elasticsearch.model.BulkEsIndexRespItem) EsIndexResp(com.netflix.titus.ext.elasticsearch.model.EsIndexResp) Schedulers(reactor.core.scheduler.Schedulers) EsClient(com.netflix.titus.ext.elasticsearch.EsClient) JobGenerator(com.netflix.titus.testkit.model.job.JobGenerator) Test(org.junit.Test) Mono(reactor.core.publisher.Mono) GrpcJobManagementModelConverters(com.netflix.titus.runtime.endpoint.v3.grpc.GrpcJobManagementModelConverters) Mockito.when(org.mockito.Mockito.when) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) Collectors(java.util.stream.Collectors) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) Flux(reactor.core.publisher.Flux) List(java.util.List) DefaultRegistry(com.netflix.spectator.api.DefaultRegistry) TitusRuntime(com.netflix.titus.common.runtime.TitusRuntime) Collections(java.util.Collections) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Mockito.mock(org.mockito.Mockito.mock) EsPublisher(com.netflix.titus.supplementary.taskspublisher.es.EsPublisher) DefaultRegistry(com.netflix.spectator.api.DefaultRegistry) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Aggregations

DefaultRegistry (com.netflix.spectator.api.DefaultRegistry)1 TitusRuntime (com.netflix.titus.common.runtime.TitusRuntime)1 TitusRuntimes (com.netflix.titus.common.runtime.TitusRuntimes)1 EsClient (com.netflix.titus.ext.elasticsearch.EsClient)1 BulkEsIndexResp (com.netflix.titus.ext.elasticsearch.model.BulkEsIndexResp)1 BulkEsIndexRespItem (com.netflix.titus.ext.elasticsearch.model.BulkEsIndexRespItem)1 EsIndexResp (com.netflix.titus.ext.elasticsearch.model.EsIndexResp)1 EmptyLogStorageInfo (com.netflix.titus.runtime.endpoint.common.EmptyLogStorageInfo)1 GrpcJobManagementModelConverters (com.netflix.titus.runtime.endpoint.v3.grpc.GrpcJobManagementModelConverters)1 JobOrTaskUpdate (com.netflix.titus.supplementary.taskspublisher.TitusClient.JobOrTaskUpdate)1 EsPublisherConfiguration (com.netflix.titus.supplementary.taskspublisher.config.EsPublisherConfiguration)1 EsPublisher (com.netflix.titus.supplementary.taskspublisher.es.EsPublisher)1 JobGenerator (com.netflix.titus.testkit.model.job.JobGenerator)1 Duration (java.time.Duration)1 Collections (java.util.Collections)1 List (java.util.List)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 TimeUnit (java.util.concurrent.TimeUnit)1 Collectors (java.util.stream.Collectors)1 Fail.fail (org.assertj.core.api.Fail.fail)1