config: expose health probes for active apps

This commit is contained in:
lingniu
2026-07-01 12:08:54 +08:00
parent a76cd3a8d6
commit 59edc7a8d4
6 changed files with 49 additions and 0 deletions

View File

@@ -130,6 +130,10 @@ management:
web: web:
exposure: exposure:
include: health,info,metrics,prometheus,gb32960sessions include: health,info,metrics,prometheus,gb32960sessions
endpoint:
health:
probes:
enabled: ${MANAGEMENT_HEALTH_PROBES_ENABLED:true}
health: health:
redis: redis:
enabled: ${MANAGEMENT_HEALTH_REDIS_ENABLED:false} enabled: ${MANAGEMENT_HEALTH_REDIS_ENABLED:false}

View File

@@ -90,6 +90,10 @@ management:
web: web:
exposure: exposure:
include: health,info,metrics,prometheus include: health,info,metrics,prometheus
endpoint:
health:
probes:
enabled: ${MANAGEMENT_HEALTH_PROBES_ENABLED:true}
health: health:
redis: redis:
enabled: ${MANAGEMENT_HEALTH_REDIS_ENABLED:false} enabled: ${MANAGEMENT_HEALTH_REDIS_ENABLED:false}

View File

@@ -70,6 +70,10 @@ management:
web: web:
exposure: exposure:
include: health,info,metrics,prometheus include: health,info,metrics,prometheus
endpoint:
health:
probes:
enabled: ${MANAGEMENT_HEALTH_PROBES_ENABLED:true}
metrics: metrics:
tags: tags:
application: vehicle-analytics-app application: vehicle-analytics-app

View File

@@ -107,6 +107,10 @@ management:
web: web:
exposure: exposure:
include: health,info,metrics,prometheus include: health,info,metrics,prometheus
endpoint:
health:
probes:
enabled: ${MANAGEMENT_HEALTH_PROBES_ENABLED:true}
health: health:
redis: redis:
enabled: ${MANAGEMENT_HEALTH_REDIS_ENABLED:false} enabled: ${MANAGEMENT_HEALTH_REDIS_ENABLED:false}

View File

@@ -1,11 +1,14 @@
package com.lingniu.ingest.historyapp; package com.lingniu.ingest.historyapp;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
import org.springframework.core.io.FileSystemResource;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.List; import java.util.List;
import java.util.Properties;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@@ -47,6 +50,24 @@ class PortainerComposeResourceLimitsTest {
.contains("JAVA_OPTS: ${JAVA_OPTS:---sun-misc-unsafe-memory-access=allow -XX:+UseZGC -XX:MaxRAMPercentage=75}"); .contains("JAVA_OPTS: ${JAVA_OPTS:---sun-misc-unsafe-memory-access=allow -XX:+UseZGC -XX:MaxRAMPercentage=75}");
} }
@Test
void activeAppsExposeHealthProbeGroupsByDefault() {
Path root = repositoryRoot();
List<Path> activeAppConfigs = List.of(
root.resolve("modules/apps/gb32960-ingest-app/src/main/resources/application.yml"),
root.resolve("modules/apps/jt808-ingest-app/src/main/resources/application.yml"),
root.resolve("modules/apps/yutong-mqtt-app/src/main/resources/application.yml"),
root.resolve("modules/apps/vehicle-history-app/src/main/resources/application.yml"),
root.resolve("modules/apps/vehicle-analytics-app/src/main/resources/application.yml"));
for (Path config : activeAppConfigs) {
assertThat(yamlProperties(config))
.as(config.toString())
.containsEntry("management.endpoint.health.probes.enabled",
"${MANAGEMENT_HEALTH_PROBES_ENABLED:true}");
}
}
@Test @Test
void dockerEntrypointExecsJavaForSignalHandling() throws IOException { void dockerEntrypointExecsJavaForSignalHandling() throws IOException {
String dockerfile = Files.readString(repositoryRoot().resolve("Dockerfile")); String dockerfile = Files.readString(repositoryRoot().resolve("Dockerfile"));
@@ -388,6 +409,14 @@ class PortainerComposeResourceLimitsTest {
return compose.substring(start, end); return compose.substring(start, end);
} }
private static Properties yamlProperties(Path path) {
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
factory.setResources(new FileSystemResource(path));
Properties properties = factory.getObject();
assertThat(properties).isNotNull();
return properties;
}
private static Path repositoryRoot() { private static Path repositoryRoot() {
Path current = Path.of(System.getProperty("user.dir")).toAbsolutePath(); Path current = Path.of(System.getProperty("user.dir")).toAbsolutePath();
while (current != null) { while (current != null) {

View File

@@ -100,6 +100,10 @@ management:
web: web:
exposure: exposure:
include: health,info,metrics,prometheus include: health,info,metrics,prometheus
endpoint:
health:
probes:
enabled: ${MANAGEMENT_HEALTH_PROBES_ENABLED:true}
health: health:
redis: redis:
enabled: ${MANAGEMENT_HEALTH_REDIS_ENABLED:false} enabled: ${MANAGEMENT_HEALTH_REDIS_ENABLED:false}