use of com.ibeiliao.deployment.admin.vo.global.ProjectEnv 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.global.ProjectEnv 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.global.ProjectEnv in project Corgi by kevinYin.
the class InitTestDataService method init.
/**
* 创建初始化数据
*/
public InitData init() {
// 1. 创建 account
// 2. 创建 project
// 3. 创建 module
// 4. 初始化 env
// 5. 创建 server group & server
List<ProjectEnv> envs = createProjectEnv();
AdminAccount account = createAdminAccount();
Project project = createProject(account);
ProjectModule module = createModule(account.getUid(), project, envs);
return new InitData(account, project, module, envs);
}
use of com.ibeiliao.deployment.admin.vo.global.ProjectEnv in project Corgi by kevinYin.
the class DeployHistoryServiceImpl method fillNames.
private void fillNames(DeployHistory history) {
ProjectEnv env = projectEnvService.getById(history.getEnvId());
if (env != null) {
history.setEnvName(env.getEnvName());
}
Project project = projectService.getProject(history.getProjectId());
if (project != null) {
history.setProjectName(project.getProjectName());
}
}
use of com.ibeiliao.deployment.admin.vo.global.ProjectEnv in project Corgi by kevinYin.
the class DeployHistoryServiceImpl method validateParameterAndModule.
/**
* 校验参数,成功返回当前发布的环境id
*
* @param order
* @return envId
*/
private void validateParameterAndModule(DeploymentOrder order) {
// 校验参数
String message = ValidatorUtil.validate(order);
if (StringUtils.isNotEmpty(message)) {
throw new IllegalArgumentException(message);
}
Assert.hasText(order.getRealName(), "发布者姓名不能为空");
ProjectEnv env = projectEnvService.getById(order.getEnvId());
Assert.notNull(env, "环境不存在, envId: " + order.getEnvId());
if (env.getOnlineFlag() == Constants.TRUE && !order.getTagName().contains(RepositoryConstants.TAGS)) {
throw new IllegalArgumentException("生产环境 " + env.getEnvName() + " 只能发布 tag,请选择一个 tag 创建上线单");
}
// 检查项目是否存在 & online
checkProjectStatus(order.getProjectId());
// 检查模块是否存在
checkModuleStatus(order.getModuleId());
}
Aggregations