|
@@ -6,6 +6,10 @@ import cn.reghao.bnt.web.devops.app.db.repository.AppDeployingRepository;
|
|
|
import cn.reghao.bnt.web.devops.app.db.repository.config.AppConfigRepository;
|
|
import cn.reghao.bnt.web.devops.app.db.repository.config.AppConfigRepository;
|
|
|
import cn.reghao.bnt.web.devops.app.db.repository.config.AppDeployConfigRepository;
|
|
import cn.reghao.bnt.web.devops.app.db.repository.config.AppDeployConfigRepository;
|
|
|
import cn.reghao.bnt.web.devops.app.model.po.AppBuilding;
|
|
import cn.reghao.bnt.web.devops.app.model.po.AppBuilding;
|
|
|
|
|
+import cn.reghao.bnt.web.devops.app.model.po.AppDeploying;
|
|
|
|
|
+import cn.reghao.bnt.web.devops.app.model.po.AppDeployingNode;
|
|
|
|
|
+import cn.reghao.bnt.web.devops.app.model.po.config.AppConfig;
|
|
|
|
|
+import cn.reghao.bnt.web.devops.app.model.po.config.AppDeployConfig;
|
|
|
import cn.reghao.bnt.web.sys.service.NotifyService;
|
|
import cn.reghao.bnt.web.sys.service.NotifyService;
|
|
|
import cn.reghao.bnt.web.sys.db.repository.EmailAccountRepository;
|
|
import cn.reghao.bnt.web.sys.db.repository.EmailAccountRepository;
|
|
|
import cn.reghao.bnt.web.sys.db.repository.NotifyReceiverRepository;
|
|
import cn.reghao.bnt.web.sys.db.repository.NotifyReceiverRepository;
|
|
@@ -17,6 +21,8 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.ActiveProfiles;
|
|
import org.springframework.test.context.ActiveProfiles;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @author reghao
|
|
* @author reghao
|
|
|
* @date 2022-08-17 15:53:04
|
|
* @date 2022-08-17 15:53:04
|
|
@@ -51,14 +57,36 @@ public class AppConfigTest {
|
|
|
AppDeployConfigRepository deployConfigRepository;
|
|
AppDeployConfigRepository deployConfigRepository;
|
|
|
@Test
|
|
@Test
|
|
|
public void appConfigTest() {
|
|
public void appConfigTest() {
|
|
|
- configRepository.findAll().forEach(appConfig -> {
|
|
|
|
|
|
|
+ /*configRepository.findAll().forEach(appConfig -> {
|
|
|
AppBuilding appBuilding = new AppBuilding(appConfig);
|
|
AppBuilding appBuilding = new AppBuilding(appConfig);
|
|
|
buildingRepository.save(appBuilding);
|
|
buildingRepository.save(appBuilding);
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- /*deployConfigRepository.findAll().forEach(appDeployConfig -> {
|
|
|
|
|
- AppDeploying appDeploying = new AppDeploying(appDeployConfig);
|
|
|
|
|
- deployingRepository.save(appDeploying);
|
|
|
|
|
});*/
|
|
});*/
|
|
|
|
|
+
|
|
|
|
|
+ deployConfigRepository.findAll().forEach(appDeployConfig -> {
|
|
|
|
|
+ AppConfig appConfig = appDeployConfig.getAppConfig();
|
|
|
|
|
+ AppDeploying appDeploying = deployingRepository.findByAppConfig(appConfig);
|
|
|
|
|
+ if (appDeploying == null) {
|
|
|
|
|
+ appDeploying = new AppDeploying(appDeployConfig);
|
|
|
|
|
+ deployingRepository.save(appDeploying);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ String machineId = appDeployConfig.getMachineHost().getMachineId();
|
|
|
|
|
+
|
|
|
|
|
+ boolean exist = false;
|
|
|
|
|
+ List<AppDeployingNode> deployingNodes = appDeploying.getDeployingNodes();
|
|
|
|
|
+ for (AppDeployingNode deployingNode : deployingNodes) {
|
|
|
|
|
+ AppDeployConfig deployConfig = deployingNode.getDeployConfig();
|
|
|
|
|
+ String machineId1 = deployConfig.getMachineHost().getMachineId();
|
|
|
|
|
+ if (machineId.equals(machineId1)) {
|
|
|
|
|
+ exist = true;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!exist) {
|
|
|
|
|
+ deployingNodes.add(new AppDeployingNode(appDeployConfig));
|
|
|
|
|
+ deployingRepository.save(appDeploying);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|