Search in sources :

Example 16 with ProjectModule

use of com.ibeiliao.deployment.admin.vo.project.ProjectModule in project Corgi by kevinYin.

the class InitTestDataService method createModule.

private ProjectModule createModule(long accountId, Project project, List<ProjectEnv> envs) {
    ProjectModule module = new ProjectModule();
    module.setProjectId(project.getProjectId());
    module.setCompileShell("mvn -P=dev");
    module.setNeedAudit(Constants.TRUE);
    module.setModuleName("test-module");
    module.setModuleNameZh("测试模块");
    module.setModuleType(ModuleType.SERVICE.getValue());
    module.setLogName("");
    module.setPreShell("");
    module.setPostShell("");
    module.setRestartShell("/usr/local/resinpro/bin/resin.sh restart");
    module.setRepoUrl("https://a.b.com/test-project");
    module.setRepoType(ModuleRepoType.SVN.getValue());
    module.setSrcPath("");
    module.setStopShell("");
    module.setSvnAccount("test-account");
    module.setSvnPassword("test-password");
    module.setNeedAudit(Constants.TRUE);
    ProjectEnv env = envs.get(0);
    List<ServerGroup> serverGroups = new ArrayList<>();
    ServerGroup group1 = new ServerGroup();
    group1.setEnvId(env.getEnvId());
    group1.setGroupName("dev test");
    serverGroups.add(group1);
    projectModuleService.saveProjectModule(accountId, module);
    List<Server> servers = new ArrayList<>();
    final int MAX_SERVERS = 8;
    for (int i = 0; i < MAX_SERVERS; i++) {
        servers.add(createServer(i));
    }
    group1.setServers(servers);
    module.setServerGroups(serverGroups);
    projectModuleService.saveProjectModule(accountId, module);
    ProjectModule tmpModule = projectModuleService.getByModuleId(module.getModuleId());
    Assert.notNull(tmpModule);
    Assert.isTrue(tmpModule.getNeedAudit() == Constants.TRUE);
    // 要重新读一次数据
    List<ServerGroup> newServerGroups = serverGroupService.getByModuleIds(Lists.newArrayList(module.getModuleId()), false);
    module.setServerGroups(newServerGroups);
    for (ServerGroup tmpGroup : newServerGroups) {
        List<Integer> groupIds = new LinkedList<>();
        groupIds.add(tmpGroup.getGroupId());
        List<Server> newServers = serverService.getByGroupIds(groupIds);
        tmpGroup.setServers(newServers);
    }
    return module;
}
Also used : ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) ProjectEnv(com.ibeiliao.deployment.admin.vo.global.ProjectEnv) ServerGroup(com.ibeiliao.deployment.admin.vo.server.ServerGroup) Server(com.ibeiliao.deployment.admin.vo.server.Server)

Example 17 with ProjectModule

use of com.ibeiliao.deployment.admin.vo.project.ProjectModule in project Corgi by kevinYin.

the class ModuleServiceTest method testSave.

@Test
public void testSave() {
    ProjectModule module = new ProjectModule();
    buildModuleBaseInfo(module);
    fillServerGroupInfo(module);
    moduleService.saveProjectModule(1L, module);
}
Also used : ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) Test(org.junit.Test)

Aggregations

ProjectModule (com.ibeiliao.deployment.admin.vo.project.ProjectModule)17 ProjectEnv (com.ibeiliao.deployment.admin.vo.global.ProjectEnv)3 Project (com.ibeiliao.deployment.admin.vo.project.Project)3 Server (com.ibeiliao.deployment.admin.vo.server.Server)3 ServerGroup (com.ibeiliao.deployment.admin.vo.server.ServerGroup)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 ProjectModulePO (com.ibeiliao.deployment.admin.po.project.ProjectModulePO)2 MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)2 AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)2 ModuleJvm (com.ibeiliao.deployment.admin.vo.project.ModuleJvm)2 Test (org.junit.Test)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ProjectPO (com.ibeiliao.deployment.admin.po.project.ProjectPO)1 DeployHistory (com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)1 Transactional (org.springframework.transaction.annotation.Transactional)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1