feat(测试跟踪): 测试计划保存的运行环境回显,并且作为当前计划下所有用例的环境的默认值
--user=郭雨琦 --story=1008894 https://www.tapd.cn/55049933/prong/stories/view/1155049933001008894 --story=1008895 https://www.tapd.cn/55049933/prong/stories/view/1155049933001008895
This commit is contained in:
parent
a38e2799f4
commit
bb7b3dd342
|
@ -1,7 +1,6 @@
|
||||||
package io.metersphere.track.controller;
|
package io.metersphere.track.controller;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import io.metersphere.api.dto.datacount.request.ScheduleInfoRequest;
|
import io.metersphere.api.dto.datacount.request.ScheduleInfoRequest;
|
||||||
|
@ -19,7 +18,7 @@ import io.metersphere.track.dto.*;
|
||||||
import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest;
|
import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest;
|
||||||
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
||||||
import io.metersphere.track.request.testplan.AddTestPlanRequest;
|
import io.metersphere.track.request.testplan.AddTestPlanRequest;
|
||||||
import io.metersphere.track.request.testplan.TestplanRunRequest;
|
import io.metersphere.track.request.testplan.TestPlanRunRequest;
|
||||||
import io.metersphere.track.request.testplancase.TestCaseRelevanceRequest;
|
import io.metersphere.track.request.testplancase.TestCaseRelevanceRequest;
|
||||||
import io.metersphere.track.service.TestPlanProjectService;
|
import io.metersphere.track.service.TestPlanProjectService;
|
||||||
import io.metersphere.track.service.TestPlanService;
|
import io.metersphere.track.service.TestPlanService;
|
||||||
|
@ -207,18 +206,18 @@ public class TestPlanController {
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/edit/runModeConfig")
|
@PostMapping("/edit/runModeConfig")
|
||||||
public void updateRunModeConfig(@RequestBody TestplanRunRequest testplanRunRequest) {
|
public void updateRunModeConfig(@RequestBody TestPlanRunRequest testplanRunRequest) {
|
||||||
testPlanService.updateRunModeConfig(testplanRunRequest);
|
testPlanService.updateRunModeConfig(testplanRunRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/run")
|
@PostMapping("/run")
|
||||||
public String run(@RequestBody TestplanRunRequest testplanRunRequest) {
|
public String run(@RequestBody TestPlanRunRequest testplanRunRequest) {
|
||||||
return testPlanService.runPlan(testplanRunRequest);
|
return testPlanService.runPlan(testplanRunRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/run/batch")
|
@PostMapping(value = "/run/batch")
|
||||||
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanService.class)
|
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.testPlanIds)", msClass = TestPlanService.class)
|
||||||
public void runBatch(@RequestBody TestplanRunRequest request) {
|
public void runBatch(@RequestBody TestPlanRunRequest request) {
|
||||||
request.setTriggerMode(TriggerMode.BATCH.name());
|
request.setTriggerMode(TriggerMode.BATCH.name());
|
||||||
testPlanService.runBatch(request);
|
testPlanService.runBatch(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,15 +9,15 @@ import java.util.Map;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class TestplanRunRequest {
|
public class TestPlanRunRequest {
|
||||||
private String testPlanId;
|
private String testPlanId;
|
||||||
private String projectId;
|
private String projectId;
|
||||||
private String userId;
|
private String userId;
|
||||||
private String triggerMode;//触发方式
|
private String triggerMode;//触发方式
|
||||||
private String mode;//运行模式
|
private String mode;//运行模式
|
||||||
private String reportType;//报告展示方式
|
private String reportType;//报告展示方式
|
||||||
private String onSampleError;//是否失败停止
|
private boolean onSampleError;//是否失败停止
|
||||||
private String runWithinResourcePool;//是否选择资源池
|
private boolean runWithinResourcePool;//是否选择资源池
|
||||||
private String resourcePoolId;//资源池Id
|
private String resourcePoolId;//资源池Id
|
||||||
private Map<String, String> envMap;
|
private Map<String, String> envMap;
|
||||||
private String environmentType;
|
private String environmentType;
|
|
@ -30,7 +30,8 @@ import io.metersphere.track.request.report.QueryTestPlanReportRequest;
|
||||||
import io.metersphere.track.request.report.TestPlanReportSaveRequest;
|
import io.metersphere.track.request.report.TestPlanReportSaveRequest;
|
||||||
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
||||||
import io.metersphere.track.request.testplan.LoadCaseRequest;
|
import io.metersphere.track.request.testplan.LoadCaseRequest;
|
||||||
import io.metersphere.track.request.testplan.TestplanRunRequest;
|
import io.metersphere.track.request.testplan.TestPlanRunRequest;
|
||||||
|
import io.metersphere.track.service.utils.TestPlanRequestUtil;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -584,7 +585,8 @@ public class TestPlanReportService {
|
||||||
TestPlanExecutionQueue testPlanExecutionQueue = planExecutionQueueList.get(0);
|
TestPlanExecutionQueue testPlanExecutionQueue = planExecutionQueueList.get(0);
|
||||||
TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(testPlanExecutionQueue.getTestPlanId());
|
TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(testPlanExecutionQueue.getTestPlanId());
|
||||||
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRunModeConfig());
|
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRunModeConfig());
|
||||||
TestplanRunRequest runRequest = JSON.toJavaObject(jsonObject, TestplanRunRequest.class);
|
TestPlanRequestUtil.changeStringToBoolean(jsonObject);
|
||||||
|
TestPlanRunRequest runRequest = JSON.toJavaObject(jsonObject, TestPlanRunRequest.class);
|
||||||
runRequest.setReportId(testPlanExecutionQueue.getReportId());
|
runRequest.setReportId(testPlanExecutionQueue.getReportId());
|
||||||
testPlanService.runPlan(runRequest);
|
testPlanService.runPlan(runRequest);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,9 @@ import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
||||||
import io.metersphere.track.request.testplan.AddTestPlanRequest;
|
import io.metersphere.track.request.testplan.AddTestPlanRequest;
|
||||||
import io.metersphere.track.request.testplan.LoadCaseReportRequest;
|
import io.metersphere.track.request.testplan.LoadCaseReportRequest;
|
||||||
import io.metersphere.track.request.testplan.LoadCaseRequest;
|
import io.metersphere.track.request.testplan.LoadCaseRequest;
|
||||||
import io.metersphere.track.request.testplan.TestplanRunRequest;
|
import io.metersphere.track.request.testplan.TestPlanRunRequest;
|
||||||
import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest;
|
import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest;
|
||||||
|
import io.metersphere.track.service.utils.TestPlanRequestUtil;
|
||||||
import io.metersphere.utils.LoggerUtil;
|
import io.metersphere.utils.LoggerUtil;
|
||||||
import org.apache.commons.beanutils.BeanMap;
|
import org.apache.commons.beanutils.BeanMap;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
@ -974,11 +975,27 @@ public class TestPlanService {
|
||||||
LogUtil.error(e);
|
LogUtil.error(e);
|
||||||
}
|
}
|
||||||
if (runModeConfig == null) {
|
if (runModeConfig == null) {
|
||||||
runModeConfig = new RunModeConfigDTO();
|
TestPlanWithBLOBs testPlanWithBLOBs = testPlanMapper.selectByPrimaryKey(testPlanID);
|
||||||
runModeConfig.setMode(RunModeConstants.SERIAL.name());
|
if (StringUtils.isNotEmpty(testPlanWithBLOBs.getRunModeConfig())) {
|
||||||
runModeConfig.setReportType("iddReport");
|
JSONObject json = JSONObject.parseObject(testPlanWithBLOBs.getRunModeConfig());
|
||||||
runModeConfig.setEnvMap(new HashMap<>());
|
TestPlanRequestUtil.changeStringToBoolean(json);
|
||||||
runModeConfig.setOnSampleError(false);
|
TestPlanRunRequest testPlanRunRequest = JSON.toJavaObject(json, TestPlanRunRequest.class);
|
||||||
|
if (StringUtils.equals("GROUP", testPlanRunRequest.getEnvironmentType()) && StringUtils.isBlank(testPlanRunRequest.getEnvironmentGroupId())) {
|
||||||
|
runModeConfig = buildRunModeConfigDTO();
|
||||||
|
} else {
|
||||||
|
runModeConfig = new RunModeConfigDTO();
|
||||||
|
runModeConfig.setMode(testPlanRunRequest.getMode());
|
||||||
|
runModeConfig.setReportType(testPlanRunRequest.getReportType());
|
||||||
|
if (testPlanRunRequest.getEnvMap() == null) {
|
||||||
|
runModeConfig.setEnvMap(new HashMap<>());
|
||||||
|
} else {
|
||||||
|
runModeConfig.setEnvMap(testPlanRunRequest.getEnvMap());
|
||||||
|
}
|
||||||
|
runModeConfig.setOnSampleError(testPlanRunRequest.isOnSampleError());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
runModeConfig = buildRunModeConfigDTO();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (runModeConfig.getEnvMap() == null) {
|
if (runModeConfig.getEnvMap() == null) {
|
||||||
runModeConfig.setEnvMap(new HashMap<>());
|
runModeConfig.setEnvMap(new HashMap<>());
|
||||||
|
@ -1029,6 +1046,15 @@ public class TestPlanService {
|
||||||
return planReportId;
|
return planReportId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private RunModeConfigDTO buildRunModeConfigDTO() {
|
||||||
|
RunModeConfigDTO runModeConfig = new RunModeConfigDTO();
|
||||||
|
runModeConfig.setMode(RunModeConstants.SERIAL.name());
|
||||||
|
runModeConfig.setReportType("iddReport");
|
||||||
|
runModeConfig.setEnvMap(new HashMap<>());
|
||||||
|
runModeConfig.setOnSampleError(false);
|
||||||
|
return runModeConfig;
|
||||||
|
}
|
||||||
|
|
||||||
private Map<String, String> executeApiTestCase(String triggerMode, String planReportId, String userId, List<String> planCaseIds, RunModeConfigDTO runModeConfig) {
|
private Map<String, String> executeApiTestCase(String triggerMode, String planReportId, String userId, List<String> planCaseIds, RunModeConfigDTO runModeConfig) {
|
||||||
BatchRunDefinitionRequest request = new BatchRunDefinitionRequest();
|
BatchRunDefinitionRequest request = new BatchRunDefinitionRequest();
|
||||||
request.setTriggerMode(triggerMode);
|
request.setTriggerMode(triggerMode);
|
||||||
|
@ -1118,6 +1144,24 @@ public class TestPlanService {
|
||||||
return returnMap;
|
return returnMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLogDetails(List<String> ids) {
|
||||||
|
if (CollectionUtils.isNotEmpty(ids)) {
|
||||||
|
TestPlanExample testPlanExample = new TestPlanExample();
|
||||||
|
testPlanExample.createCriteria().andIdIn(ids);
|
||||||
|
List<TestPlan> planList = testPlanMapper.selectByExample(testPlanExample);
|
||||||
|
if (CollectionUtils.isNotEmpty(planList)) {
|
||||||
|
List<OperatingLogDetails> detailsList = new ArrayList<>();
|
||||||
|
for (TestPlan plan : planList) {
|
||||||
|
List<DetailColumn> columns = ReflexObjectUtil.getColumns(planList.get(0), TestPlanReference.testPlanColumns);
|
||||||
|
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(plan.getId()), plan.getProjectId(), plan.getName(), plan.getCreator(), columns);
|
||||||
|
detailsList.add(details);
|
||||||
|
}
|
||||||
|
return JSON.toJSONString(detailsList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public String getLogDetails(String id) {
|
public String getLogDetails(String id) {
|
||||||
TestPlan plan = testPlanMapper.selectByPrimaryKey(id);
|
TestPlan plan = testPlanMapper.selectByPrimaryKey(id);
|
||||||
if (plan != null) {
|
if (plan != null) {
|
||||||
|
@ -2074,7 +2118,7 @@ public class TestPlanService {
|
||||||
return envMap;
|
return envMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String runPlan(TestplanRunRequest testplanRunRequest) {
|
public String runPlan(TestPlanRunRequest testplanRunRequest) {
|
||||||
//检查测试计划下有没有可以执行的用例;
|
//检查测试计划下有没有可以执行的用例;
|
||||||
if (!haveExecCase(testplanRunRequest.getTestPlanId()) && !haveUiCase(testplanRunRequest.getTestPlanId())) {
|
if (!haveExecCase(testplanRunRequest.getTestPlanId()) && !haveUiCase(testplanRunRequest.getTestPlanId())) {
|
||||||
MSException.throwException(Translator.get("plan_warning"));
|
MSException.throwException(Translator.get("plan_warning"));
|
||||||
|
@ -2091,7 +2135,7 @@ public class TestPlanService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private RunModeConfigDTO getRunModeConfigDTO(TestplanRunRequest testplanRunRequest, String envType, Map<String, String> envMap, String environmentGroupId, String testPlanId) {
|
private RunModeConfigDTO getRunModeConfigDTO(TestPlanRunRequest testplanRunRequest, String envType, Map<String, String> envMap, String environmentGroupId, String testPlanId) {
|
||||||
RunModeConfigDTO runModeConfig = new RunModeConfigDTO();
|
RunModeConfigDTO runModeConfig = new RunModeConfigDTO();
|
||||||
runModeConfig.setEnvironmentType(testplanRunRequest.getEnvironmentType());
|
runModeConfig.setEnvironmentType(testplanRunRequest.getEnvironmentType());
|
||||||
if (StringUtils.equals(envType, EnvironmentType.JSON.name()) && !envMap.isEmpty()) {
|
if (StringUtils.equals(envType, EnvironmentType.JSON.name()) && !envMap.isEmpty()) {
|
||||||
|
@ -2103,7 +2147,7 @@ public class TestPlanService {
|
||||||
}
|
}
|
||||||
runModeConfig.setMode(testplanRunRequest.getMode());
|
runModeConfig.setMode(testplanRunRequest.getMode());
|
||||||
runModeConfig.setResourcePoolId(testplanRunRequest.getResourcePoolId());
|
runModeConfig.setResourcePoolId(testplanRunRequest.getResourcePoolId());
|
||||||
runModeConfig.setOnSampleError(Boolean.parseBoolean(testplanRunRequest.getOnSampleError()));
|
runModeConfig.setOnSampleError(testplanRunRequest.isOnSampleError());
|
||||||
if (StringUtils.isBlank(testplanRunRequest.getReportType())) {
|
if (StringUtils.isBlank(testplanRunRequest.getReportType())) {
|
||||||
runModeConfig.setReportType("iddReport");
|
runModeConfig.setReportType("iddReport");
|
||||||
} else {
|
} else {
|
||||||
|
@ -2116,7 +2160,7 @@ public class TestPlanService {
|
||||||
return runModeConfig;
|
return runModeConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePlan(TestplanRunRequest testplanRunRequest, String testPlanId) {
|
private void updatePlan(TestPlanRunRequest testplanRunRequest, String testPlanId) {
|
||||||
String request = JSON.toJSONString(testplanRunRequest);
|
String request = JSON.toJSONString(testplanRunRequest);
|
||||||
TestPlanWithBLOBs testPlanWithBLOBs = testPlanMapper.selectByPrimaryKey(testPlanId);
|
TestPlanWithBLOBs testPlanWithBLOBs = testPlanMapper.selectByPrimaryKey(testPlanId);
|
||||||
if (testPlanWithBLOBs.getRunModeConfig() == null || !(StringUtils.equals(request, testPlanWithBLOBs.getRunModeConfig()))) {
|
if (testPlanWithBLOBs.getRunModeConfig() == null || !(StringUtils.equals(request, testPlanWithBLOBs.getRunModeConfig()))) {
|
||||||
|
@ -2293,7 +2337,7 @@ public class TestPlanService {
|
||||||
return extTestPlanMapper.list(request);
|
return extTestPlanMapper.list(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runBatch(TestplanRunRequest request) {
|
public void runBatch(TestPlanRunRequest request) {
|
||||||
List<String> ids = request.getTestPlanIds();
|
List<String> ids = request.getTestPlanIds();
|
||||||
if (CollectionUtils.isEmpty(ids) && !request.getIsAll()) {
|
if (CollectionUtils.isEmpty(ids) && !request.getIsAll()) {
|
||||||
return;
|
return;
|
||||||
|
@ -2360,7 +2404,7 @@ public class TestPlanService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<TestPlanExecutionQueue> getTestPlanExecutionQueues(TestplanRunRequest request, Map<String, String> executeQueue) {
|
private List<TestPlanExecutionQueue> getTestPlanExecutionQueues(TestPlanRunRequest request, Map<String, String> executeQueue) {
|
||||||
List<TestPlanExecutionQueue> planExecutionQueues = new ArrayList<>();
|
List<TestPlanExecutionQueue> planExecutionQueues = new ArrayList<>();
|
||||||
String resourceId = UUID.randomUUID().toString();
|
String resourceId = UUID.randomUUID().toString();
|
||||||
final int[] nextNum = {testPlanExecutionQueueService.getNextNum(resourceId)};
|
final int[] nextNum = {testPlanExecutionQueueService.getNextNum(resourceId)};
|
||||||
|
@ -2379,7 +2423,7 @@ public class TestPlanService {
|
||||||
return planExecutionQueues;
|
return planExecutionQueues;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runByMode(TestplanRunRequest request, Map<String, TestPlanWithBLOBs> testPlanMap, List<TestPlanExecutionQueue> planExecutionQueues) {
|
private void runByMode(TestPlanRunRequest request, Map<String, TestPlanWithBLOBs> testPlanMap, List<TestPlanExecutionQueue> planExecutionQueues) {
|
||||||
if (CollectionUtils.isNotEmpty(planExecutionQueues)) {
|
if (CollectionUtils.isNotEmpty(planExecutionQueues)) {
|
||||||
Thread thread = new Thread(new Runnable() {
|
Thread thread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -2389,14 +2433,16 @@ public class TestPlanService {
|
||||||
TestPlanExecutionQueue planExecutionQueue = planExecutionQueues.get(0);
|
TestPlanExecutionQueue planExecutionQueue = planExecutionQueues.get(0);
|
||||||
TestPlanWithBLOBs testPlan = testPlanMap.get(planExecutionQueue.getTestPlanId());
|
TestPlanWithBLOBs testPlan = testPlanMap.get(planExecutionQueue.getTestPlanId());
|
||||||
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRunModeConfig());
|
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRunModeConfig());
|
||||||
TestplanRunRequest runRequest = JSON.toJavaObject(jsonObject, TestplanRunRequest.class);
|
TestPlanRequestUtil.changeStringToBoolean(jsonObject);
|
||||||
|
TestPlanRunRequest runRequest = JSON.toJavaObject(jsonObject, TestPlanRunRequest.class);
|
||||||
runRequest.setReportId(planExecutionQueue.getReportId());
|
runRequest.setReportId(planExecutionQueue.getReportId());
|
||||||
runPlan(runRequest);
|
runPlan(runRequest);
|
||||||
} else {
|
} else {
|
||||||
for (TestPlanExecutionQueue planExecutionQueue : planExecutionQueues) {
|
for (TestPlanExecutionQueue planExecutionQueue : planExecutionQueues) {
|
||||||
TestPlanWithBLOBs testPlan = testPlanMap.get(planExecutionQueue.getTestPlanId());
|
TestPlanWithBLOBs testPlan = testPlanMap.get(planExecutionQueue.getTestPlanId());
|
||||||
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRunModeConfig());
|
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRunModeConfig());
|
||||||
TestplanRunRequest runRequest = JSON.toJavaObject(jsonObject, TestplanRunRequest.class);
|
TestPlanRequestUtil.changeStringToBoolean(jsonObject);
|
||||||
|
TestPlanRunRequest runRequest = JSON.toJavaObject(jsonObject, TestPlanRunRequest.class);
|
||||||
runRequest.setReportId(planExecutionQueue.getReportId());
|
runRequest.setReportId(planExecutionQueue.getReportId());
|
||||||
runPlan(runRequest);
|
runPlan(runRequest);
|
||||||
}
|
}
|
||||||
|
@ -2407,7 +2453,7 @@ public class TestPlanService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateRunModeConfig(TestplanRunRequest testplanRunRequest) {
|
public void updateRunModeConfig(TestPlanRunRequest testplanRunRequest) {
|
||||||
String testPlanId = testplanRunRequest.getTestPlanId();
|
String testPlanId = testplanRunRequest.getTestPlanId();
|
||||||
updatePlan(testplanRunRequest, testPlanId);
|
updatePlan(testplanRunRequest, testPlanId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package io.metersphere.track.service.utils;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
|
public class TestPlanRequestUtil {
|
||||||
|
|
||||||
|
private static final String ON_SAMPLE_ERROR = "onSampleError";
|
||||||
|
private static final String RUN_WITHIN_RESOURCE_POOL = "runWithinResourcePool";
|
||||||
|
|
||||||
|
public static void changeStringToBoolean(JSONObject runModeConfig) {
|
||||||
|
if (runModeConfig != null) {
|
||||||
|
if (runModeConfig.get(ON_SAMPLE_ERROR).equals("true") || runModeConfig.get(ON_SAMPLE_ERROR).equals(true)) {
|
||||||
|
runModeConfig.put(ON_SAMPLE_ERROR, true);
|
||||||
|
} else {
|
||||||
|
runModeConfig.put(ON_SAMPLE_ERROR, false);
|
||||||
|
}
|
||||||
|
if (runModeConfig.get(RUN_WITHIN_RESOURCE_POOL).equals("true") || runModeConfig.get(RUN_WITHIN_RESOURCE_POOL).equals(true)) {
|
||||||
|
runModeConfig.put(RUN_WITHIN_RESOURCE_POOL, true);
|
||||||
|
} else {
|
||||||
|
runModeConfig.put(RUN_WITHIN_RESOURCE_POOL, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -125,7 +125,7 @@
|
||||||
<span v-if="runConfig.retryEnable">
|
<span v-if="runConfig.retryEnable">
|
||||||
<el-tooltip placement="top" style="margin: 0 4px 0 2px">
|
<el-tooltip placement="top" style="margin: 0 4px 0 2px">
|
||||||
<div slot="content">{{ $t("run_mode.retry_message") }}</div>
|
<div slot="content">{{ $t("run_mode.retry_message") }}</div>
|
||||||
<i class="el-icon-question" style="cursor: pointer" />
|
<i class="el-icon-question" style="cursor: pointer"/>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<span style="margin-left: 10px">
|
<span style="margin-left: 10px">
|
||||||
{{ $t("run_mode.retry") }}
|
{{ $t("run_mode.retry") }}
|
||||||
|
@ -145,8 +145,9 @@
|
||||||
|
|
||||||
<div class="mode-row" v-if="runConfig.mode === 'serial'">
|
<div class="mode-row" v-if="runConfig.mode === 'serial'">
|
||||||
<el-checkbox v-model="runConfig.onSampleError">{{
|
<el-checkbox v-model="runConfig.onSampleError">{{
|
||||||
$t("api_test.fail_to_stop")
|
$t("api_test.fail_to_stop")
|
||||||
}}</el-checkbox>
|
}}
|
||||||
|
</el-checkbox>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mode-row" v-if="haveUICase">
|
<div class="mode-row" v-if="haveUICase">
|
||||||
|
@ -163,20 +164,23 @@
|
||||||
<el-button @click="close">{{ $t("commons.cancel") }}</el-button>
|
<el-button @click="close">{{ $t("commons.cancel") }}</el-button>
|
||||||
<el-dropdown @command="handleCommand" style="margin-left: 5px">
|
<el-dropdown @command="handleCommand" style="margin-left: 5px">
|
||||||
<el-button type="primary">
|
<el-button type="primary">
|
||||||
{{ $t("load_test.save_and_run")
|
{{
|
||||||
|
$t("load_test.save_and_run")
|
||||||
}}<i class="el-icon-arrow-down el-icon--right"></i>
|
}}<i class="el-icon-arrow-down el-icon--right"></i>
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-menu slot="dropdown">
|
||||||
<el-dropdown-item command="run">{{
|
<el-dropdown-item command="run">{{
|
||||||
$t("load_test.save_and_run")
|
$t("load_test.save_and_run")
|
||||||
}}</el-dropdown-item>
|
}}
|
||||||
|
</el-dropdown-item>
|
||||||
<el-dropdown-item command="save">{{
|
<el-dropdown-item command="save">{{
|
||||||
$t("commons.save")
|
$t("commons.save")
|
||||||
}}</el-dropdown-item>
|
}}
|
||||||
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
</div>
|
</div>
|
||||||
<ms-dialog-footer v-else @cancel="close" @confirm="handleRunBatch" />
|
<ms-dialog-footer v-else @cancel="close" @confirm="handleRunBatch"/>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
@ -184,13 +188,12 @@
|
||||||
<script>
|
<script>
|
||||||
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
|
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
|
||||||
import EnvPopover from "@/business/components/api/automation/scenario/EnvPopover";
|
import EnvPopover from "@/business/components/api/automation/scenario/EnvPopover";
|
||||||
import { strMapToObj } from "@/common/js/utils";
|
import {hasLicense, strMapToObj} from "@/common/js/utils";
|
||||||
import { ENV_TYPE } from "@/common/js/constants";
|
import {ENV_TYPE} from "@/common/js/constants";
|
||||||
import { hasLicense } from "@/common/js/utils";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsPlanRunModeWithEnv",
|
name: "MsPlanRunModeWithEnv",
|
||||||
components: { EnvPopover, MsDialogFooter },
|
components: {EnvPopover, MsDialogFooter},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
btnStyle: {
|
btnStyle: {
|
||||||
|
@ -256,7 +259,12 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
open(testType) {
|
open(testType, runModeConfig) {
|
||||||
|
if (runModeConfig) {
|
||||||
|
this.runConfig = JSON.parse(runModeConfig);
|
||||||
|
this.runConfig.onSampleError = this.runConfig.onSampleError === 'true' || this.runConfig.onSampleError === true;
|
||||||
|
this.runConfig.runWithinResourcePool = this.runConfig.runWithinResourcePool === 'true' || this.runConfig.runWithinResourcePool === true;
|
||||||
|
}
|
||||||
this.runModeVisible = true;
|
this.runModeVisible = true;
|
||||||
this.testType = testType;
|
this.testType = testType;
|
||||||
this.getResourcePools();
|
this.getResourcePools();
|
||||||
|
@ -317,7 +325,7 @@ export default {
|
||||||
param = this.planCaseIds;
|
param = this.planCaseIds;
|
||||||
} else if (this.type === "plan") {
|
} else if (this.type === "plan") {
|
||||||
url = "/test/plan/case/env";
|
url = "/test/plan/case/env";
|
||||||
param = { id: this.planId };
|
param = {id: this.planId};
|
||||||
}
|
}
|
||||||
this.$post(url, param, (res) => {
|
this.$post(url, param, (res) => {
|
||||||
let data = res.data;
|
let data = res.data;
|
||||||
|
@ -359,6 +367,7 @@ export default {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.env-container .content {
|
.env-container .content {
|
||||||
width: 163px;
|
width: 163px;
|
||||||
}
|
}
|
||||||
|
@ -369,7 +378,7 @@ export default {
|
||||||
padding: 5px 10px 5px 10px;
|
padding: 5px 10px 5px 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/deep/.content .el-popover__reference {
|
/deep/ .content .el-popover__reference {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,6 +391,7 @@ export default {
|
||||||
margin-top: 25px;
|
margin-top: 25px;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
}
|
}
|
||||||
|
|
||||||
.other-content {
|
.other-content {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,11 +267,14 @@
|
||||||
</ms-table-column>
|
</ms-table-column>
|
||||||
</span>
|
</span>
|
||||||
<template v-slot:opt-before="scope">
|
<template v-slot:opt-before="scope">
|
||||||
<ms-table-operator-button :tip="$t('api_test.run')" icon="el-icon-video-play" :class="[scope.row.status==='Archived'?'disable-run':'run-button']" :disabled="scope.row.status === 'Archived'"
|
<ms-table-operator-button :tip="$t('api_test.run')" icon="el-icon-video-play"
|
||||||
|
:class="[scope.row.status==='Archived'?'disable-run':'run-button']"
|
||||||
|
:disabled="scope.row.status === 'Archived'"
|
||||||
@exec="handleRun(scope.row)" v-permission="['PROJECT_TRACK_PLAN:READ+RUN']"
|
@exec="handleRun(scope.row)" v-permission="['PROJECT_TRACK_PLAN:READ+RUN']"
|
||||||
/>
|
/>
|
||||||
<ms-table-operator-button :tip="$t('commons.edit')" icon="el-icon-edit"
|
<ms-table-operator-button :tip="$t('commons.edit')" icon="el-icon-edit"
|
||||||
@exec="handleEdit(scope.row)" v-permission="['PROJECT_TRACK_PLAN:READ+EDIT']" :disabled="scope.row.status === 'Archived'"
|
@exec="handleEdit(scope.row)" v-permission="['PROJECT_TRACK_PLAN:READ+EDIT']"
|
||||||
|
:disabled="scope.row.status === 'Archived'"
|
||||||
style="margin-right: 10px"/>
|
style="margin-right: 10px"/>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:opt-behind="scope">
|
<template v-slot:opt-behind="scope">
|
||||||
|
@ -291,10 +294,11 @@
|
||||||
<el-icon class="el-icon-more"></el-icon>
|
<el-icon class="el-icon-more"></el-icon>
|
||||||
</el-link>
|
</el-link>
|
||||||
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-menu slot="dropdown">
|
||||||
<el-dropdown-item command="delete" v-permission="['PROJECT_TRACK_PLAN:READ+DELETE']" >
|
<el-dropdown-item command="delete" v-permission="['PROJECT_TRACK_PLAN:READ+DELETE']">
|
||||||
{{ $t('commons.delete') }}
|
{{ $t('commons.delete') }}
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
<el-dropdown-item command="schedule_task" v-permission="['PROJECT_TRACK_PLAN:READ+SCHEDULE']" :disabled="scope.row.status === 'Archived'" >
|
<el-dropdown-item command="schedule_task" v-permission="['PROJECT_TRACK_PLAN:READ+SCHEDULE']"
|
||||||
|
:disabled="scope.row.status === 'Archived'">
|
||||||
{{ $t('commons.trigger_mode.schedule') }}
|
{{ $t('commons.trigger_mode.schedule') }}
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
|
@ -326,7 +330,8 @@
|
||||||
<el-radio label="serial">{{ $t("run_mode.serial") }}</el-radio>
|
<el-radio label="serial">{{ $t("run_mode.serial") }}</el-radio>
|
||||||
<el-radio label="parallel">{{ $t("run_mode.parallel") }}</el-radio>
|
<el-radio label="parallel">{{ $t("run_mode.parallel") }}</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</div><br/>
|
</div>
|
||||||
|
<br/>
|
||||||
<span>注:运行模式仅对测试计划间有效</span>
|
<span>注:运行模式仅对测试计划间有效</span>
|
||||||
<template v-slot:footer>
|
<template v-slot:footer>
|
||||||
<ms-dialog-footer @cancel="closeExecute" @confirm="handleRunBatch"/>
|
<ms-dialog-footer @cancel="closeExecute" @confirm="handleRunBatch"/>
|
||||||
|
@ -348,7 +353,9 @@ import {TEST_PLAN_CONFIGS} from "../../../common/components/search/search-compon
|
||||||
import {
|
import {
|
||||||
_filter,
|
_filter,
|
||||||
_sort,
|
_sort,
|
||||||
deepClone, getCustomTableHeader, getCustomTableWidth,
|
deepClone,
|
||||||
|
getCustomTableHeader,
|
||||||
|
getCustomTableWidth,
|
||||||
getLastTableSortField,
|
getLastTableSortField,
|
||||||
saveLastTableSortField
|
saveLastTableSortField
|
||||||
} from "@/common/js/tableUtils";
|
} from "@/common/js/tableUtils";
|
||||||
|
@ -361,7 +368,8 @@ import {
|
||||||
getCurrentProjectID,
|
getCurrentProjectID,
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
getCurrentUserId,
|
getCurrentUserId,
|
||||||
hasPermission, operationConfirm
|
hasPermission,
|
||||||
|
operationConfirm
|
||||||
} from "@/common/js/utils";
|
} from "@/common/js/utils";
|
||||||
import PlanRunModeWithEnv from "@/business/components/track/plan/common/PlanRunModeWithEnv";
|
import PlanRunModeWithEnv from "@/business/components/track/plan/common/PlanRunModeWithEnv";
|
||||||
import TestPlanReportReview from "@/business/components/track/report/components/TestPlanReportReview";
|
import TestPlanReportReview from "@/business/components/track/report/components/TestPlanReportReview";
|
||||||
|
@ -401,7 +409,7 @@ export default {
|
||||||
result: {},
|
result: {},
|
||||||
cardResult: {},
|
cardResult: {},
|
||||||
enableDeleteTip: false,
|
enableDeleteTip: false,
|
||||||
showExecute:false,
|
showExecute: false,
|
||||||
queryPath: "/test/plan/list",
|
queryPath: "/test/plan/list",
|
||||||
deletePath: "/test/plan/delete",
|
deletePath: "/test/plan/delete",
|
||||||
condition: {
|
condition: {
|
||||||
|
@ -464,7 +472,7 @@ export default {
|
||||||
permission: ['PROJECT_TRACK_PLAN:READ+EDIT']
|
permission: ['PROJECT_TRACK_PLAN:READ+EDIT']
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
batchExecuteType:"serial",
|
batchExecuteType: "serial",
|
||||||
haveUICase: false
|
haveUICase: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -534,7 +542,7 @@ export default {
|
||||||
data.listObject.forEach(item => {
|
data.listObject.forEach(item => {
|
||||||
if (item.tags) {
|
if (item.tags) {
|
||||||
item.tags = JSON.parse(item.tags);
|
item.tags = JSON.parse(item.tags);
|
||||||
if(item.tags.length===0){
|
if (item.tags.length === 0) {
|
||||||
item.tags = null;
|
item.tags = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -580,7 +588,7 @@ export default {
|
||||||
this.$set(item, "showFollow", showFollow);
|
this.$set(item, "showFollow", showFollow);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
this.tableData =data.listObject;
|
this.tableData = data.listObject;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
copyData(status) {
|
copyData(status) {
|
||||||
|
@ -622,10 +630,10 @@ export default {
|
||||||
this.$refs.scheduleBatchSwitch.open(param, size, this.condition.selectAll, this.condition);
|
this.$refs.scheduleBatchSwitch.open(param, size, this.condition.selectAll, this.condition);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleBatchExecute(){
|
handleBatchExecute() {
|
||||||
this.showExecute = true;
|
this.showExecute = true;
|
||||||
},
|
},
|
||||||
handleRunBatch(){
|
handleRunBatch() {
|
||||||
this.showExecute = false;
|
this.showExecute = false;
|
||||||
let mode = this.batchExecuteType;
|
let mode = this.batchExecuteType;
|
||||||
let param = {mode};
|
let param = {mode};
|
||||||
|
@ -633,8 +641,7 @@ export default {
|
||||||
if (this.condition.selectAll) {
|
if (this.condition.selectAll) {
|
||||||
param.isAll = true;
|
param.isAll = true;
|
||||||
param.queryTestPlanRequest = this.condition
|
param.queryTestPlanRequest = this.condition
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.$refs.testPlanLitTable.selectRows.forEach((item) => {
|
this.$refs.testPlanLitTable.selectRows.forEach((item) => {
|
||||||
ids.push(item.id)
|
ids.push(item.id)
|
||||||
});
|
});
|
||||||
|
@ -651,7 +658,7 @@ export default {
|
||||||
// this.$error(error.message);
|
// this.$error(error.message);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
closeExecute(){
|
closeExecute() {
|
||||||
this.showExecute = false;
|
this.showExecute = false;
|
||||||
},
|
},
|
||||||
statusChange(data) {
|
statusChange(data) {
|
||||||
|
@ -771,7 +778,7 @@ export default {
|
||||||
let r = await this.haveUIScenario();
|
let r = await this.haveUIScenario();
|
||||||
this.haveUICase = r.data.data;
|
this.haveUICase = r.data.data;
|
||||||
if (haveExecCase || this.haveUICase) {
|
if (haveExecCase || this.haveUICase) {
|
||||||
this.$refs.runMode.open('API');
|
this.$refs.runMode.open('API', row.runModeConfig);
|
||||||
} else {
|
} else {
|
||||||
this.$router.push('/track/plan/view/' + row.id);
|
this.$router.push('/track/plan/view/' + row.id);
|
||||||
}
|
}
|
||||||
|
@ -788,7 +795,10 @@ export default {
|
||||||
environmentType,
|
environmentType,
|
||||||
environmentGroupId,
|
environmentGroupId,
|
||||||
browser,
|
browser,
|
||||||
headlessEnabled
|
headlessEnabled,
|
||||||
|
retryEnable,
|
||||||
|
retryNum,
|
||||||
|
triggerMode
|
||||||
} = config;
|
} = config;
|
||||||
let param = {mode, reportType, onSampleError, runWithinResourcePool, resourcePoolId, envMap};
|
let param = {mode, reportType, onSampleError, runWithinResourcePool, resourcePoolId, envMap};
|
||||||
param.testPlanId = this.currentPlanId;
|
param.testPlanId = this.currentPlanId;
|
||||||
|
@ -802,17 +812,17 @@ export default {
|
||||||
param.retryNum = config.retryNum;
|
param.retryNum = config.retryNum;
|
||||||
param.browser = config.browser;
|
param.browser = config.browser;
|
||||||
param.headlessEnabled = config.headlessEnabled;
|
param.headlessEnabled = config.headlessEnabled;
|
||||||
if(config.isRun === true){
|
if (config.isRun === true) {
|
||||||
this.$refs.taskCenter.open();
|
this.$refs.taskCenter.open();
|
||||||
this.result = this.$post('test/plan/run/', param, () => {
|
this.result = this.$post('test/plan/run/', param, () => {
|
||||||
this.$success(this.$t('commons.run_success'));
|
this.$success(this.$t('commons.run_success'));
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
this.result = this.$post('test/plan/edit/runModeConfig', param, () => {
|
this.result = this.$post('test/plan/edit/runModeConfig', param, () => {
|
||||||
this.$success(this.$t('commons.save_success'));
|
this.$success(this.$t('commons.save_success'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
this.initTableData();
|
||||||
},
|
},
|
||||||
saveFollow(row) {
|
saveFollow(row) {
|
||||||
if (row.showFollow) {
|
if (row.showFollow) {
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<el-row >
|
<el-row>
|
||||||
<el-col :span="12" v-if="caseCharData && caseCharData.length > 0">
|
<el-col :span="12" v-if="caseCharData && caseCharData.length > 0">
|
||||||
<ms-doughnut-pie-chart style="margin-right: 200px" :name="$t('api_test.home_page.detail_card.single_case')" :data="caseCharData" ref="functionChar"/>
|
<ms-doughnut-pie-chart style="margin-right: 200px" :name="$t('api_test.home_page.detail_card.single_case')"
|
||||||
|
:data="caseCharData" ref="functionChar"/>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12" v-if="scenarioCharData && scenarioCharData.length > 0">
|
<el-col :span="12" v-if="scenarioCharData && scenarioCharData.length > 0">
|
||||||
<api-scenario-char-result :name="$t('test_track.plan.test_plan_api_scenario_count')" :data="scenarioCharData"/>
|
<api-scenario-char-result :name="$t('test_track.plan.test_plan_api_scenario_count')" :data="scenarioCharData"/>
|
||||||
<api-scenario-char-result style="margin-top: -50px;" :name="$t('test_track.plan.test_plan_component_case_count')" :data="stepCharData"/>
|
<api-scenario-char-result style="margin-top: -50px;"
|
||||||
|
:name="$t('test_track.plan.test_plan_component_case_count')" :data="stepCharData"/>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
|
@ -18,6 +20,7 @@ import MsPieChart from "@/business/components/common/components/MsPieChart";
|
||||||
import MsDoughnutPieChart from "@/business/components/common/components/MsDoughnutPieChart";
|
import MsDoughnutPieChart from "@/business/components/common/components/MsDoughnutPieChart";
|
||||||
import ApiScenarioCharResult
|
import ApiScenarioCharResult
|
||||||
from "@/business/components/track/plan/view/comonents/report/detail/component/ApiScenarioCharResult";
|
from "@/business/components/track/plan/view/comonents/report/detail/component/ApiScenarioCharResult";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ApiResult",
|
name: "ApiResult",
|
||||||
components: {ApiScenarioCharResult, MsDoughnutPieChart, MsPieChart},
|
components: {ApiScenarioCharResult, MsDoughnutPieChart, MsPieChart},
|
||||||
|
@ -82,11 +85,13 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
let stepCharData = [];
|
let stepCharData = [];
|
||||||
for (let i = 0; i < this.apiResult.apiScenarioStepData.length; i++) {
|
if (this.apiResult.apiScenarioStepData && this.apiResult.apiScenarioStepData.length > 0) {
|
||||||
let stepItem = this.apiResult.apiScenarioStepData[i];
|
for (let i = 0; i < this.apiResult.apiScenarioStepData.length; i++) {
|
||||||
let data = this.getDataByStatus(stepItem.status);
|
let stepItem = this.apiResult.apiScenarioStepData[i];
|
||||||
data.value = stepItem.count;
|
let data = this.getDataByStatus(stepItem.status);
|
||||||
stepCharData.push(data);
|
data.value = stepItem.count;
|
||||||
|
stepCharData.push(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.scenarioCharData = apiScenarioData;
|
this.scenarioCharData = apiScenarioData;
|
||||||
|
|
Loading…
Reference in New Issue