refactor: trim unused stateful runtime settings
This commit is contained in:
@@ -61,6 +61,20 @@ class PortainerComposeResourceLimitsTest {
|
||||
.doesNotContain("vehicle-history-archive:");
|
||||
}
|
||||
|
||||
@Test
|
||||
void localLaunchctlHistoryRuntimeDoesNotRequireSharedArchiveRoot() throws IOException {
|
||||
Path launchctl = repositoryRoot().resolve("deploy/local/launchctl");
|
||||
String historyTemplate = Files.readString(launchctl.resolve("com.lingniu.vehicle-history.plist.template"));
|
||||
String readme = Files.readString(launchctl.resolve("README.md"));
|
||||
|
||||
assertThat(historyTemplate)
|
||||
.doesNotContain("SINK_ARCHIVE_PATH")
|
||||
.doesNotContain("__SHARED_ARCHIVE_PATH__");
|
||||
assertThat(readme)
|
||||
.doesNotContain("三个服务必须使用同一个 `SINK_ARCHIVE_PATH`")
|
||||
.doesNotContain("history 服务按同一个 archive root 读取原始帧");
|
||||
}
|
||||
|
||||
@Test
|
||||
void vehicleAnalyticsComposeOnlyExposesStatConsumerEnvironment() throws IOException {
|
||||
String compose = Files.readString(repositoryRoot().resolve("deploy/portainer/docker-compose.yml"));
|
||||
@@ -74,6 +88,21 @@ class PortainerComposeResourceLimitsTest {
|
||||
.doesNotContain("VEHICLE_STATE_ENABLED");
|
||||
}
|
||||
|
||||
@Test
|
||||
void vehicleAnalyticsDoesNotInheritRedisStateEnvironment() throws IOException {
|
||||
String compose = Files.readString(repositoryRoot().resolve("deploy/portainer/docker-compose.yml"));
|
||||
String commonEnv = commonEnvBlock(compose);
|
||||
String analyticsService = serviceBlock(compose, "vehicle-analytics-app");
|
||||
|
||||
assertThat(analyticsService).contains("<<: *common-env");
|
||||
assertThat(commonEnv)
|
||||
.doesNotContain("REDIS_HOST")
|
||||
.doesNotContain("REDIS_PORT")
|
||||
.doesNotContain("REDIS_DATABASE")
|
||||
.doesNotContain("REDIS_USERNAME")
|
||||
.doesNotContain("REDIS_PASSWORD");
|
||||
}
|
||||
|
||||
private static void assertServiceMemoryLimit(String compose,
|
||||
String serviceName,
|
||||
String envName,
|
||||
@@ -107,6 +136,19 @@ class PortainerComposeResourceLimitsTest {
|
||||
return compose.substring(start);
|
||||
}
|
||||
|
||||
private static String commonEnvBlock(String compose) {
|
||||
String marker = "x-common-env: &common-env\n";
|
||||
int start = compose.indexOf(marker);
|
||||
if (start < 0) {
|
||||
throw new IllegalArgumentException("common env block not found");
|
||||
}
|
||||
int end = compose.indexOf("\nservices:\n", start);
|
||||
if (end < 0) {
|
||||
throw new IllegalArgumentException("services block not found");
|
||||
}
|
||||
return compose.substring(start, end);
|
||||
}
|
||||
|
||||
private static Path repositoryRoot() {
|
||||
Path current = Path.of(System.getProperty("user.dir")).toAbsolutePath();
|
||||
while (current != null) {
|
||||
|
||||
Reference in New Issue
Block a user