diff --git a/src/main/java/com/cisd/tms/modules/backup/restore/LightweightRestoreApplierLauncher.java b/src/main/java/com/cisd/tms/modules/backup/restore/LightweightRestoreApplierLauncher.java index f51b482..b9e3f64 100644 --- a/src/main/java/com/cisd/tms/modules/backup/restore/LightweightRestoreApplierLauncher.java +++ b/src/main/java/com/cisd/tms/modules/backup/restore/LightweightRestoreApplierLauncher.java @@ -2,6 +2,7 @@ package com.cisd.tms.modules.backup.restore; import com.cisd.tms.modules.backup.config.ResourceBackupProperties; import com.cisd.tms.modules.backup.dto.support.ConfiguredRestoreCommand; +import com.cisd.tms.modules.init.config.InitExecutorProperties; import java.io.IOException; import java.net.URI; import java.nio.file.Files; @@ -16,6 +17,7 @@ import org.springframework.stereotype.Component; public class LightweightRestoreApplierLauncher { private final ResourceBackupProperties properties; + private final InitExecutorProperties initExecutorProperties; private final RestoreCommandInvoker invoker; private final String datasourceUrl; private final String datasourceUsername; @@ -25,6 +27,7 @@ public class LightweightRestoreApplierLauncher { public LightweightRestoreApplierLauncher( ResourceBackupProperties properties, + InitExecutorProperties initExecutorProperties, RestoreCommandInvoker invoker, @Value("${spring.datasource.url:}") String datasourceUrl, @Value("${spring.datasource.username:}") String datasourceUsername, @@ -33,6 +36,7 @@ public class LightweightRestoreApplierLauncher { @Value("${tms.init.executor.standard-run-user:cmep4i}") String standardRunUser ) { this.properties = properties; + this.initExecutorProperties = initExecutorProperties == null ? new InitExecutorProperties() : initExecutorProperties; this.invoker = invoker; this.datasourceUrl = datasourceUrl; this.datasourceUsername = datasourceUsername; @@ -115,6 +119,7 @@ public class LightweightRestoreApplierLauncher { values.put("DB_RESTORE_SCRIPT_PATH", trim(properties.getRestoreDbScriptPath())); values.put("RESTORE_DB_TIMEOUT_SECONDS", String.valueOf(properties.getRestoreDbTimeoutSeconds())); values.put("MQ_REPLAY_SCRIPT_PATH", trim(properties.getMqReplayScriptPath())); + values.put("RABBITMQ_CTL_COMMAND", trim(initExecutorProperties.getRabbitmqCtlCommand())); values.put("MYSQL_PATH", trim(properties.getMysqlPath()).isEmpty() ? "mysql" : trim(properties.getMysqlPath())); values.put("DB_HOST", target.host()); values.put("DB_PORT", target.port()); diff --git a/src/test/java/com/cisd/tms/modules/backup/restore/LightweightRestoreApplierLauncherTest.java b/src/test/java/com/cisd/tms/modules/backup/restore/LightweightRestoreApplierLauncherTest.java index 8266ee5..65514b6 100644 --- a/src/test/java/com/cisd/tms/modules/backup/restore/LightweightRestoreApplierLauncherTest.java +++ b/src/test/java/com/cisd/tms/modules/backup/restore/LightweightRestoreApplierLauncherTest.java @@ -2,6 +2,7 @@ package com.cisd.tms.modules.backup.restore; import com.cisd.tms.modules.backup.config.ResourceBackupProperties; import com.cisd.tms.modules.backup.dto.support.ConfiguredRestoreCommand; +import com.cisd.tms.modules.init.config.InitExecutorProperties; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; @@ -36,9 +37,12 @@ class LightweightRestoreApplierLauncherTest { ); properties.setRestoreStartCommands(List.of(tmsStart, standardStart, directOnlyStart)); properties.setRestoreStopCommands(List.of(restoreCommand("TMS", "/home/tms/scripts/tms.sh stop", false))); + InitExecutorProperties initProperties = new InitExecutorProperties(); + initProperties.setRabbitmqCtlCommand("sudo -n /usr/local/sbin/tms-rabbitmqctl"); RecordingInvoker invoker = new RecordingInvoker(); LightweightRestoreApplierLauncher launcher = new LightweightRestoreApplierLauncher( properties, + initProperties, invoker, "jdbc:mysql://db-host:4000/tms?useUnicode=true", "root", @@ -63,6 +67,7 @@ class LightweightRestoreApplierLauncherTest { Assertions.assertTrue(env.contains("export DB_RESTORE_SCRIPT_PATH='/home/tms/bin/resource-restore/restore-db.sh'")); Assertions.assertTrue(env.contains("export RESTORE_DB_TIMEOUT_SECONDS='300'")); Assertions.assertTrue(env.contains("export MQ_REPLAY_SCRIPT_PATH='/home/tms/bin/resource-restore/replay-mq.sh'")); + Assertions.assertTrue(env.contains("export RABBITMQ_CTL_COMMAND='sudo -n /usr/local/sbin/tms-rabbitmqctl'")); Assertions.assertTrue(env.contains("export MYSQL_PATH='mysql'")); Assertions.assertTrue(env.contains("export DB_HOST='db-host'")); Assertions.assertTrue(env.contains("export DB_PORT='4000'"));