Search in sources :

Example 1 with Sniffer

use of org.elasticsearch.client.sniff.Sniffer in project spring-boot by spring-projects.

the class ElasticsearchRestClientAutoConfigurationTests method configureWhenCustomSnifferShouldBackOff.

@Test
void configureWhenCustomSnifferShouldBackOff() {
    Sniffer customSniffer = mock(Sniffer.class);
    this.contextRunner.withBean(Sniffer.class, () -> customSniffer).run((context) -> {
        assertThat(context).hasSingleBean(Sniffer.class);
        Sniffer sniffer = context.getBean(Sniffer.class);
        assertThat(sniffer).isSameAs(customSniffer);
        then(customSniffer).shouldHaveNoInteractions();
    });
}
Also used : Sniffer(org.elasticsearch.client.sniff.Sniffer) Test(org.junit.jupiter.api.Test)

Example 2 with Sniffer

use of org.elasticsearch.client.sniff.Sniffer in project spring-boot by spring-projects.

the class ElasticsearchRestClientAutoConfigurationTests method configureWithCustomSnifferSettings.

@Test
void configureWithCustomSnifferSettings() {
    this.contextRunner.withPropertyValues("spring.elasticsearch.restclient.sniffer.interval=180s", "spring.elasticsearch.restclient.sniffer.delay-after-failure=30s").run((context) -> {
        assertThat(context).hasSingleBean(Sniffer.class);
        Sniffer sniffer = context.getBean(Sniffer.class);
        assertThat(sniffer).hasFieldOrPropertyWithValue("sniffIntervalMillis", Duration.ofMinutes(3).toMillis());
        assertThat(sniffer).hasFieldOrPropertyWithValue("sniffAfterFailureDelayMillis", Duration.ofSeconds(30).toMillis());
    });
}
Also used : Sniffer(org.elasticsearch.client.sniff.Sniffer) Test(org.junit.jupiter.api.Test)

Aggregations

Sniffer (org.elasticsearch.client.sniff.Sniffer)2 Test (org.junit.jupiter.api.Test)2