diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/ApiReportEnvConfigUtil.java b/api-test/backend/src/main/java/io/metersphere/api/dto/ApiReportEnvConfigUtil.java new file mode 100644 index 0000000000..ed5b3aa5f1 --- /dev/null +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/ApiReportEnvConfigUtil.java @@ -0,0 +1,15 @@ +package io.metersphere.api.dto; + +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +public class ApiReportEnvConfigUtil { + + private String envName; + + private String resourcePoolName; + + +} diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/ApiScenarioReportDTO.java b/api-test/backend/src/main/java/io/metersphere/api/dto/ApiScenarioReportDTO.java index 1135f9af5b..e6099b578a 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/ApiScenarioReportDTO.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/ApiScenarioReportDTO.java @@ -41,4 +41,7 @@ public class ApiScenarioReportDTO { //<项目名称,<环境名称>> private LinkedHashMap> projectEnvMap; + private String mode; + private String poolName; + } diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java b/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java index 0c79ece917..477e7572bf 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java @@ -385,6 +385,7 @@ public class ApiScenarioExecuteService { configDTO.setEnvMap(request.getEnvironmentMap()); request.setConfig(configDTO); } + request.getConfig().setEnvMap(request.getEnvironmentMap()); // 生成调试结果 ApiScenarioReportResult report = apiScenarioReportService.initDebugResult(request); ApiScenarioWithBLOBs scenario = apiScenarioMapper.selectByPrimaryKey(request.getScenarioId()); diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java index a5991e8854..c0fdc1a410 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java @@ -162,6 +162,8 @@ public class ApiDefinitionService { private ApiScenarioMapper apiScenarioMapper; @Resource private JMeterService jMeterService; + @Resource + private BaseTestResourcePoolService baseTestResourcePoolService; private final ThreadLocal currentApiOrder = new ThreadLocal<>(); private final ThreadLocal currentApiCaseOrder = new ThreadLocal<>(); @@ -1573,7 +1575,11 @@ public class ApiDefinitionService { if (StringUtils.isNotBlank(contentStr)) { JSONObject content = JSONUtil.parseObject(contentStr); if (StringUtils.isNotEmpty(result.getEnvConfig())) { - content.put("envName", this.getEnvNameByEnvConfig(result.getProjectId(), result.getEnvConfig())); + ApiReportEnvConfigUtil envNameByEnvConfig = this.getEnvNameByEnvConfig(result.getProjectId(), result.getEnvConfig()); + if (envNameByEnvConfig != null) { + content.put("envName", envNameByEnvConfig.getEnvName()); + content.put("poolName", envNameByEnvConfig.getResourcePoolName()); + } } contentStr = content.toString(); reportResult.setContent(contentStr); @@ -1584,9 +1590,8 @@ public class ApiDefinitionService { return reportResult; } - - public String getEnvNameByEnvConfig(String projectId, String envConfig) { - String envName = null; + public ApiReportEnvConfigUtil getEnvNameByEnvConfig(String projectId, String envConfig) { + ApiReportEnvConfigUtil apiReportEnvConfig = new ApiReportEnvConfigUtil(); RunModeConfigDTO runModeConfigDTO = null; try { runModeConfigDTO = JSON.parseObject(envConfig, RunModeConfigDTO.class); @@ -1595,9 +1600,17 @@ public class ApiDefinitionService { } if (StringUtils.isNotEmpty(projectId) && runModeConfigDTO != null && MapUtils.isNotEmpty(runModeConfigDTO.getEnvMap())) { String envId = runModeConfigDTO.getEnvMap().get(projectId); - envName = apiTestEnvironmentService.selectNameById(envId); + apiReportEnvConfig.setEnvName(apiTestEnvironmentService.selectNameById(envId)); } - return envName; + if (runModeConfigDTO != null && StringUtils.isNotBlank(runModeConfigDTO.getResourcePoolId())) { + TestResourcePool resourcePool = baseTestResourcePoolService.getResourcePool(runModeConfigDTO.getResourcePoolId()); + if (resourcePool != null) { + apiReportEnvConfig.setResourcePoolName(resourcePool.getName()); + } + } else { + apiReportEnvConfig.setResourcePoolName("LOCAL"); + } + return apiReportEnvConfig; } public ApiReportResult getDbResult(String testId, String type) { @@ -2785,8 +2798,10 @@ public class ApiDefinitionService { runModeConfigDTO.setEnvMap(new HashMap<>() {{ this.put(request.getProjectId(), request.getEnvironmentId()); }}); + runModeConfigDTO.setResourcePoolId(request.getConfig().getResourcePoolId()); result.setEnvConfig(JSON.toJSONString(runModeConfigDTO)); } + result.setActuator(request.getConfig().getResourcePoolId()); apiDefinitionExecResultMapper.insert(result); } if (request.isEditCaseRequest() && CollectionUtils.isNotEmpty(request.getTestElement().getHashTree()) && CollectionUtils.isNotEmpty(request.getTestElement().getHashTree().get(0).getHashTree())) { diff --git a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanApiCaseService.java b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanApiCaseService.java index 25ab21c772..18d03a1376 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanApiCaseService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanApiCaseService.java @@ -764,6 +764,16 @@ public class TestPlanApiCaseService { result.setName(reportName); result.setProjectId(apiCase.getProjectId()); result.setTriggerMode(TriggerMode.MANUAL.name()); + RunModeConfigDTO runModeConfigDTO = new RunModeConfigDTO(); + jMeterService.verifyPool(result.getProjectId(), runModeConfigDTO); + if (StringUtils.isNotEmpty(testPlanApiCase.getEnvironmentId())) { + runModeConfigDTO.setEnvMap(new HashMap<>() {{ + this.put(result.getProjectId(), testPlanApiCase.getEnvironmentId()); + }}); + runModeConfigDTO.setResourcePoolId(runModeConfigDTO.getResourcePoolId()); + result.setEnvConfig(JSON.toJSONString(runModeConfigDTO)); + } + result.setActuator(runModeConfigDTO.getResourcePoolId()); apiDefinitionExecResultMapper.insert(result); apiCase.setId(testId); diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportService.java index bbba6ac63c..4fd4deff4c 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportService.java @@ -129,6 +129,7 @@ public class ApiScenarioReportService { reportResult.setTestId(reportId); ApiScenarioReportDTO dto = apiScenarioReportStructureService.apiIntegratedReport(reportId); apiScenarioReportStructureService.initProjectEnvironmentByEnvConfig(dto, result.getEnvConfig()); + apiScenarioReportStructureService.getEnvConfig(dto, result.getEnvConfig()); reportResult.setContent(JSON.toJSONString(dto)); return reportResult; } diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportStructureService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportStructureService.java index d5fbe124a2..4f46022433 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportStructureService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportStructureService.java @@ -13,6 +13,8 @@ import io.metersphere.commons.enums.ApiReportStatus; import io.metersphere.commons.utils.*; import io.metersphere.constants.RunModeConstants; import io.metersphere.dto.RequestResult; +import io.metersphere.dto.RunModeConfigDTO; +import io.metersphere.service.BaseTestResourcePoolService; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.BooleanUtils; @@ -70,6 +72,8 @@ public class ApiScenarioReportStructureService { private ApiScenarioEnvService apiScenarioEnvService; @Resource private ApiScenarioReportMapper apiScenarioReportMapper; + @Resource + private BaseTestResourcePoolService baseTestResourcePoolService; public void save(List apiScenarios, String reportId, String reportType) { List dtoList = new LinkedList<>(); @@ -500,6 +504,10 @@ public class ApiScenarioReportStructureService { dto.setName(report.getName()); dto.setEnvConfig(report.getEnvConfig()); this.initProjectEnvironmentByEnvConfig(dto, report.getEnvConfig()); + this.getEnvConfig(dto, report.getEnvConfig()); + if (report != null && report.getReportType().equals(ReportTypeConstants.SCENARIO_INDEPENDENT.name())) { + dto.setMode(null); + } return dto; } } @@ -692,4 +700,24 @@ public class ApiScenarioReportStructureService { return (T) clazz.getInterfaces(); } } + + public void getEnvConfig(ApiScenarioReportDTO dto, String envConfig) { + RunModeConfigDTO runModeConfigDTO = null; + try { + runModeConfigDTO = JSON.parseObject(envConfig, RunModeConfigDTO.class); + } catch (Exception e) { + LogUtil.error("解析" + envConfig + "为RunModeConfigDTO时失败!", e); + } + if (runModeConfigDTO != null && StringUtils.isNotBlank(runModeConfigDTO.getResourcePoolId())) { + TestResourcePool resourcePool = baseTestResourcePoolService.getResourcePool(runModeConfigDTO.getResourcePoolId()); + if (resourcePool != null) { + dto.setPoolName(resourcePool.getName()); + } + } else { + dto.setPoolName("LOCAL"); + } + if (runModeConfigDTO != null && StringUtils.isNotBlank(runModeConfigDTO.getMode())) { + dto.setMode(runModeConfigDTO.getMode()); + } + } } diff --git a/api-test/frontend/src/business/automation/report/ApiReportDetail.vue b/api-test/frontend/src/business/automation/report/ApiReportDetail.vue index f81ec557d6..eab606c3e1 100644 --- a/api-test/frontend/src/business/automation/report/ApiReportDetail.vue +++ b/api-test/frontend/src/business/automation/report/ApiReportDetail.vue @@ -13,6 +13,8 @@ :debug="debug" :report="report" :project-env-map="projectEnvMap" + :mode="mode" + :pool-name="poolName" @reportExport="handleExport" @reportSave="handleSave" /> @@ -99,6 +101,8 @@ :project-env-map="projectEnvMap" :title="report.name" :content="content" + :mode="mode" + :pool-name="poolName" :report="report" :total-time="totalTime" /> @@ -163,6 +167,8 @@ export default { tempResult: [], projectEnvMap: {}, showCancel: false, + poolName: '', + mode: '', }; }, activated() { @@ -489,6 +495,10 @@ export default { if (report.projectEnvMap) { this.projectEnvMap = report.projectEnvMap; } + if (report.poolName) { + this.poolName = report.poolName; + } + this.mode = report.mode; this.fullTreeNodes = report.steps; this.content.console = report.console; this.content.error = report.error; diff --git a/api-test/frontend/src/business/automation/report/ApiReportExport.vue b/api-test/frontend/src/business/automation/report/ApiReportExport.vue index 2bd763ad88..f7e103ed88 100644 --- a/api-test/frontend/src/business/automation/report/ApiReportExport.vue +++ b/api-test/frontend/src/business/automation/report/ApiReportExport.vue @@ -3,6 +3,8 @@ :title="title" :report="report" :project-env-map="projectEnvMap" + :pool-name="poolName" + :mode="mode" :type="$t('report.api_test_report')">
@@ -95,6 +97,8 @@ export default { totalTime: Number, projectEnvMap: {}, title: String, + poolName: String, + mode: String, }, data() { return {}; diff --git a/api-test/frontend/src/business/automation/report/ApiReportViewHeader.vue b/api-test/frontend/src/business/automation/report/ApiReportViewHeader.vue index ff89a883dc..fa568c15a5 100644 --- a/api-test/frontend/src/business/automation/report/ApiReportViewHeader.vue +++ b/api-test/frontend/src/business/automation/report/ApiReportViewHeader.vue @@ -81,7 +81,26 @@
- + + +
+ {{ $t('report.run_model') + ':' }} +
+
+ {{ getModeName(this.mode) }} +
+
+ +
+ {{ $t('load_test.select_resource_pool') + ':' }} +
+
+ {{ this.poolName }} +
+
+ +
+ {{ $t('commons.environment') + ':' }}
{{ key + ':' }} @@ -121,6 +140,8 @@ export default { default: false, }, isPlan: Boolean, + poolName: String, + mode: String, }, computed: { showProjectEnv() { @@ -235,6 +256,14 @@ export default { } }); }, + getModeName(mode) { + switch (mode) { + case 'serial': + return this.$t('run_mode.serial'); + case 'parallel': + return this.$t('run_mode.parallel'); + } + }, }, }; diff --git a/api-test/frontend/src/business/automation/scenario/ApiScenarioList.vue b/api-test/frontend/src/business/automation/scenario/ApiScenarioList.vue index ef2e180675..ad4384702e 100644 --- a/api-test/frontend/src/business/automation/scenario/ApiScenarioList.vue +++ b/api-test/frontend/src/business/automation/scenario/ApiScenarioList.vue @@ -1,5 +1,5 @@ diff --git a/framework/sdk-parent/frontend/src/i18n/lang/en-US.js b/framework/sdk-parent/frontend/src/i18n/lang/en-US.js index a7c2f7ed21..e27f7048f9 100644 --- a/framework/sdk-parent/frontend/src/i18n/lang/en-US.js +++ b/framework/sdk-parent/frontend/src/i18n/lang/en-US.js @@ -63,6 +63,7 @@ const message = { current_project: 'Current Project', not_exist: "Not exist", name: 'Name', + template_name: 'Template Name', description: 'Description', annotation: 'Annotation', clear: 'Clear', diff --git a/framework/sdk-parent/frontend/src/i18n/lang/zh-CN.js b/framework/sdk-parent/frontend/src/i18n/lang/zh-CN.js index 23b02de8bf..239fe9244b 100644 --- a/framework/sdk-parent/frontend/src/i18n/lang/zh-CN.js +++ b/framework/sdk-parent/frontend/src/i18n/lang/zh-CN.js @@ -62,6 +62,7 @@ const message = { current_project: '当前项目', not_exist: "不存在", name: '名称', + template_name: '模板名称', description: '描述', annotation: '注释', clear: '清空', diff --git a/framework/sdk-parent/frontend/src/i18n/lang/zh-TW.js b/framework/sdk-parent/frontend/src/i18n/lang/zh-TW.js index d1e22fcdf9..dce40c4c4c 100644 --- a/framework/sdk-parent/frontend/src/i18n/lang/zh-TW.js +++ b/framework/sdk-parent/frontend/src/i18n/lang/zh-TW.js @@ -62,6 +62,7 @@ const message = { current_project: '當前項目', not_exist: "不存在", name: '名稱', + template_name: '模版名稱', description: '描述', annotation: '註釋', clear: '清空', diff --git a/pom.xml b/pom.xml index 965179b7a3..ac28dad03b 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ 2021.0.5 5.7.5 2.7.18 - 1.1.0 + 1.2.0 7.15.0 1.10.1 7.4.1.jre8 diff --git a/project-management/frontend/src/business/menu/template/FieldTemplateEdit.vue b/project-management/frontend/src/business/menu/template/FieldTemplateEdit.vue index 5a4d084765..fae66b2f13 100644 --- a/project-management/frontend/src/business/menu/template/FieldTemplateEdit.vue +++ b/project-management/frontend/src/business/menu/template/FieldTemplateEdit.vue @@ -18,7 +18,7 @@ - + diff --git a/test-track/backend/src/main/java/io/metersphere/controller/IssuesController.java b/test-track/backend/src/main/java/io/metersphere/controller/IssuesController.java index 91fe22437c..9c27f998f8 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/IssuesController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/IssuesController.java @@ -210,6 +210,11 @@ public class IssuesController { return issuesService.getPlatformTransitions(request); } + @PostMapping("/platform/status") + public List getPlatformStatus(@RequestBody PlatformIssueTypeRequest request) { + return issuesService.getPlatformStatus(request); + } + @GetMapping("/platform/option") public List getPlatformOptions() { return platformPluginService.getPlatformOptions(); diff --git a/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java b/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java index 115ea10c8e..53fa2c47e4 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java @@ -1449,16 +1449,45 @@ public class IssuesService { return extIssuesMapper.getIssues(request); } + public List getPlatformStatus(PlatformIssueTypeRequest request) { + List platformStatusDTOS = new ArrayList<>(); + Project project = baseProjectService.getProjectById(request.getProjectId()); + String projectConfig = PlatformPluginService.getCompatibleProjectConfig(project); + String platform = project.getPlatform(); + if (PlatformPluginService.isPluginPlatform(platform)) { + return platformPluginService.getPlatform(platform) + .getStatusList(projectConfig) + .stream().map(item -> { + // 全部插件化后简化 + PlatformStatusDTO platformStatusDTO = new PlatformStatusDTO(); + platformStatusDTO.setLabel(item.getLabel()); + platformStatusDTO.setValue(item.getValue()); + return platformStatusDTO; + }) + .collect(Collectors.toList()); + } else { + List platforms = getPlatforms(project); + if (CollectionUtils.isEmpty(platforms)) { + return platformStatusDTOS; + } + + IssuesRequest issuesRequest = getDefaultIssueRequest(request.getProjectId(), request.getWorkspaceId()); + return IssueFactory.createPlatform(platform, issuesRequest).getTransitions(request.getPlatformKey()); + } + } + public List getPlatformTransitions(PlatformIssueTypeRequest request) { List platformStatusDTOS = new ArrayList<>(); if (!StringUtils.isBlank(request.getPlatformKey())) { Project project = baseProjectService.getProjectById(request.getProjectId()); + String projectConfig = PlatformPluginService.getCompatibleProjectConfig(project); String platform = project.getPlatform(); if (PlatformPluginService.isPluginPlatform(platform)) { return platformPluginService.getPlatform(platform) - .getStatusList(request.getPlatformKey()) + .getTransitions(projectConfig, request.getPlatformKey()) .stream().map(item -> { + // 全部插件化后简化 PlatformStatusDTO platformStatusDTO = new PlatformStatusDTO(); platformStatusDTO.setLabel(item.getLabel()); platformStatusDTO.setValue(item.getValue()); diff --git a/test-track/frontend/src/api/issue.js b/test-track/frontend/src/api/issue.js index 251fbc2a79..bb7eaeeedf 100644 --- a/test-track/frontend/src/api/issue.js +++ b/test-track/frontend/src/api/issue.js @@ -212,6 +212,10 @@ export function getPlatformStatus(param) { return post('/issues/platform/status', param); } +export function getPlatformTransitions(param) { + return post('/issues/platform/transitions', param); +} + export function enableThirdPartTemplate(projectId) { return get(BASE_URL + 'third/part/template/enable/' + projectId); } diff --git a/test-track/frontend/src/business/issue/IssueEditDetail.vue b/test-track/frontend/src/business/issue/IssueEditDetail.vue index 9bd70780d1..3ab02127d4 100644 --- a/test-track/frontend/src/business/issue/IssueEditDetail.vue +++ b/test-track/frontend/src/business/issue/IssueEditDetail.vue @@ -200,13 +200,11 @@ import {hasLicense} from "metersphere-frontend/src/utils/permission"; import { enableThirdPartTemplate, getIssuePartTemplateWithProject, - getPlatformStatus, - getIssuesById, saveOrUpdateIssue, saveFollow, getFollow, getComments, - getTapdUser + getTapdUser, getPlatformTransitions } from "@/api/issue"; import { uploadIssueAttachment, @@ -433,7 +431,7 @@ export default { projectId: getCurrentProjectID(), workspaceId: getCurrentWorkspaceId() } - getPlatformStatus(data).then(response => { + getPlatformTransitions(data).then(response => { if (response.data.length > 0) { this.platformTransitions = response.data; } diff --git a/test-track/frontend/src/business/issue/IssueList.vue b/test-track/frontend/src/business/issue/IssueList.vue index f30620ff71..cddd7f54f0 100644 --- a/test-track/frontend/src/business/issue/IssueList.vue +++ b/test-track/frontend/src/business/issue/IssueList.vue @@ -65,15 +65,14 @@