[ Server ] [ Executor ] - 初步实现测试代码
This commit is contained in:
@@ -37,7 +37,7 @@ public class BaseFuncScheduler {
|
||||
private void afterRunProcedure() {
|
||||
|
||||
// 检查是否安装完成, 对安装环境进行判定
|
||||
|
||||
log.debug("afterRunProcedure complete!");
|
||||
}
|
||||
|
||||
private void doRunProcedure(ProjectDeployContext projectDeployContext) {
|
||||
@@ -75,6 +75,8 @@ public class BaseFuncScheduler {
|
||||
|
||||
// 打印施工信息
|
||||
|
||||
log.debug("beforeRunProcedure complete!");
|
||||
|
||||
}
|
||||
|
||||
private boolean MasterNodeProcedure(String masterTopicName) {
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ProjectServerController {
|
||||
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("Project-Server-创建一个Project-Server半丁关系")
|
||||
@ApiOperation("Project-Server-创建一个Project-Server绑定关系")
|
||||
public R<String> projectServerCreate(
|
||||
@RequestParam(value = "projectId", name = "projectId")
|
||||
@ApiParam(value = "projectId") Long projectId,
|
||||
@@ -72,6 +72,26 @@ public class ProjectServerController {
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
@PostMapping("/create/multi")
|
||||
@ApiOperation("Project-Server-创建一对多的Project-Server绑定关系")
|
||||
public R<String> projectServerCreateMulti(
|
||||
@RequestParam(value = "projectId", name = "projectId")
|
||||
@ApiParam(value = "projectId") Long projectId,
|
||||
@RequestParam(value = "serverIdList", name = "serverIdList")
|
||||
@ApiParam(value = "serverIdList") List<Long> serverIdList
|
||||
) {
|
||||
|
||||
String result = "创建Project-Server成功!";
|
||||
|
||||
if (!coreProjectServerService.projectServerCreateMulti(
|
||||
projectId,
|
||||
serverIdList
|
||||
)) {
|
||||
result = "创建Project-Server失败!";
|
||||
}
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("Project-Server-更新一个Project-Server")
|
||||
public R<String> projectServerUpdate(
|
||||
|
||||
@@ -31,7 +31,7 @@ public class ServerController {
|
||||
|
||||
@PostMapping("/all")
|
||||
@ApiOperation("获取服务器信息-web")
|
||||
public R<Page<ServerInfoVO>> serverGetAllByPage(
|
||||
public R<Page<ServerInfoPO>> serverGetAllByPage(
|
||||
@RequestBody ServerQueryEntity serverQueryEntity
|
||||
) {
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ public interface CoreProjectServerService {
|
||||
|
||||
boolean projectServerCreate(Long projectId, Long serverId);
|
||||
|
||||
boolean projectServerCreateMulti(Long projectId, List<Long> serverIdList);
|
||||
|
||||
boolean projectServerUpdate(Long projectId, Long serverId);
|
||||
|
||||
boolean projectServerDelete(Long projectId, Long serverId);
|
||||
|
||||
@@ -19,7 +19,7 @@ public interface CoreServerService {
|
||||
/**
|
||||
* 查询主机信息,但是是条件查询
|
||||
*/
|
||||
Page<ServerInfoVO> serverGetByPage(ServerQueryEntity serverQueryEntity);
|
||||
Page<ServerInfoPO> serverGetByPage(ServerQueryEntity serverQueryEntity);
|
||||
|
||||
List<ServerInfoVO> serverGetAllIncludeDelete();
|
||||
|
||||
|
||||
@@ -138,10 +138,29 @@ public class CoreProjectServerServiceImpl implements CoreProjectServerService {
|
||||
return projectServerRelationService.save(projectServerRelationPO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean projectServerCreateMulti(Long projectId, List<Long> serverIdList) {
|
||||
|
||||
for (Long serverId : serverIdList) {
|
||||
if (!this.projectServerCreate(
|
||||
projectId,
|
||||
serverId
|
||||
)) {
|
||||
|
||||
log.error("绑定失败!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean projectServerUpdate(Long projectId, Long serverId) {
|
||||
return this.projectServerCreate(projectId,
|
||||
serverId);
|
||||
return this.projectServerCreate(
|
||||
projectId,
|
||||
serverId
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -46,19 +46,18 @@ public class CoreProjectServiceImpl implements CoreProjectService {
|
||||
);
|
||||
|
||||
new LambdaQueryChainWrapper<ProjectInfoPO>(projectInfoService.getBaseMapper())
|
||||
.likeLeft(
|
||||
.likeRight(
|
||||
StringUtils.isNotBlank(projectQueryEntity.getProjectName()),
|
||||
ProjectInfoPO::getProjectName,
|
||||
projectQueryEntity.getProjectName()
|
||||
)
|
||||
.likeLeft(
|
||||
.likeRight(
|
||||
StringUtils.isNotBlank(projectQueryEntity.getProjectProvince()),
|
||||
ProjectInfoPO::getProjectProvince,
|
||||
projectQueryEntity.getProjectProvince()
|
||||
)
|
||||
.page(poPage);
|
||||
|
||||
|
||||
return poPage;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public class CoreServerServiceImpl implements CoreServerService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ServerInfoVO> serverGetByPage(ServerQueryEntity serverQueryEntity) {
|
||||
public Page<ServerInfoPO> serverGetByPage(ServerQueryEntity serverQueryEntity) {
|
||||
|
||||
// 默认数值处理
|
||||
if (serverQueryEntity == null || serverQueryEntity.getPageSize() == null || serverQueryEntity.getPageNumber() == null) {
|
||||
@@ -129,7 +129,7 @@ public class CoreServerServiceImpl implements CoreServerService {
|
||||
|
||||
|
||||
// 将查询结果中的User对象转换为UserVO对象
|
||||
Page<ServerInfoVO> serverInfoVOPage = new Page<>(
|
||||
/*Page<ServerInfoVO> serverInfoVOPage = new Page<>(
|
||||
serverInfoPOPage.getCurrent(),
|
||||
serverInfoPOPage.getSize()
|
||||
);
|
||||
@@ -139,9 +139,9 @@ public class CoreServerServiceImpl implements CoreServerService {
|
||||
serverInfoPOPage.getRecords(),
|
||||
(serverQueryEntity.getPageNumber() - 1) * serverQueryEntity.getPageSize()
|
||||
)
|
||||
);
|
||||
);*/
|
||||
|
||||
return serverInfoVOPage;
|
||||
return serverInfoPOPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ServerInfoTest {
|
||||
ServerQueryEntity serverQueryEntity = new ServerQueryEntity();
|
||||
|
||||
// Act
|
||||
R<Page<ServerInfoVO>> result = serverController.serverGetAllByPage(serverQueryEntity);
|
||||
R<Page<ServerInfoPO>> result = serverController.serverGetAllByPage(serverQueryEntity);
|
||||
|
||||
// Assert
|
||||
assertNotNull(result);
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package io.wdd.server.func;
|
||||
|
||||
import io.wdd.func.auto.beans.ProjectDeployContext;
|
||||
import io.wdd.func.auto.service.BaseFuncScheduler;
|
||||
import io.wdd.server.beans.po.ServerInfoPO;
|
||||
import io.wdd.server.beans.request.ServerQueryEntity;
|
||||
import io.wdd.server.coreService.CoreServerService;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@SpringBootTest
|
||||
public class TestBaseFuncScheduler {
|
||||
|
||||
|
||||
@Resource
|
||||
BaseFuncScheduler baseFuncScheduler;
|
||||
|
||||
@Resource
|
||||
CoreServerService serverService;
|
||||
|
||||
|
||||
@Test
|
||||
public void testRunProcedure() {
|
||||
|
||||
ProjectDeployContext projectDeployContext = new ProjectDeployContext();
|
||||
|
||||
projectDeployContext.setProjectId(1716372290994155522L);
|
||||
|
||||
ServerQueryEntity serverQueryEntity = new ServerQueryEntity();
|
||||
serverQueryEntity.setServerName("Osaka");
|
||||
ServerInfoPO serverInfoPO = serverService
|
||||
.serverGetByPage(serverQueryEntity)
|
||||
.getRecords()
|
||||
.get(0);
|
||||
|
||||
projectDeployContext.setMasterNode(serverInfoPO);
|
||||
|
||||
|
||||
baseFuncScheduler.runProcedure(projectDeployContext);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user