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