deploy: add portainer readiness healthchecks
This commit is contained in:
@@ -39,6 +39,19 @@ class PortainerComposeResourceLimitsTest {
|
||||
assertServiceMemoryLimit(compose, "vehicle-analytics-app", "VEHICLE_ANALYTICS_MEM_LIMIT", "1024m");
|
||||
}
|
||||
|
||||
@Test
|
||||
void portainerServicesUseContainerReadinessHealthchecks() throws IOException {
|
||||
String compose = Files.readString(repositoryRoot().resolve("deploy/portainer/docker-compose.yml"));
|
||||
String dockerfile = Files.readString(repositoryRoot().resolve("Dockerfile"));
|
||||
|
||||
assertThat(dockerfile).contains("apt-get install -y --no-install-recommends curl");
|
||||
assertServiceReadinessHealthcheck(compose, "gb32960-ingest-app", "20100");
|
||||
assertServiceReadinessHealthcheck(compose, "jt808-ingest-app", "20400");
|
||||
assertServiceReadinessHealthcheck(compose, "yutong-mqtt-app", "20500");
|
||||
assertServiceReadinessHealthcheck(compose, "vehicle-history-app", "20200");
|
||||
assertServiceReadinessHealthcheck(compose, "vehicle-analytics-app", "20300");
|
||||
}
|
||||
|
||||
@Test
|
||||
void containerDefaultsIncludeJava25UnsafeCompatibilityFlag() throws IOException {
|
||||
String compose = Files.readString(repositoryRoot().resolve("deploy/portainer/docker-compose.yml"));
|
||||
@@ -382,6 +395,17 @@ class PortainerComposeResourceLimitsTest {
|
||||
.contains(" mem_limit: ${" + envName + ":-" + defaultLimit + "}");
|
||||
}
|
||||
|
||||
private static void assertServiceReadinessHealthcheck(String compose, String serviceName, String httpPort) {
|
||||
assertThat(serviceBlock(compose, serviceName))
|
||||
.contains(" healthcheck:\n")
|
||||
.contains(" test: [\"CMD-SHELL\", \"curl -fsS http://127.0.0.1:"
|
||||
+ httpPort + "/actuator/health/readiness >/dev/null\"]")
|
||||
.contains(" interval: 30s\n")
|
||||
.contains(" timeout: 5s\n")
|
||||
.contains(" retries: 3\n")
|
||||
.contains(" start_period: 60s\n");
|
||||
}
|
||||
|
||||
private static String serviceBlock(String compose, String serviceName) {
|
||||
String marker = "\n " + serviceName + ":\n";
|
||||
int start = compose.indexOf(marker);
|
||||
|
||||
Reference in New Issue
Block a user