fix(接口自动化): 批量执行,不同模式切换问题
This commit is contained in:
parent
b610e11b4e
commit
91c7f25067
|
@ -118,6 +118,12 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
MsHTTPSamplerProxy proxy = mapper.readValue(bloBs.getRequest(), new TypeReference<MsHTTPSamplerProxy>() {
|
||||
});
|
||||
this.setHashTree(proxy.getHashTree());
|
||||
this.setName(bloBs.getName());
|
||||
this.setMethod(proxy.getMethod());
|
||||
this.setBody(proxy.getBody());
|
||||
this.setRest(proxy.getRest());
|
||||
this.setArguments(proxy.getArguments());
|
||||
this.setHeaders(proxy.getHeaders());
|
||||
}
|
||||
} else {
|
||||
ApiDefinitionWithBLOBs apiDefinition = apiDefinitionService.getBLOBs(this.getId());
|
||||
|
@ -126,6 +132,12 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
MsHTTPSamplerProxy proxy = mapper.readValue(apiDefinition.getRequest(), new TypeReference<MsHTTPSamplerProxy>() {
|
||||
});
|
||||
this.setHashTree(proxy.getHashTree());
|
||||
this.setName(apiDefinition.getName());
|
||||
this.setMethod(proxy.getMethod());
|
||||
this.setBody(proxy.getBody());
|
||||
this.setRest(proxy.getRest());
|
||||
this.setArguments(proxy.getArguments());
|
||||
this.setHeaders(proxy.getHeaders());
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
|
|
@ -567,7 +567,7 @@ public class ApiAutomationService {
|
|||
return null;
|
||||
}
|
||||
|
||||
public APIScenarioReportResult createScenarioReport(String id, String scenarioId, String scenarioName, String triggerMode, String execType, String projectId, String userID) {
|
||||
public APIScenarioReportResult createScenarioReport(String id, String scenarioId, String scenarioName, String triggerMode, String execType, String projectId, String userID, RunModeConfig config) {
|
||||
APIScenarioReportResult report = new APIScenarioReportResult();
|
||||
if (triggerMode.equals(ApiRunMode.SCENARIO.name()) || triggerMode.equals(ApiRunMode.DEFINITION.name())) {
|
||||
triggerMode = ReportTriggerMode.MANUAL.name();
|
||||
|
@ -579,8 +579,12 @@ public class ApiAutomationService {
|
|||
} else {
|
||||
report.setName("场景调试");
|
||||
}
|
||||
report.setCreateTime(System.currentTimeMillis());
|
||||
report.setUpdateTime(System.currentTimeMillis());
|
||||
report.setCreateTime(System.currentTimeMillis());
|
||||
if (config != null && config.getMode().equals("serial")) {
|
||||
report.setCreateTime(System.currentTimeMillis() + 2000);
|
||||
report.setUpdateTime(System.currentTimeMillis() + 2000);
|
||||
}
|
||||
report.setStatus(APITestStatus.Running.name());
|
||||
if (StringUtils.isNotEmpty(userID)) {
|
||||
report.setUserId(userID);
|
||||
|
@ -733,10 +737,10 @@ public class ApiAutomationService {
|
|||
}
|
||||
}
|
||||
report = createScenarioReport(reportId, testPlanScenarioId, item.getName(), request.getTriggerMode(),
|
||||
request.getExecuteType(), item.getProjectId(), request.getReportUserID());
|
||||
request.getExecuteType(), item.getProjectId(), request.getReportUserID(), null);
|
||||
} else {
|
||||
report = createScenarioReport(reportId, item.getId(), item.getName(), request.getTriggerMode(),
|
||||
request.getExecuteType(), item.getProjectId(), request.getReportUserID());
|
||||
request.getExecuteType(), item.getProjectId(), request.getReportUserID(), null);
|
||||
}
|
||||
|
||||
// 生成报告和HashTree
|
||||
|
@ -769,8 +773,13 @@ public class ApiAutomationService {
|
|||
private HashTree generateHashTree(List<ApiScenarioWithBLOBs> apiScenarios, RunScenarioRequest request, List<String> reportIds) {
|
||||
HashTree jmeterHashTree = new ListedHashTree();
|
||||
MsTestPlan testPlan = new MsTestPlan();
|
||||
testPlan.setSerializeThreadgroups(request.getConfig() != null && request.getConfig().getMode().equals("serial"));
|
||||
testPlan.setHashTree(new LinkedList<>());
|
||||
if (request.getConfig() != null && request.getConfig().getMode().equals("serial")) {
|
||||
testPlan.setSerializeThreadgroups(true);
|
||||
if (StringUtils.isNotEmpty(request.getConfig().getReportName())) {
|
||||
request.setExecuteType(ExecuteType.Completed.name());
|
||||
}
|
||||
}
|
||||
try {
|
||||
boolean isFirst = true;
|
||||
for (ApiScenarioWithBLOBs item : apiScenarios) {
|
||||
|
@ -791,7 +800,6 @@ public class ApiAutomationService {
|
|||
// 批量执行的结果直接存储为报告
|
||||
if (isFirst) {
|
||||
group.setName(request.getId());
|
||||
isFirst = false;
|
||||
}
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
|
@ -829,15 +837,16 @@ public class ApiAutomationService {
|
|||
}
|
||||
}
|
||||
createScenarioReport(group.getName(), testPlanScenarioId, item.getName(), request.getTriggerMode() == null ? ReportTriggerMode.MANUAL.name() : request.getTriggerMode(),
|
||||
request.getExecuteType(), item.getProjectId(), request.getReportUserID());
|
||||
request.getExecuteType(), item.getProjectId(), request.getReportUserID(), request.getConfig());
|
||||
} else {
|
||||
createScenarioReport(group.getName(), item.getId(), item.getName(), request.getTriggerMode() == null ? ReportTriggerMode.MANUAL.name() : request.getTriggerMode(),
|
||||
request.getExecuteType(), item.getProjectId(), request.getReportUserID());
|
||||
request.getExecuteType(), item.getProjectId(), request.getReportUserID(), request.getConfig());
|
||||
}
|
||||
reportIds.add(group.getName());
|
||||
}
|
||||
group.setHashTree(scenarios);
|
||||
testPlan.getHashTree().add(group);
|
||||
isFirst = false;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
MSException.throwException(ex.getMessage());
|
||||
|
@ -859,7 +868,11 @@ public class ApiAutomationService {
|
|||
List<String> ids = request.getIds();
|
||||
//检查是否有正在执行中的情景
|
||||
this.checkScenarioIsRunning(ids);
|
||||
List<ApiScenarioWithBLOBs> apiScenarios = extApiScenarioMapper.selectIds(ids);
|
||||
StringBuilder idStr = new StringBuilder();
|
||||
ids.forEach(item -> {
|
||||
idStr.append("\"").append(item).append("\"").append(",");
|
||||
});
|
||||
List<ApiScenarioWithBLOBs> apiScenarios = extApiScenarioMapper.selectByIds(idStr.toString().substring(0, idStr.toString().length() - 1), "\"" + StringUtils.join(ids, ",") + "\"");
|
||||
|
||||
String runMode = ApiRunMode.SCENARIO.name();
|
||||
if (StringUtils.isNotBlank(request.getRunMode()) && StringUtils.equals(request.getRunMode(), ApiRunMode.SCENARIO_PLAN.name())) {
|
||||
|
@ -936,7 +949,7 @@ public class ApiAutomationService {
|
|||
}
|
||||
// 调用执行方法
|
||||
createScenarioReport(request.getId(), request.getScenarioId(), request.getScenarioName(), ReportTriggerMode.MANUAL.name(), request.getExecuteType(), request.getProjectId(),
|
||||
SessionUtils.getUserId());
|
||||
SessionUtils.getUserId(), null);
|
||||
// 调用执行方法
|
||||
// jMeterService.runTest(request.getId(), hashTree, ApiRunMode.SCENARIO.name(), null);
|
||||
// 调用执行方法
|
||||
|
|
|
@ -49,41 +49,44 @@ public class ApiDefinitionExecResultService {
|
|||
if (CollectionUtils.isNotEmpty(result.getScenarios())) {
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
ApiDefinitionExecResultMapper definitionExecResultMapper = sqlSession.getMapper(ApiDefinitionExecResultMapper.class);
|
||||
result.getScenarios().get(0).getRequestResults().forEach(item -> {
|
||||
ApiDefinitionExecResult saveResult = new ApiDefinitionExecResult();
|
||||
saveResult.setId(UUID.randomUUID().toString());
|
||||
saveResult.setCreateTime(System.currentTimeMillis());
|
||||
saveResult.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
|
||||
saveResult.setName(item.getName());
|
||||
if (item.getName().indexOf("<->") != -1) {
|
||||
saveResult.setName(item.getName().substring(0, item.getName().indexOf("<->")));
|
||||
}
|
||||
saveResult.setResourceId(item.getName());
|
||||
saveResult.setContent(JSON.toJSONString(item));
|
||||
saveResult.setStartTime(item.getStartTime());
|
||||
String status = item.isSuccess() ? "success" : "error";
|
||||
saveResult.setEndTime(item.getResponseResult().getResponseTime());
|
||||
saveResult.setType(type);
|
||||
saveResult.setStatus(status);
|
||||
if (StringUtils.equals(type, ApiRunMode.API_PLAN.name())) {
|
||||
testPlanApiCaseService.setExecResult(item.getName(), status);
|
||||
testCaseReviewApiCaseService.setExecResult(item.getName(), status);
|
||||
result.getScenarios().forEach(scenarioResult -> {
|
||||
if (scenarioResult != null && CollectionUtils.isNotEmpty(scenarioResult.getRequestResults())) {
|
||||
scenarioResult.getRequestResults().forEach(item -> {
|
||||
ApiDefinitionExecResult saveResult = new ApiDefinitionExecResult();
|
||||
saveResult.setId(UUID.randomUUID().toString());
|
||||
saveResult.setCreateTime(item.getStartTime());
|
||||
saveResult.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
|
||||
saveResult.setName(item.getName());
|
||||
if (item.getName().indexOf("<->") != -1) {
|
||||
saveResult.setName(item.getName().substring(0, item.getName().indexOf("<->")));
|
||||
}
|
||||
saveResult.setResourceId(item.getName());
|
||||
saveResult.setContent(JSON.toJSONString(item));
|
||||
saveResult.setStartTime(item.getStartTime());
|
||||
String status = item.isSuccess() ? "success" : "error";
|
||||
saveResult.setEndTime(item.getResponseResult().getResponseTime());
|
||||
saveResult.setType(type);
|
||||
saveResult.setStatus(status);
|
||||
if (StringUtils.equals(type, ApiRunMode.API_PLAN.name())) {
|
||||
testPlanApiCaseService.setExecResult(item.getName(), status, item.getStartTime());
|
||||
testCaseReviewApiCaseService.setExecResult(item.getName(), status, item.getStartTime());
|
||||
}
|
||||
|
||||
}
|
||||
// 清空上次执行结果的内容,只保留当前最新一条内容
|
||||
ApiDefinitionExecResult prevResult = extApiDefinitionExecResultMapper.selectMaxResultByResourceIdAndType(item.getName(), type);
|
||||
if (prevResult != null) {
|
||||
prevResult.setContent(null);
|
||||
definitionExecResultMapper.updateByPrimaryKeyWithBLOBs(prevResult);
|
||||
}
|
||||
// 更新用例最后执行结果
|
||||
ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = new ApiTestCaseWithBLOBs();
|
||||
apiTestCaseWithBLOBs.setId(saveResult.getResourceId());
|
||||
apiTestCaseWithBLOBs.setLastResultId(saveResult.getId());
|
||||
|
||||
// 清空上次执行结果的内容,只保留当前最新一条内容
|
||||
ApiDefinitionExecResult prevResult = extApiDefinitionExecResultMapper.selectMaxResultByResourceIdAndType(item.getName(), type);
|
||||
if (prevResult != null) {
|
||||
prevResult.setContent(null);
|
||||
definitionExecResultMapper.updateByPrimaryKeyWithBLOBs(prevResult);
|
||||
apiTestCaseMapper.updateByPrimaryKeySelective(apiTestCaseWithBLOBs);
|
||||
definitionExecResultMapper.insert(saveResult);
|
||||
});
|
||||
}
|
||||
// 更新用例最后执行结果
|
||||
ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = new ApiTestCaseWithBLOBs();
|
||||
apiTestCaseWithBLOBs.setId(saveResult.getResourceId());
|
||||
apiTestCaseWithBLOBs.setLastResultId(saveResult.getId());
|
||||
|
||||
apiTestCaseMapper.updateByPrimaryKeySelective(apiTestCaseWithBLOBs);
|
||||
definitionExecResultMapper.insert(saveResult);
|
||||
});
|
||||
sqlSession.flushStatements();
|
||||
}
|
||||
|
@ -126,8 +129,8 @@ public class ApiDefinitionExecResultService {
|
|||
testPlanApiCaseService.updateByPrimaryKeySelective(apiCase);
|
||||
} else {
|
||||
userID = Objects.requireNonNull(SessionUtils.getUser()).getId();
|
||||
testPlanApiCaseService.setExecResult(item.getName(), status);
|
||||
testCaseReviewApiCaseService.setExecResult(item.getName(), status);
|
||||
testPlanApiCaseService.setExecResult(item.getName(), status, item.getStartTime());
|
||||
testCaseReviewApiCaseService.setExecResult(item.getName(), status, item.getStartTime());
|
||||
}
|
||||
|
||||
saveResult.setUserId(userID);
|
||||
|
|
|
@ -15,12 +15,13 @@ import io.metersphere.base.mapper.ApiScenarioReportDetailMapper;
|
|||
import io.metersphere.base.mapper.ApiScenarioReportMapper;
|
||||
import io.metersphere.base.mapper.TestPlanApiScenarioMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtApiScenarioReportMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtTestPlanScenarioCaseMapper;
|
||||
import io.metersphere.commons.constants.APITestStatus;
|
||||
import io.metersphere.commons.constants.ApiRunMode;
|
||||
import io.metersphere.commons.constants.ReportTriggerMode;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.*;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.DateUtils;
|
||||
import io.metersphere.commons.utils.ServiceUtils;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.track.service.TestPlanReportService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
@ -57,9 +58,9 @@ public class ApiScenarioReportService {
|
|||
// 更新场景
|
||||
if (result != null) {
|
||||
if (StringUtils.equals(runMode, ApiRunMode.SCENARIO_PLAN.name())) {
|
||||
return updatePlanCase(result,runMode);
|
||||
return updatePlanCase(result, runMode);
|
||||
} else if (StringUtils.equals(runMode, ApiRunMode.SCHEDULE_SCENARIO_PLAN.name())) {
|
||||
return updateSchedulePlanCase(result,runMode);
|
||||
return updateSchedulePlanCase(result, runMode);
|
||||
} else {
|
||||
updateScenarioStatus(result.getTestId());
|
||||
return updateScenario(result, runMode);
|
||||
|
@ -114,11 +115,12 @@ public class ApiScenarioReportService {
|
|||
return report;
|
||||
}
|
||||
|
||||
public ApiScenarioReport editReport(ScenarioResult test) {
|
||||
public ApiScenarioReport editReport(ScenarioResult test, long startTime) {
|
||||
ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(test.getName());
|
||||
report.setId(report.getId());
|
||||
report.setName(report.getScenarioName() + "-" + DateUtils.getTimeStr(System.currentTimeMillis()));
|
||||
report.setUpdateTime(System.currentTimeMillis());
|
||||
report.setCreateTime(startTime);
|
||||
report.setUpdateTime(startTime);
|
||||
String status = test.getError() == 0 ? "Success" : "Error";
|
||||
report.setStatus(status);
|
||||
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
|
||||
|
@ -166,7 +168,7 @@ public class ApiScenarioReportService {
|
|||
return testResult;
|
||||
}
|
||||
|
||||
public ApiScenarioReport updatePlanCase(TestResult result,String runMode) {
|
||||
public ApiScenarioReport updatePlanCase(TestResult result, String runMode) {
|
||||
// TestPlanApiScenario testPlanApiScenario = testPlanApiScenarioMapper.selectByPrimaryKey(result.getTestId());
|
||||
List<ScenarioResult> scenarioResultList = result.getScenarios();
|
||||
ApiScenarioReport returnReport = null;
|
||||
|
@ -175,9 +177,13 @@ public class ApiScenarioReportService {
|
|||
String projectId = null;
|
||||
String userId = null;
|
||||
TestResult fullResult = createTestResult(result);
|
||||
for (ScenarioResult scenarioResult :
|
||||
scenarioResultList) {
|
||||
ApiScenarioReport report = editReport(scenarioResult);
|
||||
List<String> reportIds = new LinkedList<>();
|
||||
for (ScenarioResult scenarioResult : scenarioResultList) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
if (CollectionUtils.isNotEmpty(scenarioResult.getRequestResults()) && scenarioResult.getRequestResults().get(0).getStartTime() > 0) {
|
||||
startTime = scenarioResult.getRequestResults().get(0).getStartTime();
|
||||
}
|
||||
ApiScenarioReport report = editReport(scenarioResult, startTime);
|
||||
// 报告详情内容
|
||||
ApiScenarioReportDetail detail = new ApiScenarioReportDetail();
|
||||
TestResult newResult = createTestResult(result.getTestId(), scenarioResult);
|
||||
|
@ -207,16 +213,17 @@ public class ApiScenarioReportService {
|
|||
String passRate = new DecimalFormat("0%").format((float) scenarioResult.getSuccess() / (scenarioResult.getSuccess() + scenarioResult.getError()));
|
||||
testPlanApiScenario.setPassRate(passRate);
|
||||
testPlanApiScenario.setReportId(report.getId());
|
||||
testPlanApiScenario.setUpdateTime(System.currentTimeMillis());
|
||||
testPlanApiScenario.setUpdateTime(report.getCreateTime());
|
||||
testPlanApiScenarioMapper.updateByPrimaryKeySelective(testPlanApiScenario);
|
||||
}
|
||||
returnReport = report;
|
||||
reportIds.add(report.getId());
|
||||
}
|
||||
margeReport(result, scenarioIds, scenarioNames, runMode, projectId, userId);
|
||||
margeReport(result, scenarioIds, scenarioNames, runMode, projectId, userId, reportIds);
|
||||
return returnReport;
|
||||
}
|
||||
|
||||
public ApiScenarioReport updateSchedulePlanCase(TestResult result,String runMode) {
|
||||
public ApiScenarioReport updateSchedulePlanCase(TestResult result, String runMode) {
|
||||
ApiScenarioReport lastReport = null;
|
||||
List<ScenarioResult> scenarioResultList = result.getScenarios();
|
||||
|
||||
|
@ -226,9 +233,14 @@ public class ApiScenarioReportService {
|
|||
String projectId = null;
|
||||
String userId = null;
|
||||
TestResult fullResult = createTestResult(result);
|
||||
List<String> reportIds = new ArrayList<>();
|
||||
for (ScenarioResult scenarioResult : scenarioResultList) {
|
||||
// 存储场景报告
|
||||
ApiScenarioReport report = editReport(scenarioResult);
|
||||
long startTime = System.currentTimeMillis();
|
||||
if (CollectionUtils.isNotEmpty(scenarioResult.getRequestResults())) {
|
||||
startTime = scenarioResult.getRequestResults().get(0).getStartTime();
|
||||
}
|
||||
ApiScenarioReport report = editReport(scenarioResult, startTime);
|
||||
|
||||
/**
|
||||
* 测试计划的定时任务场景执行时,主键是提前生成的【测试报告ID】。也就是TestResult.id是【测试报告ID】。
|
||||
|
@ -280,9 +292,10 @@ public class ApiScenarioReportService {
|
|||
scenarioNames.append(report.getName()).append(",");
|
||||
|
||||
lastReport = report;
|
||||
reportIds.add(report.getId());
|
||||
}
|
||||
// 合并报告
|
||||
margeReport(result, scenarioIds, scenarioNames, runMode, projectId, userId);
|
||||
margeReport(result, scenarioIds, scenarioNames, runMode, projectId, userId, reportIds);
|
||||
|
||||
TestPlanReportService testPlanReportService = CommonBeanFactory.getBean(TestPlanReportService.class);
|
||||
testPlanReportService.updateReport(testPlanReportIdList, ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ReportTriggerMode.SCHEDULE.name());
|
||||
|
@ -323,9 +336,12 @@ public class ApiScenarioReportService {
|
|||
}
|
||||
}
|
||||
|
||||
private void margeReport(TestResult result, StringBuilder scenarioIds, StringBuilder scenarioNames, String runMode, String projectId, String userId) {
|
||||
private void margeReport(TestResult result, StringBuilder scenarioIds, StringBuilder scenarioNames, String runMode, String projectId, String userId, List<String> reportIds) {
|
||||
// 合并生成一份报告
|
||||
if (StringUtils.isNotEmpty(result.getReportName())) {
|
||||
// 清理其他报告保留一份合并后的报告
|
||||
this.deleteByIds(reportIds);
|
||||
|
||||
ApiScenarioReport report = createScenarioReport(scenarioIds.toString(), result.getReportName(), result.getError() > 0 ? "Error" : "Success", scenarioNames.toString().substring(0, scenarioNames.toString().length() - 1), runMode, projectId, userId);
|
||||
ApiScenarioReportDetail detail = new ApiScenarioReportDetail();
|
||||
detail.setContent(JSON.toJSONString(result).getBytes(StandardCharsets.UTF_8));
|
||||
|
@ -342,9 +358,14 @@ public class ApiScenarioReportService {
|
|||
String projectId = null;
|
||||
String userId = null;
|
||||
TestResult fullResult = createTestResult(result);
|
||||
List<String> reportIds = new LinkedList<>();
|
||||
for (ScenarioResult item : result.getScenarios()) {
|
||||
// 更新报告状态
|
||||
ApiScenarioReport report = editReport(item);
|
||||
long startTime = System.currentTimeMillis();
|
||||
if (CollectionUtils.isNotEmpty(item.getRequestResults())) {
|
||||
startTime = item.getRequestResults().get(0).getStartTime();
|
||||
}
|
||||
ApiScenarioReport report = editReport(item, startTime);
|
||||
TestResult newResult = createTestResult(result.getTestId(), item);
|
||||
item.setName(report.getScenarioName());
|
||||
newResult.addScenario(item);
|
||||
|
@ -373,9 +394,10 @@ public class ApiScenarioReportService {
|
|||
apiScenarioMapper.updateByPrimaryKey(scenario);
|
||||
}
|
||||
lastReport = report;
|
||||
reportIds.add(report.getId());
|
||||
}
|
||||
// 合并生成一份报告
|
||||
margeReport(result, scenarioIds, scenarioNames, runMode, projectId, userId);
|
||||
margeReport(result, scenarioIds, scenarioNames, runMode, projectId, userId, reportIds);
|
||||
return lastReport;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,13 @@ public interface ExtApiScenarioMapper {
|
|||
|
||||
List<ApiScenarioWithBLOBs> selectIds(@Param("ids") List<String> ids);
|
||||
|
||||
List<ApiScenarioWithBLOBs> selectByIds(@Param("ids") String ids,@Param("oderId") String oderId);
|
||||
|
||||
List<ApiScenario> selectReference(@Param("request") ApiScenarioRequest request);
|
||||
|
||||
int removeToGc(@Param("ids") List<String> ids);
|
||||
|
||||
|
||||
int removeToGcByExample(ApiScenarioExample example);
|
||||
|
||||
int reduction(@Param("ids") List<String> ids);
|
||||
|
|
|
@ -256,6 +256,10 @@
|
|||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectByIds" resultType="io.metersphere.base.domain.ApiScenarioWithBLOBs">
|
||||
select * from api_scenario where id in (${ids}) ORDER BY FIND_IN_SET(id,${oderId})
|
||||
</select>
|
||||
|
||||
<select id="selectReference" resultType="io.metersphere.base.domain.ApiScenario">
|
||||
select * from api_scenario
|
||||
<where>
|
||||
|
|
|
@ -19,4 +19,7 @@ public interface ExtTestPlanScenarioCaseMapper {
|
|||
List<String> getNotRelevanceCaseIds(String planId, List<String> relevanceProjectIds);
|
||||
|
||||
List<String> selectIds(@Param("request")TestPlanScenarioRequest request);
|
||||
|
||||
List<TestPlanApiScenario> selectByIds(@Param("ids")String ids ,@Param("oderId")String oderId );
|
||||
|
||||
}
|
|
@ -88,6 +88,9 @@
|
|||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectByIds" resultType="io.metersphere.base.domain.TestPlanApiScenario">
|
||||
select t.* from test_plan_api_scenario t where t.id in (${ids}) ORDER BY FIND_IN_SET(t.id,${oderId})
|
||||
</select>
|
||||
<select id="selectIds" resultType="java.lang.String">
|
||||
select
|
||||
t.id
|
||||
|
|
|
@ -7,8 +7,6 @@ import io.metersphere.api.service.ApiDefinitionExecResultService;
|
|||
import io.metersphere.api.service.ApiTestCaseService;
|
||||
import io.metersphere.base.domain.TestCaseReviewApiCase;
|
||||
import io.metersphere.base.domain.TestCaseReviewApiCaseExample;
|
||||
import io.metersphere.base.domain.TestPlanApiCase;
|
||||
import io.metersphere.base.domain.TestPlanApiCaseExample;
|
||||
import io.metersphere.base.mapper.TestCaseReviewApiCaseMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtTestCaseReviewApiCaseMapper;
|
||||
import io.metersphere.commons.utils.ServiceUtils;
|
||||
|
@ -91,11 +89,11 @@ public class TestCaseReviewApiCaseService {
|
|||
});
|
||||
}
|
||||
}
|
||||
public void setExecResult(String id, String status) {
|
||||
public void setExecResult(String id, String status,Long time) {
|
||||
TestCaseReviewApiCase apiCase = new TestCaseReviewApiCase();
|
||||
apiCase.setId(id);
|
||||
apiCase.setStatus(status);
|
||||
apiCase.setUpdateTime(System.currentTimeMillis());
|
||||
apiCase.setUpdateTime(time);
|
||||
testCaseReviewApiCaseMapper.updateByPrimaryKeySelective(apiCase);
|
||||
}
|
||||
public void updateByPrimaryKeySelective(TestCaseReviewApiCase apiCase) {
|
||||
|
|
|
@ -122,11 +122,11 @@ public class TestPlanApiCaseService {
|
|||
return testPlanApiCaseMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public void setExecResult(String id, String status) {
|
||||
public void setExecResult(String id, String status,Long time) {
|
||||
TestPlanApiCase apiCase = new TestPlanApiCase();
|
||||
apiCase.setId(id);
|
||||
apiCase.setStatus(status);
|
||||
apiCase.setUpdateTime(System.currentTimeMillis());
|
||||
apiCase.setUpdateTime(time);
|
||||
testPlanApiCaseMapper.updateByPrimaryKeySelective(apiCase);
|
||||
}
|
||||
|
||||
|
|
|
@ -92,14 +92,14 @@ public class TestPlanScenarioCaseService {
|
|||
}
|
||||
|
||||
public String run(RunScenarioRequest request) {
|
||||
TestPlanApiScenarioExample example = new TestPlanApiScenarioExample();
|
||||
example.createCriteria().andIdIn(request.getPlanCaseIds());
|
||||
List<TestPlanApiScenario> testPlanApiScenarioList = testPlanApiScenarioMapper.selectByExample(example);
|
||||
|
||||
StringBuilder idStr = new StringBuilder();
|
||||
request.getPlanCaseIds().forEach(item -> {
|
||||
idStr.append("\"").append(item).append("\"").append(",");
|
||||
});
|
||||
List<TestPlanApiScenario> testPlanApiScenarioList =extTestPlanScenarioCaseMapper.selectByIds(idStr.toString().substring(0, idStr.toString().length() - 1), "\"" + org.apache.commons.lang3.StringUtils.join(request.getPlanCaseIds(), ",") + "\"");
|
||||
List<String> scenarioIds = new ArrayList<>();
|
||||
Map<String,String> scenarioIdApiScarionMap = new HashMap<>();
|
||||
for (TestPlanApiScenario apiScenario:
|
||||
testPlanApiScenarioList) {
|
||||
for (TestPlanApiScenario apiScenario: testPlanApiScenarioList) {
|
||||
scenarioIds.add(apiScenario.getApiScenarioId());
|
||||
scenarioIdApiScarionMap.put(apiScenario.getApiScenarioId(),apiScenario.getId());
|
||||
}
|
||||
|
|
|
@ -932,7 +932,7 @@ public class TestPlanService {
|
|||
APIScenarioReportResult report = apiAutomationService.createScenarioReport(group.getName(),
|
||||
planScenarioID + ":" + request.getTestPlanReportId(),
|
||||
item.getName(), request.getTriggerMode() == null ? ReportTriggerMode.MANUAL.name() : request.getTriggerMode(),
|
||||
request.getExecuteType(), item.getProjectId(), request.getReportUserID());
|
||||
request.getExecuteType(), item.getProjectId(), request.getReportUserID(),null);
|
||||
group.setHashTree(scenarios);
|
||||
testPlan.getHashTree().add(group);
|
||||
apiScenarioReportMapper.insert(report);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -486,7 +486,6 @@ export default {
|
|||
this.rowLoading = row.id;
|
||||
|
||||
this.$get('/api/testcase/get/' + row.caseId, (response) => {
|
||||
console.log(response.data)
|
||||
let apiCase = response.data;
|
||||
let request = JSON.parse(apiCase.request);
|
||||
request.name = row.id;
|
||||
|
@ -512,7 +511,7 @@ export default {
|
|||
request.name = row.id;
|
||||
request.id = row.id;
|
||||
request.useEnvironment = row.environmentId;
|
||||
this.runData.push(request);
|
||||
this.runData.unshift(request);
|
||||
if (this.selectRows.size === index) {
|
||||
resolve();
|
||||
}
|
||||
|
|
|
@ -309,8 +309,6 @@ export default {
|
|||
this.selectRows.forEach(row => {
|
||||
this.buildExecuteParam(param,row);
|
||||
});
|
||||
console.log(param)
|
||||
|
||||
this.$post("/test/plan/scenario/case/run", param, response => {});
|
||||
}
|
||||
this.$message('任务执行中,请稍后刷新查看结果');
|
||||
|
|
Loading…
Reference in New Issue