refactor(接口测试): 接口报告停止适配测试计划的接口报告停止
This commit is contained in:
parent
da5c545e14
commit
5be3cf217d
|
@ -212,11 +212,13 @@
|
|||
</include>
|
||||
</select>
|
||||
<select id="getReports" resultType="io.metersphere.api.dto.report.ReportDTO">
|
||||
select distinct ar.* , project.organization_id , a.api_test_case_id as resourceId from api_report ar
|
||||
select distinct ar.* , project.organization_id ,
|
||||
ar.test_plan_case_id as testPlanId,
|
||||
if (ar.test_plan_case_id = 'NONE' , a.api_test_case_id , ar.test_plan_case_id) as resourceId from api_report ar
|
||||
LEFT JOIN api_test_case_record a ON ar.id = a.api_report_id
|
||||
LEFT JOIN api_test_case c ON a.api_test_case_id = c.id
|
||||
left join project on ar.project_id = project.id
|
||||
where
|
||||
where
|
||||
ar.deleted = false and ar.plan = 0
|
||||
and ar.start_time BETWEEN #{startTime} AND #{endTime}
|
||||
and ar.exec_status in ('PENDING', 'RUNNING', 'RERUNNING')
|
||||
|
|
|
@ -105,7 +105,10 @@
|
|||
</select>
|
||||
<select id="getReports" resultType="io.metersphere.api.dto.report.ReportDTO">
|
||||
|
||||
select distinct asr.*, project.organization_id, a.api_scenario_id as resourceId from api_scenario_report asr
|
||||
select distinct asr.*, project.organization_id,
|
||||
asr.test_plan_scenario_id as testPlanId,
|
||||
if (asr.test_plan_scenario_id = 'NONE' , a.api_scenario_id , asr.test_plan_scenario_id) as resourceId
|
||||
from api_scenario_report asr
|
||||
left join api_scenario_record a on asr.id = a.api_scenario_report_id
|
||||
left JOIN api_scenario s on a.api_scenario_id = s.id
|
||||
left join project on asr.project_id = project.id
|
||||
|
@ -202,10 +205,12 @@
|
|||
o.id as organizationId
|
||||
from project p
|
||||
inner join organization o on p.organization_id = o.id
|
||||
where p.id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
<if test="ids != null and ids.size() > 0">
|
||||
where p.id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
<select id="getScenarioBlob" resultType="io.metersphere.api.domain.ApiScenarioBlob">
|
||||
select
|
||||
|
|
|
@ -275,6 +275,8 @@ public class ApiTaskCenterService {
|
|||
.collect(Collectors.toMap(ReportDTO::getId, ReportDTO::getIntegrated));
|
||||
Map<String, String> resourceIdMap = reports.stream()
|
||||
.collect(Collectors.toMap(ReportDTO::getId, ReportDTO::getResourceId));
|
||||
Map<String, String> testPlanIdMap = reports.stream()
|
||||
.collect(Collectors.toMap(ReportDTO::getId, ReportDTO::getTestPlanId));
|
||||
nodesList.parallelStream().forEach(node -> {
|
||||
String endpoint = TaskRunnerClient.getEndpoint(node.getIp(), node.getPort());
|
||||
//需要去除取消勾选的report
|
||||
|
@ -300,10 +302,17 @@ public class ApiTaskCenterService {
|
|||
TaskInfo taskInfo = taskRequestDTO.getTaskInfo();
|
||||
TaskItem taskItem = new TaskItem();
|
||||
taskItem.setReportId(reportId);
|
||||
taskItem.setResourceId(resourceIdMap.getOrDefault(reportId, null));
|
||||
// TODO 这里需要兼容测试计划批量执行的类型
|
||||
|
||||
taskInfo.setResourceType(request.getModuleType());
|
||||
taskItem.setResourceId(resourceIdMap.getOrDefault(reportId, null));
|
||||
// 这里需要兼容测试计划批量执行的类型
|
||||
if (StringUtils.isNotEmpty(testPlanIdMap.get(reportId))
|
||||
&& !StringUtils.equals(testPlanIdMap.get(reportId), "NONE")) {
|
||||
if (StringUtils.equals(request.getModuleType(), TaskCenterResourceType.API_CASE.toString())) {
|
||||
taskInfo.setResourceType(ApiExecuteResourceType.TEST_PLAN_API_CASE.name());
|
||||
} else if (StringUtils.equals(request.getModuleType(), TaskCenterResourceType.API_SCENARIO.toString())) {
|
||||
taskInfo.setResourceType(ApiExecuteResourceType.TEST_PLAN_API_SCENARIO.name());
|
||||
}
|
||||
}
|
||||
taskInfo.getRunModeConfig().setIntegratedReport(integrationMap.get(reportId));
|
||||
if (BooleanUtils.isTrue(integrationMap.get(reportId))) {
|
||||
taskInfo.getRunModeConfig().getCollectionReport().setReportId(reportId);
|
||||
|
|
|
@ -242,6 +242,7 @@ public class ApiTaskCenterControllerTests extends BaseTest {
|
|||
apiReport.setEnvironmentId("api-environment-id" + i);
|
||||
apiReport.setRunMode("api-run-mode" + i);
|
||||
if (i % 2 == 0) {
|
||||
apiReport.setTestPlanCaseId("task-api-resource-id" + i);
|
||||
apiReport.setStatus(ExecStatus.PENDING.name());
|
||||
} else {
|
||||
apiReport.setStatus(ExecStatus.RUNNING.name());
|
||||
|
@ -266,6 +267,7 @@ public class ApiTaskCenterControllerTests extends BaseTest {
|
|||
scenarioReport.setCreateUser("admin");
|
||||
scenarioReport.setUpdateUser("admin");
|
||||
if (i % 2 == 0) {
|
||||
scenarioReport.setTestPlanScenarioId("task-api-resource-id" + i);
|
||||
scenarioReport.setStatus(ExecStatus.PENDING.name());
|
||||
} else {
|
||||
scenarioReport.setStatus(ExecStatus.RUNNING.name());
|
||||
|
|
Loading…
Reference in New Issue