use of com.ibeiliao.deployment.admin.vo.deploy.DeployHistory in project Corgi by kevinYin.
the class DeployHistoryServiceImplTest method testCreateDeploymentOrder.
/**
* 测试创建上线单
* 期望:
* (1)创建成功
* (2)校验参数成功
* (3)审核成功
*/
@Test
public void testCreateDeploymentOrder() {
// 前提:
// 1. 创建 account
// 2. 创建 project
// 3. 创建 module
// 4. 创建 server group & server
// 5. 初始化 env
InitTestDataService.InitData data = initTestDataService.init();
ProjectEnv env = data.envs.get(0);
DeploymentOrder order = new DeploymentOrder();
order.setAccountId((int) data.account.getUid());
order.setRealName(data.account.getRealname());
order.setConcurrentServerPercentage((short) 10);
order.setDeployTimeInterval((short) 30);
order.setModuleId(data.module.getModuleId());
order.setProjectId(data.project.getProjectId());
order.setTagName("/tags/" + System.currentTimeMillis());
order.setTitle("测试创建上线单");
order.setServerId(getServerIds(data));
order.setVersionNo("12345");
order.setEnvId(env.getEnvId());
deployHistoryService.createDeploymentOrder(order);
List<DeployHistory> deployHistories = deployHistoryService.queryDeployHistory(order.getAccountId(), 0, 0, 0, 1, 10);
assertNotNull(deployHistories);
assertTrue(deployHistories.size() >= 1);
DeployHistory history = deployHistories.get(0);
// 判断状态
assertTrue(history.getHistoryId() > 0);
assertEquals(order.getTagName(), history.getTagName());
assertEquals(order.getTitle(), history.getTitle());
assertTrue(history.getDeployStatus() == DeployStatus.WAITING_FOR_AUDIT.getValue());
assertTrue(history.getResult() == 0);
assertTrue(order.getServerId().length == history.getDeployServers());
assertTrue(order.getConcurrentServerPercentage() == history.getConcurrentServerPercentage());
assertTrue(order.getAccountId() == history.getAccountId());
assertTrue(order.getModuleId() == history.getModuleId());
assertTrue(order.getProjectId() == history.getProjectId());
assertEquals(data.project.getProjectName(), history.getProjectName());
assertEquals(data.module.getModuleName(), history.getModuleName());
testGetDeployHistory(history.getHistoryId(), order);
testAudit(data.account.getUid(), history.getHistoryId());
}
use of com.ibeiliao.deployment.admin.vo.deploy.DeployHistory in project Corgi by kevinYin.
the class DeployHistoryServiceImplTest method createDeployHistory.
private DeployHistory createDeployHistory() {
InitTestDataService.InitData data = initTestDataService.init();
ProjectEnv env = data.envs.get(0);
DeploymentOrder order = new DeploymentOrder();
order.setAccountId((int) data.account.getUid());
order.setRealName(data.account.getRealname());
order.setConcurrentServerPercentage((short) 10);
order.setDeployTimeInterval((short) 30);
order.setModuleId(data.module.getModuleId());
order.setProjectId(data.project.getProjectId());
order.setTagName("tags/" + System.currentTimeMillis());
order.setTitle("测试创建上线单");
order.setServerId(getServerIds(data));
order.setVersionNo("12345");
order.setEnvId(env.getEnvId());
deployHistoryService.createDeploymentOrder(order);
List<DeployHistory> deployHistories = deployHistoryService.queryDeployHistory(order.getAccountId(), 0, 0, 0, 1, 10);
assertNotNull(deployHistories);
assertTrue(deployHistories.size() >= 1);
DeployHistory history = deployHistories.get(0);
assertTrue(history.getDeployStatus() == DeployStatus.WAITING_FOR_AUDIT.getValue());
return history;
}
use of com.ibeiliao.deployment.admin.vo.deploy.DeployHistory in project Corgi by kevinYin.
the class DeployHistoryServiceImpl method getByHistoryId.
@Override
public DeployHistory getByHistoryId(int historyId) {
DeployHistoryPO po = deployHistoryDao.get(historyId);
if (po == null) {
return null;
}
List<ServerDeployHistoryPO> servers = serverDeployHistoryDao.getByHistoryId(historyId);
DeployHistory history = new DeployHistory();
VOUtil.copy(po, history);
List<ServerDeployHistory> deployHistoryList = VOUtil.fromList(servers, ServerDeployHistory.class);
fillLogIntoServerDeploy(deployHistoryList);
history.setServerDeployHistories(deployHistoryList);
fillNames(history);
return history;
}
use of com.ibeiliao.deployment.admin.vo.deploy.DeployHistory in project Corgi by kevinYin.
the class CreateDeploymentController method enoughServerRes.
/**
* 判断服务器资源是否足够
* @param order
* @return ApiCode.SUCCESS=足够
* @author linyi 2017/5/11
*/
private RestResult<Object> enoughServerRes(DeploymentOrder order) {
List<DeployHistory> histories = deployHistoryService.queryDeployHistory(order.getEnvId(), order.getModuleId(), 1, 10);
// 静态项目不做判断
ProjectModule module = projectModuleService.getByModuleId(order.getModuleId());
if (module.getModuleType() == ModuleType.STATIC.getValue()) {
return new RestResult<>(ApiCode.SUCCESS, "");
}
/* if (CollectionUtils.isEmpty(histories)) {
logger.info("第一次发布");
String jvmArgs = getJvmArgs(order.getModuleId(), order.getEnvId());
for (int serverId : order.getServerId()) {
Server server = serverService.getById(serverId);
if (server == null || StringUtils.isBlank(server.getIp())) {
return new RestResult<>(ApiCode.FAILURE, "serverId或IP不存在, serverId: " + serverId);
}
RestResult<Object> result = AliyunEcsUtil.isEnoughResByIp(server.getIp(), jvmArgs);
if (!result.isSuccess()) {
return result;
}
}
}*/
return new RestResult<>(ApiCode.SUCCESS, "");
}
use of com.ibeiliao.deployment.admin.vo.deploy.DeployHistory in project Corgi by kevinYin.
the class DeployController method index.
/**
* 发布中主页,xhtml 仅用于展示页面,ajax 调用 .do 接口获取参数
* @return
*/
@MenuResource("发布主页")
@RequestMapping("deploy.xhtml")
public String index(HttpServletRequest request) throws Exception {
Integer historyId = ServletRequestUtils.getIntParameter(request, "historyId");
if (historyId != null) {
DeployHistory history = deployHistoryService.getByHistoryId(historyId);
request.setAttribute("history", history);
request.setAttribute("canDeploy", AdminContext.getAccountId() == history.getAccountId() && history.getDeployStatus() == DeployStatus.WAITING_FOR_DEPLOYMENT.getValue());
}
return ("/deploy/deploy");
}
Aggregations