Search in sources :

Example 6 with HealthReport

use of io.smallrye.reactive.messaging.health.HealthReport in project smallrye-reactive-messaging by smallrye.

the class HealthCheckTest method testHealthOfApplicationWithoutOutgoingTopic.

@Test
public void testHealthOfApplicationWithoutOutgoingTopic() {
    MapBasedConfig config = new MapBasedConfig(getKafkaSinkConfigForProducingBean());
    config.put("my.topic", topic);
    runApplication(config, ProducingBean.class);
    ConsumerTask<String, Integer> records = companion.consumeIntegers().fromTopics(topic, 10, Duration.ofSeconds(10));
    await().until(this::isStarted);
    await().until(this::isReady);
    await().until(this::isAlive);
    await().until(() -> records.count() == 10);
    HealthReport startup = getHealth().getStartup();
    HealthReport liveness = getHealth().getLiveness();
    HealthReport readiness = getHealth().getReadiness();
    assertThat(startup.isOk()).isTrue();
    assertThat(liveness.isOk()).isTrue();
    assertThat(readiness.isOk()).isTrue();
    assertThat(startup.getChannels()).hasSize(1);
    assertThat(liveness.getChannels()).hasSize(1);
    assertThat(readiness.getChannels()).hasSize(1);
    assertThat(liveness.getChannels().get(0).getChannel()).isEqualTo("output");
}
Also used : HealthReport(io.smallrye.reactive.messaging.health.HealthReport) KafkaMapBasedConfig(io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig) MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Test(org.junit.jupiter.api.Test)

Example 7 with HealthReport

use of io.smallrye.reactive.messaging.health.HealthReport in project smallrye-reactive-messaging by smallrye.

the class HealthCheckTest method testHealthOfApplicationWithChannel.

@Test
public void testHealthOfApplicationWithChannel() {
    KafkaMapBasedConfig config = getKafkaSourceConfig(topic);
    LazyConsumingBean bean = runApplication(config, LazyConsumingBean.class);
    ProducerTask produced = companion.produceIntegers().usingGenerator(i -> new ProducerRecord<>(topic, "key", i), 10);
    await().until(this::isStarted);
    await().until(this::isReady);
    await().until(this::isAlive);
    produced.awaitCompletion(Duration.ofMinutes(1));
    Multi<Integer> channel = bean.getChannel();
    channel.select().first(10).collect().asList().await().atMost(Duration.ofSeconds(10));
    HealthReport startup = getHealth().getStartup();
    HealthReport liveness = getHealth().getLiveness();
    HealthReport readiness = getHealth().getReadiness();
    assertThat(startup.isOk()).isTrue();
    assertThat(liveness.isOk()).isTrue();
    assertThat(readiness.isOk()).isTrue();
    assertThat(startup.getChannels()).hasSize(1);
    assertThat(liveness.getChannels()).hasSize(1);
    assertThat(readiness.getChannels()).hasSize(1);
}
Also used : HealthReport(io.smallrye.reactive.messaging.health.HealthReport) KafkaMapBasedConfig(io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig) ProducerTask(io.smallrye.reactive.messaging.kafka.companion.ProducerTask) Test(org.junit.jupiter.api.Test)

Example 8 with HealthReport

use of io.smallrye.reactive.messaging.health.HealthReport in project smallrye-reactive-messaging by smallrye.

the class HealthCheckTest method testHealthOfApplicationWithChannelUsingTopicVerification.

@Test
public void testHealthOfApplicationWithChannelUsingTopicVerification() {
    KafkaMapBasedConfig config = getKafkaSourceConfig(topic).put("health-readiness-topic-verification", true);
    LazyConsumingBean bean = runApplication(config, LazyConsumingBean.class);
    companion.produceIntegers().usingGenerator(i -> new ProducerRecord<>(topic, "key", i), 10);
    await().until(this::isStarted);
    await().until(this::isReady);
    await().until(this::isAlive);
    // before subscription to channel
    Multi<Integer> channel = bean.getChannel();
    channel.select().first(10).collect().asList().await().atMost(Duration.ofSeconds(10));
    // after subscription to channel
    HealthReport startup = getHealth().getStartup();
    HealthReport liveness = getHealth().getLiveness();
    HealthReport readiness = getHealth().getReadiness();
    assertThat(startup.isOk()).isTrue();
    assertThat(liveness.isOk()).isTrue();
    assertThat(readiness.isOk()).isTrue();
    assertThat(startup.getChannels()).hasSize(1);
    assertThat(liveness.getChannels()).hasSize(1);
    assertThat(readiness.getChannels()).hasSize(1);
}
Also used : HealthReport(io.smallrye.reactive.messaging.health.HealthReport) KafkaMapBasedConfig(io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig) Test(org.junit.jupiter.api.Test)

Example 9 with HealthReport

use of io.smallrye.reactive.messaging.health.HealthReport in project smallrye-reactive-messaging by smallrye.

the class HealthCheckTest method testHealthOfApplicationWithoutOutgoingTopicReadinessDisabled.

@Test
public void testHealthOfApplicationWithoutOutgoingTopicReadinessDisabled() {
    MapBasedConfig config = new MapBasedConfig(getKafkaSinkConfigForProducingBean().put("health-readiness-enabled", false));
    config.put("my.topic", topic);
    runApplication(config, ProducingBean.class);
    ConsumerTask<String, Integer> records = companion.consumeIntegers().fromTopics(topic, 10, Duration.ofSeconds(10));
    await().until(this::isStarted);
    await().until(this::isReady);
    await().until(this::isAlive);
    await().until(() -> records.count() == 10);
    HealthReport startup = getHealth().getStartup();
    HealthReport liveness = getHealth().getLiveness();
    HealthReport readiness = getHealth().getReadiness();
    assertThat(startup.isOk()).isTrue();
    assertThat(liveness.isOk()).isTrue();
    assertThat(readiness.isOk()).isTrue();
    assertThat(startup.getChannels()).hasSize(1);
    assertThat(liveness.getChannels()).hasSize(1);
    assertThat(readiness.getChannels()).hasSize(0);
    assertThat(liveness.getChannels().get(0).getChannel()).isEqualTo("output");
}
Also used : HealthReport(io.smallrye.reactive.messaging.health.HealthReport) KafkaMapBasedConfig(io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig) MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Test(org.junit.jupiter.api.Test)

Example 10 with HealthReport

use of io.smallrye.reactive.messaging.health.HealthReport in project smallrye-reactive-messaging by smallrye.

the class HealthCheckTest method testHealthOfApplicationWithOutgoingTopicUsingTopicVerification.

@Test
void testHealthOfApplicationWithOutgoingTopicUsingTopicVerification() {
    String outputTopic = UUID.randomUUID().toString();
    companion.topics().createAndWait(outputTopic, 1, Duration.ofMinutes(1));
    MapBasedConfig config = new MapBasedConfig(getKafkaSinkConfigForProducingBean().put("health-topic-verification-enabled", true).put("topic", outputTopic));
    config.put("my.topic", topic);
    runApplication(config, ProducingBean.class);
    ConsumerTask<String, Integer> consume = companion.consumeIntegers().fromTopics(topic, 10, Duration.ofSeconds(10));
    await().until(this::isStarted);
    await().until(this::isReady);
    await().until(this::isAlive);
    await().until(() -> consume.count() == 10);
    HealthReport startup = getHealth().getStartup();
    HealthReport liveness = getHealth().getLiveness();
    HealthReport readiness = getHealth().getReadiness();
    assertThat(startup.isOk()).isTrue();
    assertThat(liveness.isOk()).isTrue();
    assertThat(readiness.isOk()).isTrue();
    assertThat(startup.getChannels()).hasSize(1);
    assertThat(liveness.getChannels()).hasSize(1);
    assertThat(readiness.getChannels()).hasSize(1);
    assertThat(liveness.getChannels().get(0).getChannel()).isEqualTo("output");
}
Also used : HealthReport(io.smallrye.reactive.messaging.health.HealthReport) KafkaMapBasedConfig(io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig) MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Test(org.junit.jupiter.api.Test)

Aggregations

HealthReport (io.smallrye.reactive.messaging.health.HealthReport)16 Test (org.junit.jupiter.api.Test)16 MapBasedConfig (io.smallrye.reactive.messaging.test.common.config.MapBasedConfig)7 Message (org.eclipse.microprofile.reactive.messaging.Message)6 KafkaMapBasedConfig (io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig)5 TopicPartition (org.apache.kafka.common.TopicPartition)4 KafkaConnectorIncomingConfiguration (io.smallrye.reactive.messaging.kafka.KafkaConnectorIncomingConfiguration)2 IncomingKafkaRecordMetadata (io.smallrye.reactive.messaging.kafka.api.IncomingKafkaRecordMetadata)2 KafkaSource (io.smallrye.reactive.messaging.kafka.impl.KafkaSource)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 UnsatisfiedResolutionException (javax.enterprise.inject.UnsatisfiedResolutionException)2 RepeatedTest (org.junit.jupiter.api.RepeatedTest)2 Identifier (io.smallrye.common.annotation.Identifier)1 io.smallrye.reactive.messaging.kafka (io.smallrye.reactive.messaging.kafka)1 IncomingKafkaRecordBatchMetadata (io.smallrye.reactive.messaging.kafka.api.IncomingKafkaRecordBatchMetadata)1 MockKafkaUtils.injectMockConsumer (io.smallrye.reactive.messaging.kafka.base.MockKafkaUtils.injectMockConsumer)1 WeldTestBase (io.smallrye.reactive.messaging.kafka.base.WeldTestBase)1 ProducerTask (io.smallrye.reactive.messaging.kafka.companion.ProducerTask)1 Vertx (io.vertx.mutiny.core.Vertx)1