From 870f1a7f97b4bb5a95f048af880781e08e4a11c9 Mon Sep 17 00:00:00 2001 From: Fedor Dudinskiy Date: Thu, 4 May 2023 16:38:22 +0200 Subject: [PATCH] Verify, that grpc can be used for Openshift probes See https://github.com/quarkusio/quarkus/pull/32113 for details --- .../{OpenTelemetryGrpcIT.java => GrpcIT.java} | 7 ++-- .../reactive/OpenShiftGrpcIT.java | 42 +++++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) rename monitoring/opentelemetry-reactive/src/test/java/io/quarkus/ts/opentelemetry/reactive/{OpenTelemetryGrpcIT.java => GrpcIT.java} (89%) create mode 100644 monitoring/opentelemetry-reactive/src/test/java/io/quarkus/ts/opentelemetry/reactive/OpenShiftGrpcIT.java diff --git a/monitoring/opentelemetry-reactive/src/test/java/io/quarkus/ts/opentelemetry/reactive/OpenTelemetryGrpcIT.java b/monitoring/opentelemetry-reactive/src/test/java/io/quarkus/ts/opentelemetry/reactive/GrpcIT.java similarity index 89% rename from monitoring/opentelemetry-reactive/src/test/java/io/quarkus/ts/opentelemetry/reactive/OpenTelemetryGrpcIT.java rename to monitoring/opentelemetry-reactive/src/test/java/io/quarkus/ts/opentelemetry/reactive/GrpcIT.java index 57d49c2f16..b329acd742 100644 --- a/monitoring/opentelemetry-reactive/src/test/java/io/quarkus/ts/opentelemetry/reactive/OpenTelemetryGrpcIT.java +++ b/monitoring/opentelemetry-reactive/src/test/java/io/quarkus/ts/opentelemetry/reactive/GrpcIT.java @@ -18,7 +18,7 @@ import io.quarkus.test.services.QuarkusApplication; @QuarkusScenario -public class OpenTelemetryGrpcIT { +public class GrpcIT { @JaegerContainer(useOtlpCollector = true) static final JaegerService jaeger = new JaegerService(); @@ -26,7 +26,9 @@ public class OpenTelemetryGrpcIT { @QuarkusApplication() static RestService app = new RestService() .withProperty("quarkus.application.name", "pingpong") - .withProperty("quarkus.opentelemetry.tracer.exporter.otlp.endpoint", jaeger::getCollectorUrl); + .withProperty("quarkus.opentelemetry.tracer.exporter.otlp.endpoint", jaeger::getCollectorUrl) + .withProperty("quarkus.openshift.readiness-probe.grpc-action", "9000:io.quarkus.example.PongService") + .withProperty("quarkus.openshift.liveness-probe.grpc-action", "9000:io.quarkus.example.PongService"); private static final String PING_ENDPOINT = "/grpc-ping"; private static final String PONG_ENDPOINT = "/grpc-pong"; @@ -61,5 +63,4 @@ protected void assertTraceIdWithPongService(String expected) { assertEquals(expected, pongTraceId); } - } diff --git a/monitoring/opentelemetry-reactive/src/test/java/io/quarkus/ts/opentelemetry/reactive/OpenShiftGrpcIT.java b/monitoring/opentelemetry-reactive/src/test/java/io/quarkus/ts/opentelemetry/reactive/OpenShiftGrpcIT.java new file mode 100644 index 0000000000..beaf831b42 --- /dev/null +++ b/monitoring/opentelemetry-reactive/src/test/java/io/quarkus/ts/opentelemetry/reactive/OpenShiftGrpcIT.java @@ -0,0 +1,42 @@ +package io.quarkus.ts.opentelemetry.reactive; + +import java.util.List; + +import jakarta.inject.Inject; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import io.fabric8.kubernetes.api.model.Container; +import io.fabric8.kubernetes.api.model.GRPCAction; +import io.fabric8.kubernetes.api.model.Pod; +import io.fabric8.kubernetes.api.model.Probe; +import io.quarkus.test.bootstrap.inject.OpenShiftClient; +import io.quarkus.test.scenarios.OpenShiftDeploymentStrategy; +import io.quarkus.test.scenarios.OpenShiftScenario; + +@OpenShiftScenario(deployment = OpenShiftDeploymentStrategy.UsingOpenShiftExtension) +public class OpenShiftGrpcIT extends GrpcIT { + + @Inject + static OpenShiftClient oc; + + @Test + void grpcProbes() { + List pods = oc.podsInService(app); + Assertions.assertEquals(1, pods.size()); + List containers = pods.get(0).getSpec().getContainers(); + Assertions.assertEquals(1, containers.size()); + Container container = containers.get(0); + validateProbe(container.getLivenessProbe()); + validateProbe(container.getReadinessProbe()); + } + + private static void validateProbe(Probe probe) { + Assertions.assertNotNull(probe); + GRPCAction grpcAction = probe.getGrpc(); + Assertions.assertNotNull(grpcAction); + Assertions.assertEquals("io.quarkus.example.PongService", grpcAction.getService()); + Assertions.assertEquals(9000, grpcAction.getPort()); + } +}