Search in sources :

Example 1 with BulkEsIndexResp

use of com.netflix.titus.ext.elasticsearch.model.BulkEsIndexResp in project titus-control-plane by Netflix.

the class TaskEventsGeneratorTest method mockElasticSearchClient.

private EsClient<TaskDocument> mockElasticSearchClient() {
    EsClient<TaskDocument> esClient = mock(EsClient.class);
    when(esClient.bulkIndexDocuments(anyList(), anyString(), anyString())).thenAnswer((Answer<Mono<BulkEsIndexResp>>) invocation -> {
        final List<TaskDocument> documents = invocation.getArgument(0);
        final List<BulkEsIndexRespItem> bulkEsIndexRespItemList = documents.stream().map(doc -> {
            EsIndexResp esIndexResp = new EsIndexResp(true, "created", doc.getId());
            return new BulkEsIndexRespItem(esIndexResp);
        }).collect(Collectors.toList());
        final BulkEsIndexResp bulkEsIndexResp = new BulkEsIndexResp(bulkEsIndexRespItemList);
        return Mono.just(bulkEsIndexResp);
    });
    return esClient;
}
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) BulkEsIndexRespItem(com.netflix.titus.ext.elasticsearch.model.BulkEsIndexRespItem) BulkEsIndexResp(com.netflix.titus.ext.elasticsearch.model.BulkEsIndexResp) BulkEsIndexResp(com.netflix.titus.ext.elasticsearch.model.BulkEsIndexResp) EsIndexResp(com.netflix.titus.ext.elasticsearch.model.EsIndexResp) Mono(reactor.core.publisher.Mono) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List)

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