deploy: add launchctl templates for active apps
This commit is contained in:
@@ -125,13 +125,37 @@ class PortainerComposeResourceLimitsTest {
|
||||
String readme = Files.readString(repositoryRoot()
|
||||
.resolve("deploy/local/launchctl/README.md"));
|
||||
|
||||
for (String httpPort : List.of("20100", "20400", "20200")) {
|
||||
for (String httpPort : List.of("20100", "20400", "20500", "20200", "20300")) {
|
||||
assertThat(readme)
|
||||
.contains("curl -sS http://127.0.0.1:" + httpPort + "/actuator/health/liveness")
|
||||
.contains("curl -sS http://127.0.0.1:" + httpPort + "/actuator/health/readiness");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void localLaunchctlTemplatesCoverActiveProductionApps() throws IOException {
|
||||
Path launchctl = repositoryRoot().resolve("deploy/local/launchctl");
|
||||
String readme = Files.readString(launchctl.resolve("README.md"));
|
||||
|
||||
assertThat(readme)
|
||||
.contains("gb32960 jt808 yutong-mqtt vehicle-history vehicle-analytics")
|
||||
.contains("mkdir -p /tmp/lingniu-gb32960-live /tmp/lingniu-jt808-live /tmp/lingniu-yutong-mqtt-live /tmp/lingniu-vehicle-history-live /tmp/lingniu-vehicle-analytics-live")
|
||||
.contains("launchctl bootstrap \"gui/$(id -u)\" \"$HOME/Library/LaunchAgents/com.lingniu.yutong-mqtt.plist\"")
|
||||
.contains("launchctl bootstrap \"gui/$(id -u)\" \"$HOME/Library/LaunchAgents/com.lingniu.vehicle-analytics.plist\"")
|
||||
.contains("launchctl bootout \"gui/$(id -u)\" \"$HOME/Library/LaunchAgents/com.lingniu.yutong-mqtt.plist\" || true")
|
||||
.contains("launchctl bootout \"gui/$(id -u)\" \"$HOME/Library/LaunchAgents/com.lingniu.vehicle-analytics.plist\" || true")
|
||||
.contains("launchctl list | rg 'com.lingniu.(gb32960|jt808|yutong-mqtt|vehicle-history|vehicle-analytics)'")
|
||||
.contains("Yutong MQTT ingest: `http://127.0.0.1:20500/swagger-ui/index.html`")
|
||||
.contains("Analytics metrics: `http://127.0.0.1:20300/swagger-ui/index.html`")
|
||||
.doesNotContain("三个服务");
|
||||
|
||||
assertLaunchctlTemplate(launchctl, "gb32960", "gb32960-ingest-app", "20100");
|
||||
assertLaunchctlTemplate(launchctl, "jt808", "jt808-ingest-app", "20400");
|
||||
assertLaunchctlTemplate(launchctl, "yutong-mqtt", "yutong-mqtt-app", "20500");
|
||||
assertLaunchctlTemplate(launchctl, "vehicle-history", "vehicle-history-app", "20200");
|
||||
assertLaunchctlTemplate(launchctl, "vehicle-analytics", "vehicle-analytics-app", "20300");
|
||||
}
|
||||
|
||||
@Test
|
||||
void tdengineVerificationRunbookChecksLivenessAndReadinessForManagedApps() throws IOException {
|
||||
String runbook = Files.readString(repositoryRoot()
|
||||
@@ -495,6 +519,21 @@ class PortainerComposeResourceLimitsTest {
|
||||
.doesNotContain(" start_period: 60s\n");
|
||||
}
|
||||
|
||||
private static void assertLaunchctlTemplate(Path launchctl,
|
||||
String serviceName,
|
||||
String appName,
|
||||
String httpPort) throws IOException {
|
||||
Path template = launchctl.resolve("com.lingniu." + serviceName + ".plist.template");
|
||||
assertThat(template).exists();
|
||||
assertThat(Files.readString(template))
|
||||
.contains("<string>com.lingniu." + serviceName + "</string>")
|
||||
.contains("__PROJECT_ROOT__/modules/apps/" + appName + "/target/" + appName + ".jar")
|
||||
.contains("<key>HTTP_PORT</key>\n <string>" + httpPort + "</string>")
|
||||
.contains("<key>NACOS_CONFIG_ENABLED</key>\n <string>false</string>")
|
||||
.contains("<key>MANAGEMENT_HEALTH_REDIS_ENABLED</key>\n <string>false</string>")
|
||||
.contains("/tmp/lingniu-" + serviceName + "-live/");
|
||||
}
|
||||
|
||||
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