refactor: slim vehicle analytics app runtime
This commit is contained in:
@@ -48,6 +48,19 @@ class PortainerComposeResourceLimitsTest {
|
||||
.doesNotContain("\n TDENGINE_DATABASE:");
|
||||
}
|
||||
|
||||
@Test
|
||||
void vehicleAnalyticsComposeOnlyExposesStatConsumerEnvironment() throws IOException {
|
||||
String compose = Files.readString(repositoryRoot().resolve("deploy/portainer/docker-compose.yml"));
|
||||
String analyticsService = serviceBlock(compose, "vehicle-analytics-app");
|
||||
|
||||
assertThat(analyticsService)
|
||||
.contains("KAFKA_GROUP_STAT: ${KAFKA_GROUP_STAT:-vehicle-stat}")
|
||||
.contains("VEHICLE_STAT_ENABLED: ${VEHICLE_STAT_ENABLED:-true}")
|
||||
.contains("VEHICLE_STAT_JT808_MILEAGE_ENABLED: ${VEHICLE_STAT_JT808_MILEAGE_ENABLED:-true}")
|
||||
.doesNotContain("KAFKA_GROUP_STATE")
|
||||
.doesNotContain("VEHICLE_STATE_ENABLED");
|
||||
}
|
||||
|
||||
private static void assertServiceMemoryLimit(String compose,
|
||||
String serviceName,
|
||||
String envName,
|
||||
@@ -58,6 +71,29 @@ class PortainerComposeResourceLimitsTest {
|
||||
.contains(" mem_limit: ${" + envName + ":-" + defaultLimit + "}");
|
||||
}
|
||||
|
||||
private static String serviceBlock(String compose, String serviceName) {
|
||||
String marker = "\n " + serviceName + ":\n";
|
||||
int start = compose.indexOf(marker);
|
||||
if (start < 0) {
|
||||
throw new IllegalArgumentException("service not found: " + serviceName);
|
||||
}
|
||||
for (int cursor = start + marker.length(); cursor < compose.length(); ) {
|
||||
int nextLine = compose.indexOf('\n', cursor);
|
||||
if (nextLine < 0) {
|
||||
return compose.substring(start);
|
||||
}
|
||||
int lineStart = nextLine + 1;
|
||||
if (lineStart + 2 < compose.length()
|
||||
&& compose.charAt(lineStart) == ' '
|
||||
&& compose.charAt(lineStart + 1) == ' '
|
||||
&& compose.charAt(lineStart + 2) != ' ') {
|
||||
return compose.substring(start, nextLine);
|
||||
}
|
||||
cursor = lineStart;
|
||||
}
|
||||
return compose.substring(start);
|
||||
}
|
||||
|
||||
private static Path repositoryRoot() {
|
||||
Path current = Path.of(System.getProperty("user.dir")).toAbsolutePath();
|
||||
while (current != null) {
|
||||
|
||||
Reference in New Issue
Block a user