chore: scope mysql env in portainer stack
This commit is contained in:
@@ -577,6 +577,35 @@ class PortainerComposeResourceLimitsTest {
|
||||
.doesNotContain("REDIS_PASSWORD");
|
||||
}
|
||||
|
||||
@Test
|
||||
void mysqlEnvironmentIsScopedToIdentityAndAnalyticsOnly() throws IOException {
|
||||
String compose = Files.readString(repositoryRoot().resolve("deploy/portainer/docker-compose.yml"));
|
||||
String commonEnv = commonEnvBlock(compose);
|
||||
String identityEnv = blockBetween(compose, "x-identity-mysql-env: &identity-mysql-env\n",
|
||||
"\nx-redis-session-env:");
|
||||
String ingestServices = serviceBlock(compose, "gb32960-ingest-app")
|
||||
+ serviceBlock(compose, "jt808-ingest-app")
|
||||
+ serviceBlock(compose, "yutong-mqtt-app");
|
||||
String analyticsService = serviceBlock(compose, "vehicle-analytics-app");
|
||||
|
||||
assertThat(commonEnv)
|
||||
.doesNotContain("MYSQL_JDBC_URL")
|
||||
.doesNotContain("MYSQL_USERNAME")
|
||||
.doesNotContain("MYSQL_PASSWORD");
|
||||
assertThat(identityEnv)
|
||||
.contains("VEHICLE_IDENTITY_MYSQL_JDBC_URL: ${MYSQL_JDBC_URL:-}")
|
||||
.contains("VEHICLE_IDENTITY_MYSQL_USERNAME: ${MYSQL_USERNAME:-}")
|
||||
.contains("VEHICLE_IDENTITY_MYSQL_PASSWORD: ${MYSQL_PASSWORD:-}");
|
||||
assertThat(ingestServices)
|
||||
.doesNotContain("\n MYSQL_JDBC_URL:")
|
||||
.doesNotContain("\n MYSQL_USERNAME:")
|
||||
.doesNotContain("\n MYSQL_PASSWORD:");
|
||||
assertThat(analyticsService)
|
||||
.contains("MYSQL_JDBC_URL: ${MYSQL_JDBC_URL:-}")
|
||||
.contains("MYSQL_USERNAME: ${MYSQL_USERNAME:-}")
|
||||
.contains("MYSQL_PASSWORD: ${MYSQL_PASSWORD:-}");
|
||||
}
|
||||
|
||||
@Test
|
||||
void ingestAppsReuseSharedIdentityAndRedisEnvironmentAnchors() throws IOException {
|
||||
String compose = Files.readString(repositoryRoot().resolve("deploy/portainer/docker-compose.yml"));
|
||||
@@ -700,6 +729,18 @@ class PortainerComposeResourceLimitsTest {
|
||||
return compose.substring(start, end);
|
||||
}
|
||||
|
||||
private static String blockBetween(String text, String startMarker, String endMarker) {
|
||||
int start = text.indexOf(startMarker);
|
||||
if (start < 0) {
|
||||
throw new IllegalArgumentException("block start not found: " + startMarker);
|
||||
}
|
||||
int end = text.indexOf(endMarker, start + startMarker.length());
|
||||
if (end < 0) {
|
||||
throw new IllegalArgumentException("block end not found: " + endMarker);
|
||||
}
|
||||
return text.substring(start, end);
|
||||
}
|
||||
|
||||
private static int countOccurrences(String text, String needle) {
|
||||
int count = 0;
|
||||
int index = 0;
|
||||
|
||||
Reference in New Issue
Block a user