Search in sources :

Example 6 with DeployHistory

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());
}
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 7 with DeployHistory

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;
}
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 8 with DeployHistory

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;
}
Also used : ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) DeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO) ServerDeployHistory(com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory) ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) ServerDeployHistory(com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory) DeployHistory(com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)

Example 9 with DeployHistory

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, "");
}
Also used : ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) RestResult(com.ibeiliao.deployment.admin.common.RestResult) DeployHistory(com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)

Example 10 with DeployHistory

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");
}
Also used : DeployHistory(com.ibeiliao.deployment.admin.vo.deploy.DeployHistory) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

DeployHistory (com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)20 ServerDeployHistory (com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory)14 Test (org.junit.Test)6 InitTestDataService (com.ibeiliao.deployment.admin.service.InitTestDataService)4 DeploymentOrder (com.ibeiliao.deployment.admin.vo.deploy.DeploymentOrder)3 ProjectEnv (com.ibeiliao.deployment.admin.vo.global.ProjectEnv)3 RestResult (com.ibeiliao.deployment.admin.common.RestResult)2 DeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO)2 ServerDeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO)2 MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)2 Date (java.util.Date)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 DeployHistoryService (com.ibeiliao.deployment.admin.service.deploy.DeployHistoryService)1 AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)1 ProjectModule (com.ibeiliao.deployment.admin.vo.project.ProjectModule)1 Server (com.ibeiliao.deployment.admin.vo.server.Server)1 ServerGroup (com.ibeiliao.deployment.admin.vo.server.ServerGroup)1 ShellLogRequestMessage (com.ibeiliao.deployment.admin.websocket.request.ShellLogRequestMessage)1 ShellLogResponseMessage (com.ibeiliao.deployment.admin.websocket.request.ShellLogResponseMessage)1 Redis (com.ibeiliao.deployment.common.util.redis.Redis)1