fix:mq
This commit is contained in:
parent
e06317c883
commit
6cf9bae121
@ -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.config.ResourceBackupProperties;
|
||||||
import com.cisd.tms.modules.backup.dto.support.ConfiguredRestoreCommand;
|
import com.cisd.tms.modules.backup.dto.support.ConfiguredRestoreCommand;
|
||||||
|
import com.cisd.tms.modules.init.config.InitExecutorProperties;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@ -16,6 +17,7 @@ import org.springframework.stereotype.Component;
|
|||||||
public class LightweightRestoreApplierLauncher {
|
public class LightweightRestoreApplierLauncher {
|
||||||
|
|
||||||
private final ResourceBackupProperties properties;
|
private final ResourceBackupProperties properties;
|
||||||
|
private final InitExecutorProperties initExecutorProperties;
|
||||||
private final RestoreCommandInvoker invoker;
|
private final RestoreCommandInvoker invoker;
|
||||||
private final String datasourceUrl;
|
private final String datasourceUrl;
|
||||||
private final String datasourceUsername;
|
private final String datasourceUsername;
|
||||||
@ -25,6 +27,7 @@ public class LightweightRestoreApplierLauncher {
|
|||||||
|
|
||||||
public LightweightRestoreApplierLauncher(
|
public LightweightRestoreApplierLauncher(
|
||||||
ResourceBackupProperties properties,
|
ResourceBackupProperties properties,
|
||||||
|
InitExecutorProperties initExecutorProperties,
|
||||||
RestoreCommandInvoker invoker,
|
RestoreCommandInvoker invoker,
|
||||||
@Value("${spring.datasource.url:}") String datasourceUrl,
|
@Value("${spring.datasource.url:}") String datasourceUrl,
|
||||||
@Value("${spring.datasource.username:}") String datasourceUsername,
|
@Value("${spring.datasource.username:}") String datasourceUsername,
|
||||||
@ -33,6 +36,7 @@ public class LightweightRestoreApplierLauncher {
|
|||||||
@Value("${tms.init.executor.standard-run-user:cmep4i}") String standardRunUser
|
@Value("${tms.init.executor.standard-run-user:cmep4i}") String standardRunUser
|
||||||
) {
|
) {
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
|
this.initExecutorProperties = initExecutorProperties == null ? new InitExecutorProperties() : initExecutorProperties;
|
||||||
this.invoker = invoker;
|
this.invoker = invoker;
|
||||||
this.datasourceUrl = datasourceUrl;
|
this.datasourceUrl = datasourceUrl;
|
||||||
this.datasourceUsername = datasourceUsername;
|
this.datasourceUsername = datasourceUsername;
|
||||||
@ -115,6 +119,7 @@ public class LightweightRestoreApplierLauncher {
|
|||||||
values.put("DB_RESTORE_SCRIPT_PATH", trim(properties.getRestoreDbScriptPath()));
|
values.put("DB_RESTORE_SCRIPT_PATH", trim(properties.getRestoreDbScriptPath()));
|
||||||
values.put("RESTORE_DB_TIMEOUT_SECONDS", String.valueOf(properties.getRestoreDbTimeoutSeconds()));
|
values.put("RESTORE_DB_TIMEOUT_SECONDS", String.valueOf(properties.getRestoreDbTimeoutSeconds()));
|
||||||
values.put("MQ_REPLAY_SCRIPT_PATH", trim(properties.getMqReplayScriptPath()));
|
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("MYSQL_PATH", trim(properties.getMysqlPath()).isEmpty() ? "mysql" : trim(properties.getMysqlPath()));
|
||||||
values.put("DB_HOST", target.host());
|
values.put("DB_HOST", target.host());
|
||||||
values.put("DB_PORT", target.port());
|
values.put("DB_PORT", target.port());
|
||||||
|
|||||||
@ -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.config.ResourceBackupProperties;
|
||||||
import com.cisd.tms.modules.backup.dto.support.ConfiguredRestoreCommand;
|
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.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -36,9 +37,12 @@ class LightweightRestoreApplierLauncherTest {
|
|||||||
);
|
);
|
||||||
properties.setRestoreStartCommands(List.of(tmsStart, standardStart, directOnlyStart));
|
properties.setRestoreStartCommands(List.of(tmsStart, standardStart, directOnlyStart));
|
||||||
properties.setRestoreStopCommands(List.of(restoreCommand("TMS", "/home/tms/scripts/tms.sh stop", false)));
|
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();
|
RecordingInvoker invoker = new RecordingInvoker();
|
||||||
LightweightRestoreApplierLauncher launcher = new LightweightRestoreApplierLauncher(
|
LightweightRestoreApplierLauncher launcher = new LightweightRestoreApplierLauncher(
|
||||||
properties,
|
properties,
|
||||||
|
initProperties,
|
||||||
invoker,
|
invoker,
|
||||||
"jdbc:mysql://db-host:4000/tms?useUnicode=true",
|
"jdbc:mysql://db-host:4000/tms?useUnicode=true",
|
||||||
"root",
|
"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 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 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 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 MYSQL_PATH='mysql'"));
|
||||||
Assertions.assertTrue(env.contains("export DB_HOST='db-host'"));
|
Assertions.assertTrue(env.contains("export DB_HOST='db-host'"));
|
||||||
Assertions.assertTrue(env.contains("export DB_PORT='4000'"));
|
Assertions.assertTrue(env.contains("export DB_PORT='4000'"));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user