Search in sources :

Example 1 with ProjectEnv

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());
}
Also used : ProjectEnv(com.ibeiliao.deployment.admin.vo.global.ProjectEnv) DeploymentOrder(com.ibeiliao.deployment.admin.vo.deploy.DeploymentOrder) DeployHistory(com.ibeiliao.deployment.admin.vo.deploy.DeployHistory) ServerDeployHistory(com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory) InitTestDataService(com.ibeiliao.deployment.admin.service.InitTestDataService) Test(org.junit.Test)

Example 2 with ProjectEnv

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;
}
Also used : ProjectEnv(com.ibeiliao.deployment.admin.vo.global.ProjectEnv) DeploymentOrder(com.ibeiliao.deployment.admin.vo.deploy.DeploymentOrder) DeployHistory(com.ibeiliao.deployment.admin.vo.deploy.DeployHistory) ServerDeployHistory(com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory) InitTestDataService(com.ibeiliao.deployment.admin.service.InitTestDataService)

Example 3 with ProjectEnv

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);
}
Also used : Project(com.ibeiliao.deployment.admin.vo.project.Project) ProjectEnv(com.ibeiliao.deployment.admin.vo.global.ProjectEnv) ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount)

Example 4 with ProjectEnv

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());
    }
}
Also used : Project(com.ibeiliao.deployment.admin.vo.project.Project) ProjectEnv(com.ibeiliao.deployment.admin.vo.global.ProjectEnv)

Example 5 with ProjectEnv

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());
}
Also used : ProjectEnv(com.ibeiliao.deployment.admin.vo.global.ProjectEnv)

Aggregations

ProjectEnv (com.ibeiliao.deployment.admin.vo.global.ProjectEnv)14 DeployHistory (com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)3 ProjectModule (com.ibeiliao.deployment.admin.vo.project.ProjectModule)3 RestResult (com.ibeiliao.deployment.admin.common.RestResult)2 InitTestDataService (com.ibeiliao.deployment.admin.service.InitTestDataService)2 MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)2 DeploymentOrder (com.ibeiliao.deployment.admin.vo.deploy.DeploymentOrder)2 ServerDeployHistory (com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory)2 Project (com.ibeiliao.deployment.admin.vo.project.Project)2 Server (com.ibeiliao.deployment.admin.vo.server.Server)2 ServerGroup (com.ibeiliao.deployment.admin.vo.server.ServerGroup)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)1 GlobalSetting (com.ibeiliao.deployment.admin.vo.global.GlobalSetting)1 ModuleJvm (com.ibeiliao.deployment.admin.vo.project.ModuleJvm)1 LowQualityRank (com.ibeiliao.deployment.admin.vo.stat.LowQualityRank)1 ResinConf (com.ibeiliao.deployment.transfer.vo.ResinConf)1 TransferRequest (com.ibeiliao.deployment.transfer.vo.TransferRequest)1 ArrayList (java.util.ArrayList)1