refactor: share portainer ingress env

This commit is contained in:
lingniu
2026-07-01 07:23:20 +08:00
parent e47e3eebb4
commit 4f83cd2792
2 changed files with 59 additions and 26 deletions

View File

@@ -150,6 +150,37 @@ class PortainerComposeResourceLimitsTest {
.doesNotContain("REDIS_PASSWORD");
}
@Test
void ingestAppsReuseSharedIdentityAndRedisEnvironmentAnchors() throws IOException {
String compose = Files.readString(repositoryRoot().resolve("deploy/portainer/docker-compose.yml"));
String gb32960Service = serviceBlock(compose, "gb32960-ingest-app");
String jt808Service = serviceBlock(compose, "jt808-ingest-app");
String mqttService = serviceBlock(compose, "yutong-mqtt-app");
assertThat(compose)
.contains("x-identity-mysql-env: &identity-mysql-env")
.contains("x-redis-session-env: &redis-session-env");
assertThat(gb32960Service)
.contains("- *identity-mysql-env")
.contains("- *redis-session-env");
assertThat(jt808Service)
.contains("- *identity-mysql-env")
.contains("- *redis-session-env");
assertThat(mqttService)
.contains("- *identity-mysql-env")
.doesNotContain("- *redis-session-env");
assertThat(gb32960Service + jt808Service + mqttService)
.doesNotContain("VEHICLE_IDENTITY_MYSQL_JDBC_URL")
.doesNotContain("VEHICLE_IDENTITY_MYSQL_USERNAME")
.doesNotContain("VEHICLE_IDENTITY_MYSQL_PASSWORD")
.doesNotContain("REDIS_HOST")
.doesNotContain("REDIS_PORT")
.doesNotContain("REDIS_DATABASE")
.doesNotContain("REDIS_USERNAME")
.doesNotContain("REDIS_PASSWORD");
}
@Test
void moduleDataFlowShowsSplitProductionAppsInsteadOfDeletedBootstrapAll() throws IOException {
String moduleDataFlow = Files.readString(repositoryRoot().resolve("docs/module-data-flow.html"));
@@ -202,7 +233,10 @@ class PortainerComposeResourceLimitsTest {
if (start < 0) {
throw new IllegalArgumentException("common env block not found");
}
int end = compose.indexOf("\nservices:\n", start);
int end = compose.indexOf("\nx-identity-mysql-env:", start);
if (end < 0) {
end = compose.indexOf("\nservices:\n", start);
}
if (end < 0) {
throw new IllegalArgumentException("services block not found");
}