Skip to content

Commit

Permalink
Verify, that grpc can be used for Openshift probes
Browse files Browse the repository at this point in the history
See quarkusio/quarkus#32113 for details
  • Loading branch information
fedinskiy committed May 5, 2023
1 parent 7bf6de8 commit 870f1a7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
import io.quarkus.test.services.QuarkusApplication;

@QuarkusScenario
public class OpenTelemetryGrpcIT {
public class GrpcIT {

@JaegerContainer(useOtlpCollector = true)
static final JaegerService jaeger = new JaegerService();

@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";
Expand Down Expand Up @@ -61,5 +63,4 @@ protected void assertTraceIdWithPongService(String expected) {

assertEquals(expected, pongTraceId);
}

}
Original file line number Diff line number Diff line change
@@ -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<Pod> pods = oc.podsInService(app);
Assertions.assertEquals(1, pods.size());
List<Container> 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());
}
}

0 comments on commit 870f1a7

Please sign in to comment.