use of com.ibeiliao.deployment.admin.vo.deploy.DeploymentOrder 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.DeploymentOrder 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.DeploymentOrder in project Corgi by kevinYin.
the class DeployHistoryServiceImpl method createRollbackOrder.
@Override
public void createRollbackOrder(int historyId, long accountId, boolean isRollBack) {
DeployHistory deployHistory = getByHistoryId(historyId);
if (deployHistory == null) {
throw new IllegalArgumentException("发布记录不存在");
}
AdminAccount account = adminAccountService.getById(accountId);
DeploymentOrder order = new DeploymentOrder();
VOUtil.copy(deployHistory, order);
order.setAccountId(accountId);
order.setRealName(account.getRealname());
List<ServerDeployHistory> serverDeployHistories = deployHistory.getServerDeployHistories();
int[] serverId = new int[serverDeployHistories.size()];
for (int i = 0; i < serverId.length; i++) {
serverId[i] = serverDeployHistories.get(i).getServerId();
}
order.setServerId(serverId);
order.setRollbackToDeployId(historyId);
if (isRollBack) {
order.setTitle("回滚到" + historyId + "的版本");
} else {
order.setTitle("重发" + historyId + "的版本");
}
createDeploymentOrder(order);
}
Aggregations