fix:去除mq应用

This commit is contained in:
waner 2026-05-20 14:36:46 +08:00
parent c9a4242e40
commit 00001c6357
3 changed files with 57 additions and 13 deletions

View File

@ -817,11 +817,9 @@ public class ConfigurableInitStepExecutor implements InitStepExecutor {
int changed = 0; int changed = 0;
for (Path configFile : configFiles) { for (Path configFile : configFiles) {
changed += replaceProperty(configFile, "spring.rabbitmq.username", configuredUsername); appendLog(logFile, "skipped app rabbitmq credential rewrite: " + configFile);
changed += replaceProperty(configFile, "spring.rabbitmq.password", configuredPassword);
appendLog(logFile, "updated app rabbitmq credentials: " + configFile);
} }
return InitStepExecutionResult.success("应用MQ凭据已应用,变更数量=" + changed, 0, logFile.toString()); return InitStepExecutionResult.success("应用MQ凭据回写已跳过变更数量=" + changed, 0, logFile.toString());
} }
private InitStepExecutionResult executeDirectDbInit(InitTaskEntity task, InitTaskStepEntity step) throws IOException { private InitStepExecutionResult executeDirectDbInit(InitTaskEntity task, InitTaskStepEntity step) throws IOException {

View File

@ -147,7 +147,7 @@ tms:
standard-rabbit-queue-script-path-02: ${TMS_INIT_EXECUTOR_STANDARD_RABBIT_QUEUE_SCRIPT_PATH_02:${tms.init.executor.standard-home-dir}/cpackage/rabq/addrabq_R_02.sh} standard-rabbit-queue-script-path-02: ${TMS_INIT_EXECUTOR_STANDARD_RABBIT_QUEUE_SCRIPT_PATH_02:${tms.init.executor.standard-home-dir}/cpackage/rabq/addrabq_R_02.sh}
# 通道用户授权 vhost默认 /RQ # 通道用户授权 vhost默认 /RQ
rabbit-vhost: ${TMS_INIT_EXECUTOR_RABBIT_VHOST:/RQ} rabbit-vhost: ${TMS_INIT_EXECUTOR_RABBIT_VHOST:/RQ}
# 标准版应用配置文件匹配规则;用于回写 RabbitMQ 通道账号密码。 # 标准版应用配置文件匹配规则;保留历史配置项,当前不再回写 RabbitMQ 通道账号密码。
standard-rabbit-app-config-patterns: standard-rabbit-app-config-patterns:
- ${TMS_INIT_EXECUTOR_STANDARD_RABBIT_APP_CONFIG_PATTERN_1:${tms.init.executor.standard-home-dir}/cmsp/application-prd*.properties} - ${TMS_INIT_EXECUTOR_STANDARD_RABBIT_APP_CONFIG_PATTERN_1:${tms.init.executor.standard-home-dir}/cmsp/application-prd*.properties}
- ${TMS_INIT_EXECUTOR_STANDARD_RABBIT_APP_CONFIG_PATTERN_2:${tms.init.executor.standard-home-dir}/cmtp/application-prd*.properties} - ${TMS_INIT_EXECUTOR_STANDARD_RABBIT_APP_CONFIG_PATTERN_2:${tms.init.executor.standard-home-dir}/cmtp/application-prd*.properties}
@ -166,7 +166,7 @@ tms:
cisd: cisd:
preset: preset:
# 设备预制版本ENTERPRISE / INDIRECT / DIRECT。 # 设备预制版本ENTERPRISE / INDIRECT / DIRECT。
product-type: ${TMS_CISD_PRESET_PRODUCT_TYPE:ENTERPRISE} product-type: ${TMS_CISD_PRESET_PRODUCT_TYPE:INDIRECT}
# 预制版本号(用于前端展示与任务记录)。 # 预制版本号(用于前端展示与任务记录)。
version: ${TMS_CISD_PRESET_VERSION:V1.0.0} version: ${TMS_CISD_PRESET_VERSION:V1.0.0}
# 预制信息来源标识CONFIG/DB 等自定义值)。 # 预制信息来源标识CONFIG/DB 等自定义值)。

View File

@ -380,7 +380,7 @@ class ConfigurableInitStepExecutorTest {
} }
@Test @Test
void shouldApplyStandardAppMqCredentials() throws Exception { void shouldNotRewriteStandardAppMqCredentials() throws Exception {
Path tempRoot = Files.createTempDirectory("init-executor-standard-rabbit-cred-test"); Path tempRoot = Files.createTempDirectory("init-executor-standard-rabbit-cred-test");
Path cmspDir = tempRoot.resolve("cmsp"); Path cmspDir = tempRoot.resolve("cmsp");
Path cmtpDir = tempRoot.resolve("cmtp"); Path cmtpDir = tempRoot.resolve("cmtp");
@ -424,12 +424,58 @@ class ConfigurableInitStepExecutorTest {
InitStepExecutionResult result = executor.execute(task, step); InitStepExecutionResult result = executor.execute(task, step);
Assertions.assertTrue(result.isSuccess()); Assertions.assertTrue(result.isSuccess());
String encryptedUser = encryptWith3DesHex("new_user", "ABCDEFGHIJKLMN1234567890"); Assertions.assertEquals("spring.rabbitmq.username=OLD\nspring.rabbitmq.password=OLD\n", Files.readString(cmspCfg));
String encryptedPass = encryptWith3DesHex("new_pass", "ABCDEFGHIJKLMN1234567890"); Assertions.assertEquals("spring.rabbitmq.username=OLD\nspring.rabbitmq.password=OLD\n", Files.readString(cmtpCfg));
Assertions.assertTrue(Files.readString(cmspCfg).contains("spring.rabbitmq.username=" + encryptedUser)); }
Assertions.assertTrue(Files.readString(cmspCfg).contains("spring.rabbitmq.password=" + encryptedPass));
Assertions.assertTrue(Files.readString(cmtpCfg).contains("spring.rabbitmq.username=" + encryptedUser)); @Test
Assertions.assertTrue(Files.readString(cmtpCfg).contains("spring.rabbitmq.password=" + encryptedPass)); void shouldNotRewriteStandardMediaTemplateWhenApplyingAppMqCredentials() throws Exception {
Path tempRoot = Files.createTempDirectory("init-executor-standard-rabbit-template-test");
Path templateDir = tempRoot.resolve("cpackage/cmsp/01");
Path runtimeDir = tempRoot.resolve("cmsp");
Files.createDirectories(templateDir);
Files.createDirectories(runtimeDir);
Path templateCfg = templateDir.resolve("application-prd-ci01.properties");
Path runtimeCfg = runtimeDir.resolve("application-prd-ci01.properties");
String original = "spring.rabbitmq.username=FIXED\nspring.rabbitmq.password=FIXED\n";
Files.writeString(templateCfg, original);
Files.writeString(runtimeCfg, "spring.rabbitmq.username=OLD\nspring.rabbitmq.password=OLD\n");
InitExecutorProperties properties = new InitExecutorProperties();
properties.setMode(InitExecutorProperties.Mode.LOCAL);
properties.setLogDir(tempRoot.resolve("logs").toString());
properties.setStandardRabbitAppConfigPatterns(List.of(
templateCfg.toString(),
runtimeCfg.toString()
));
ConfigurableInitStepExecutor executor = new ConfigurableInitStepExecutor(properties, new ObjectMapper());
InitTaskEntity task = new InitTaskEntity();
task.setTaskId("TASK-APP-CRED-TEMPLATE-1");
task.setProductType("ENTERPRISE");
task.setInitPlanJson(buildInitPlanJson(
"ENTERPRISE",
Map.of(
"orgCodeType", "BIC",
"orgCode", "AAAABBBBXXX",
"orgNameCn", "测试机构",
"orgNameEn", "TEST BANK",
"deployMode", "SINGLE",
"nodes", Map.of("node01Ip", "10.0.1.1"),
"mq", Map.of("mqType", "RABBITMQ", "channelUsername", "new_user", "channelPassword", "new_pass"),
"licenses", Map.of("receiverLicenseFileId", "file-receiver-001")
)
));
InitTaskStepEntity step = new InitTaskStepEntity();
step.setStepNo(1);
step.setStepCode("APP_MQ_CREDENTIALS_APPLY");
step.setCommandLine("internal::app_mq_credentials_apply");
InitStepExecutionResult result = executor.execute(task, step);
Assertions.assertTrue(result.isSuccess());
Assertions.assertEquals(original, Files.readString(templateCfg));
Assertions.assertEquals("spring.rabbitmq.username=OLD\nspring.rabbitmq.password=OLD\n", Files.readString(runtimeCfg));
} }
@Test @Test