[ Server ] [ Executor ] - 初步实现测试代码

This commit is contained in:
zeaslity
2023-10-23 16:58:34 +08:00
parent b42748cfbb
commit 92a10b6dbd
10 changed files with 101 additions and 14 deletions

View File

@@ -37,7 +37,7 @@ public class BaseFuncScheduler {
private void afterRunProcedure() { private void afterRunProcedure() {
// 检查是否安装完成, 对安装环境进行判定 // 检查是否安装完成, 对安装环境进行判定
log.debug("afterRunProcedure complete!");
} }
private void doRunProcedure(ProjectDeployContext projectDeployContext) { private void doRunProcedure(ProjectDeployContext projectDeployContext) {
@@ -75,6 +75,8 @@ public class BaseFuncScheduler {
// 打印施工信息 // 打印施工信息
log.debug("beforeRunProcedure complete!");
} }
private boolean MasterNodeProcedure(String masterTopicName) { private boolean MasterNodeProcedure(String masterTopicName) {

View File

@@ -52,7 +52,7 @@ public class ProjectServerController {
@PostMapping("/create") @PostMapping("/create")
@ApiOperation("Project-Server-创建一个Project-Server半丁关系") @ApiOperation("Project-Server-创建一个Project-Server绑定关系")
public R<String> projectServerCreate( public R<String> projectServerCreate(
@RequestParam(value = "projectId", name = "projectId") @RequestParam(value = "projectId", name = "projectId")
@ApiParam(value = "projectId") Long projectId, @ApiParam(value = "projectId") Long projectId,
@@ -72,6 +72,26 @@ public class ProjectServerController {
return R.ok(result); 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") @PostMapping("/update")
@ApiOperation("Project-Server-更新一个Project-Server") @ApiOperation("Project-Server-更新一个Project-Server")
public R<String> projectServerUpdate( public R<String> projectServerUpdate(

View File

@@ -31,7 +31,7 @@ public class ServerController {
@PostMapping("/all") @PostMapping("/all")
@ApiOperation("获取服务器信息-web") @ApiOperation("获取服务器信息-web")
public R<Page<ServerInfoVO>> serverGetAllByPage( public R<Page<ServerInfoPO>> serverGetAllByPage(
@RequestBody ServerQueryEntity serverQueryEntity @RequestBody ServerQueryEntity serverQueryEntity
) { ) {

View File

@@ -16,6 +16,8 @@ public interface CoreProjectServerService {
boolean projectServerCreate(Long projectId, Long serverId); boolean projectServerCreate(Long projectId, Long serverId);
boolean projectServerCreateMulti(Long projectId, List<Long> serverIdList);
boolean projectServerUpdate(Long projectId, Long serverId); boolean projectServerUpdate(Long projectId, Long serverId);
boolean projectServerDelete(Long projectId, Long serverId); boolean projectServerDelete(Long projectId, Long serverId);

View File

@@ -19,7 +19,7 @@ public interface CoreServerService {
/** /**
* 查询主机信息,但是是条件查询 * 查询主机信息,但是是条件查询
*/ */
Page<ServerInfoVO> serverGetByPage(ServerQueryEntity serverQueryEntity); Page<ServerInfoPO> serverGetByPage(ServerQueryEntity serverQueryEntity);
List<ServerInfoVO> serverGetAllIncludeDelete(); List<ServerInfoVO> serverGetAllIncludeDelete();

View File

@@ -138,10 +138,29 @@ public class CoreProjectServerServiceImpl implements CoreProjectServerService {
return projectServerRelationService.save(projectServerRelationPO); 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 @Override
public boolean projectServerUpdate(Long projectId, Long serverId) { public boolean projectServerUpdate(Long projectId, Long serverId) {
return this.projectServerCreate(projectId, return this.projectServerCreate(
serverId); projectId,
serverId
);
} }
@Override @Override

View File

@@ -46,19 +46,18 @@ public class CoreProjectServiceImpl implements CoreProjectService {
); );
new LambdaQueryChainWrapper<ProjectInfoPO>(projectInfoService.getBaseMapper()) new LambdaQueryChainWrapper<ProjectInfoPO>(projectInfoService.getBaseMapper())
.likeLeft( .likeRight(
StringUtils.isNotBlank(projectQueryEntity.getProjectName()), StringUtils.isNotBlank(projectQueryEntity.getProjectName()),
ProjectInfoPO::getProjectName, ProjectInfoPO::getProjectName,
projectQueryEntity.getProjectName() projectQueryEntity.getProjectName()
) )
.likeLeft( .likeRight(
StringUtils.isNotBlank(projectQueryEntity.getProjectProvince()), StringUtils.isNotBlank(projectQueryEntity.getProjectProvince()),
ProjectInfoPO::getProjectProvince, ProjectInfoPO::getProjectProvince,
projectQueryEntity.getProjectProvince() projectQueryEntity.getProjectProvince()
) )
.page(poPage); .page(poPage);
return poPage; return poPage;
} }

View File

@@ -85,7 +85,7 @@ public class CoreServerServiceImpl implements CoreServerService {
} }
@Override @Override
public Page<ServerInfoVO> serverGetByPage(ServerQueryEntity serverQueryEntity) { public Page<ServerInfoPO> serverGetByPage(ServerQueryEntity serverQueryEntity) {
// 默认数值处理 // 默认数值处理
if (serverQueryEntity == null || serverQueryEntity.getPageSize() == null || serverQueryEntity.getPageNumber() == null) { if (serverQueryEntity == null || serverQueryEntity.getPageSize() == null || serverQueryEntity.getPageNumber() == null) {
@@ -129,7 +129,7 @@ public class CoreServerServiceImpl implements CoreServerService {
// 将查询结果中的User对象转换为UserVO对象 // 将查询结果中的User对象转换为UserVO对象
Page<ServerInfoVO> serverInfoVOPage = new Page<>( /*Page<ServerInfoVO> serverInfoVOPage = new Page<>(
serverInfoPOPage.getCurrent(), serverInfoPOPage.getCurrent(),
serverInfoPOPage.getSize() serverInfoPOPage.getSize()
); );
@@ -139,9 +139,9 @@ public class CoreServerServiceImpl implements CoreServerService {
serverInfoPOPage.getRecords(), serverInfoPOPage.getRecords(),
(serverQueryEntity.getPageNumber() - 1) * serverQueryEntity.getPageSize() (serverQueryEntity.getPageNumber() - 1) * serverQueryEntity.getPageSize()
) )
); );*/
return serverInfoVOPage; return serverInfoPOPage;
} }
@Override @Override

View File

@@ -27,7 +27,7 @@ public class ServerInfoTest {
ServerQueryEntity serverQueryEntity = new ServerQueryEntity(); ServerQueryEntity serverQueryEntity = new ServerQueryEntity();
// Act // Act
R<Page<ServerInfoVO>> result = serverController.serverGetAllByPage(serverQueryEntity); R<Page<ServerInfoPO>> result = serverController.serverGetAllByPage(serverQueryEntity);
// Assert // Assert
assertNotNull(result); assertNotNull(result);

View File

@@ -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);
}
}