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 4, 2023
1 parent 7bf6de8 commit 34933bd
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package io.quarkus.ts.opentelemetry.reactive;

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;
import io.quarkus.test.scenarios.annotations.DisabledOnQuarkusVersion;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.List;

@OpenShiftScenario(deployment = OpenShiftDeploymentStrategy.UsingOpenShiftExtension)
@DisabledOnQuarkusVersion(version = "2\\..*", reason = "GRPC probes are used only in Quarkus 3")
public class OpenShiftGrpcIT extends OpenTelemetryGrpcIT {

@Inject
static OpenShiftClient oc;

@Test
void check() {
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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -61,5 +63,4 @@ protected void assertTraceIdWithPongService(String expected) {

assertEquals(expected, pongTraceId);
}

}

0 comments on commit 34933bd

Please sign in to comment.