diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java index 7507cbae04..cf2bd13d17 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java @@ -42,6 +42,9 @@ public class MsAssertions extends MsTestElement { if (!config.isOperating() && !this.isEnable()) { return; } + if (StringUtils.isEmpty(this.getName())) { + this.setName("Assertion"); + } addAssertions(tree); } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiCaseResultService.java b/backend/src/main/java/io/metersphere/api/service/ApiCaseResultService.java index 73238ccfd6..f371ef8e24 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiCaseResultService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiCaseResultService.java @@ -1,34 +1,24 @@ package io.metersphere.api.service; import io.metersphere.base.domain.ApiDefinitionExecResult; -import io.metersphere.base.mapper.ApiDefinitionExecResultMapper; -import org.apache.ibatis.session.ExecutorType; -import org.apache.ibatis.session.SqlSession; -import org.apache.ibatis.session.SqlSessionFactory; -import org.mybatis.spring.SqlSessionUtils; +import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.LinkedList; import java.util.Map; @Service public class ApiCaseResultService { @Resource - private SqlSessionFactory sqlSessionFactory; + private ExtApiDefinitionExecResultMapper resultMapper; @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) public void batchSave(Map executeQueue) { - SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); - ApiDefinitionExecResultMapper batchMapper = sqlSession.getMapper(ApiDefinitionExecResultMapper.class); - for (String testId : executeQueue.keySet()) { - ApiDefinitionExecResult report = executeQueue.get(testId); - batchMapper.insert(report); - } - sqlSession.flushStatements(); - if (sqlSession != null && sqlSessionFactory != null) { - SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); + if (!executeQueue.isEmpty()) { + resultMapper.sqlInsert(new LinkedList<>(executeQueue.values())); } } } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiExecutionQueueService.java b/backend/src/main/java/io/metersphere/api/service/ApiExecutionQueueService.java index f314ee1d49..ecd770cbc2 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiExecutionQueueService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiExecutionQueueService.java @@ -28,10 +28,6 @@ import io.metersphere.utils.LoggerUtil; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.ibatis.session.ExecutorType; -import org.apache.ibatis.session.SqlSession; -import org.apache.ibatis.session.SqlSessionFactory; -import org.mybatis.spring.SqlSessionUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -45,8 +41,6 @@ public class ApiExecutionQueueService { @Resource private ApiExecutionQueueMapper queueMapper; @Resource - private SqlSessionFactory sqlSessionFactory; - @Resource private ApiExecutionQueueDetailMapper executionQueueDetailMapper; @Resource private ApiScenarioSerialService apiScenarioSerialService; @@ -79,9 +73,7 @@ public class ApiExecutionQueueService { DBTestQueue resQueue = new DBTestQueue(); BeanUtils.copyBean(resQueue, executionQueue); Map detailMap = new HashMap<>(); - - SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); - ApiExecutionQueueDetailMapper batchMapper = sqlSession.getMapper(ApiExecutionQueueDetailMapper.class); + List queueDetails = new LinkedList<>(); if (StringUtils.equalsAnyIgnoreCase(type, ApiRunMode.DEFINITION.name(), ApiRunMode.API_PLAN.name())) { final int[] sort = {0}; Map runMap = (Map) runObj; @@ -95,7 +87,7 @@ public class ApiExecutionQueueService { resQueue.setQueue(queue); } sort[0]++; - batchMapper.insert(queue); + queueDetails.add(queue); detailMap.put(k, queue.getId()); }); } else { @@ -108,13 +100,12 @@ public class ApiExecutionQueueService { resQueue.setQueue(queue); } sort[0]++; - batchMapper.insert(queue); + queueDetails.add(queue); detailMap.put(k, queue.getId()); }); } - sqlSession.flushStatements(); - if (sqlSession != null && sqlSessionFactory != null) { - SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); + if (CollectionUtils.isNotEmpty(queueDetails)) { + extApiExecutionQueueMapper.sqlInsert(queueDetails); } resQueue.setDetailMap(detailMap); return resQueue; @@ -283,10 +274,10 @@ public class ApiExecutionQueueService { public void timeOut() { final int SECOND_MILLIS = 1000; final int MINUTE_MILLIS = 60 * SECOND_MILLIS; - // 计算二十分钟前的超时报告 - final long twentyMinutesAgo = System.currentTimeMillis() - (30 * MINUTE_MILLIS); + // 计算一小时前的超时报告 + final long timeout = System.currentTimeMillis() - (60 * MINUTE_MILLIS); ApiExecutionQueueDetailExample example = new ApiExecutionQueueDetailExample(); - example.createCriteria().andCreateTimeLessThan(twentyMinutesAgo); + example.createCriteria().andCreateTimeLessThan(timeout); List queueDetails = executionQueueDetailMapper.selectByExample(example); for (ApiExecutionQueueDetail item : queueDetails) { @@ -312,7 +303,7 @@ public class ApiExecutionQueueService { ApiRunMode.JENKINS_SCENARIO_PLAN.name())) { ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(item.getReportId()); if (report != null && StringUtils.equalsAnyIgnoreCase(report.getStatus(), TestPlanReportStatus.RUNNING.name(), APITestStatus.Waiting.name()) - && report.getUpdateTime() < twentyMinutesAgo) { + && report.getUpdateTime() < timeout) { report.setStatus(ScenarioStatus.Timeout.name()); apiScenarioReportMapper.updateByPrimaryKeySelective(report); @@ -344,13 +335,13 @@ public class ApiExecutionQueueService { } ApiExecutionQueueExample queueDetailExample = new ApiExecutionQueueExample(); - queueDetailExample.createCriteria().andReportTypeEqualTo(RunModeConstants.SET_REPORT.toString()).andCreateTimeLessThan(twentyMinutesAgo); + queueDetailExample.createCriteria().andReportTypeEqualTo(RunModeConstants.SET_REPORT.toString()).andCreateTimeLessThan(timeout); List executionQueues = queueMapper.selectByExample(queueDetailExample); if (CollectionUtils.isNotEmpty(executionQueues)) { executionQueues.forEach(item -> { ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(item.getReportId()); if (report != null && StringUtils.equalsAnyIgnoreCase(report.getStatus(), TestPlanReportStatus.RUNNING.name(), APITestStatus.Waiting.name()) - && (report.getUpdateTime() < twentyMinutesAgo)) { + && (report.getUpdateTime() < timeout)) { report.setStatus(ScenarioStatus.Timeout.name()); apiScenarioReportMapper.updateByPrimaryKeySelective(report); } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java index 8c67823872..c1ecdb1bd6 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -32,10 +32,7 @@ import io.metersphere.utils.LoggerUtil; import org.apache.commons.beanutils.BeanMap; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.ibatis.session.ExecutorType; -import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; -import org.mybatis.spring.SqlSessionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -743,19 +740,16 @@ public class ApiScenarioReportService { @Transactional(propagation = Propagation.REQUIRES_NEW) public void batchSave(Map executeQueue, String serialReportId, String runMode, List responseDTOS) { - SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); - ApiScenarioReportMapper batchMapper = sqlSession.getMapper(ApiScenarioReportMapper.class); + List list = new LinkedList<>(); if (StringUtils.isEmpty(serialReportId)) { for (String reportId : executeQueue.keySet()) { APIScenarioReportResult report = executeQueue.get(reportId).getReport(); - batchMapper.insert(report); + list.add(report); responseDTOS.add(new MsExecResponseDTO(executeQueue.get(reportId).getTestId(), reportId, runMode)); } - sqlSession.flushStatements(); - if (sqlSession != null && sqlSessionFactory != null) { - SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); + if (CollectionUtils.isNotEmpty(list)) { + extApiScenarioReportMapper.sqlInsert(list); } } - } } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.java index 4e67ec94f6..bb9f9f8401 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.java @@ -3,6 +3,7 @@ package io.metersphere.base.mapper.ext; import io.metersphere.api.dto.datacount.ExecutedCaseInfoResult; import io.metersphere.base.domain.ApiDefinitionExecResult; import io.metersphere.track.dto.PlanReportCaseDTO; +import org.apache.ibatis.annotations.InsertProvider; import org.apache.ibatis.annotations.Param; import java.util.Collection; @@ -35,4 +36,7 @@ public interface ExtApiDefinitionExecResultMapper { void update(@Param("ids") List ids); + @InsertProvider(type = ExtApiDefinitionExecResultProvider.class, method = "insertListSql") + void sqlInsert(List list); + } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultProvider.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultProvider.java new file mode 100644 index 0000000000..76b6ad40a5 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultProvider.java @@ -0,0 +1,51 @@ +package io.metersphere.base.mapper.ext; + +import io.metersphere.base.domain.ApiDefinitionExecResult; + +import java.util.List; + +public class ExtApiDefinitionExecResultProvider { + public String insertListSql(List list) { + StringBuffer sqlList = new StringBuffer(); + sqlList.append("insert into api_definition_exec_result (id, `name`, resource_id, `status`, user_id, start_time, end_time," + + " create_time, `type`, actuator, trigger_mode, version_id, error_code, content) values "); + for (int i = 0; i < list.size(); i++) { + ApiDefinitionExecResult result = list.get(i); + sqlList.append(" (") + .append("'") + .append(result.getId()) + .append("','") + .append(result.getName()) + .append("','") + .append(result.getResourceId()) + .append("','") + .append(result.getStatus()) + .append("','") + .append(result.getUserId()) + .append("',") + .append(result.getStartTime()) + .append(",") + .append(result.getEndTime()) + .append(",") + .append(result.getCreateTime()) + .append(",'") + .append(result.getType()) + .append("','") + .append(result.getActuator()) + .append("','") + .append(result.getTriggerMode()) + .append("','") + .append(result.getVersionId()) + .append("','") + .append(result.getErrorCode()) + .append("','") + .append(result.getContent()) + .append("'") + .append(")"); + if (i < list.size() - 1) { + sqlList.append(","); + } + } + return sqlList.toString(); + } +} diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiExecutionQueueMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiExecutionQueueMapper.java index 73ad785c0d..1fa5317bb7 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiExecutionQueueMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiExecutionQueueMapper.java @@ -1,6 +1,8 @@ package io.metersphere.base.mapper.ext; import io.metersphere.base.domain.ApiExecutionQueue; +import io.metersphere.base.domain.ApiExecutionQueueDetail; +import org.apache.ibatis.annotations.InsertProvider; import java.util.List; @@ -10,4 +12,8 @@ public interface ExtApiExecutionQueueMapper { List findTestPlanReportQueue(); List findTestPlanRunningReport(); + + @InsertProvider(type = ExtApiExecutionQueueProvider.class, method = "insertListSql") + void sqlInsert(List list); + } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiExecutionQueueProvider.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiExecutionQueueProvider.java new file mode 100644 index 0000000000..2a0771f4b0 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiExecutionQueueProvider.java @@ -0,0 +1,38 @@ +package io.metersphere.base.mapper.ext; + +import io.metersphere.base.domain.ApiExecutionQueueDetail; + +import java.util.List; + +public class ExtApiExecutionQueueProvider { + public String insertListSql(List list) { + StringBuffer sqlList = new StringBuffer(); + sqlList.append("insert into api_execution_queue_detail (id, queue_id, sort, report_id, test_id, `type`, create_time, evn_map) values "); + for (int i = 0; i < list.size(); i++) { + ApiExecutionQueueDetail result = list.get(i); + sqlList.append(" (") + .append("'") + .append(result.getId()) + .append("','") + .append(result.getQueueId()) + .append("',") + .append(result.getSort()) + .append(",'") + .append(result.getReportId()) + .append("','") + .append(result.getTestId()) + .append("','") + .append(result.getType()) + .append("',") + .append(result.getCreateTime()) + .append(",'") + .append(result.getEvnMap()) + .append("'") + .append(")"); + if (i < list.size() - 1) { + sqlList.append(","); + } + } + return sqlList.toString(); + } +} diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.java index a028b4861e..33e6b77189 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.java @@ -6,6 +6,7 @@ import io.metersphere.api.dto.datacount.ApiDataCountResult; import io.metersphere.base.domain.ApiScenarioReport; import io.metersphere.dto.ApiReportCountDTO; import io.metersphere.track.dto.PlanReportCaseDTO; +import org.apache.ibatis.annotations.InsertProvider; import org.apache.ibatis.annotations.Param; import java.util.Collection; @@ -39,4 +40,8 @@ public interface ExtApiScenarioReportMapper { List selectForPlanReport(@Param("ids") List reportIds); void update(@Param("ids") List ids); + + @InsertProvider(type = ExtApiScenarioReportProvider.class, method = "insertListSql") + void sqlInsert(List list); + } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportProvider.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportProvider.java new file mode 100644 index 0000000000..b7eaca60b5 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportProvider.java @@ -0,0 +1,57 @@ +package io.metersphere.base.mapper.ext; + +import io.metersphere.api.dto.automation.APIScenarioReportResult; + +import java.util.List; + +public class ExtApiScenarioReportProvider { + public String insertListSql(List list) { + StringBuffer sqlList = new StringBuffer(); + sqlList.append("INSERT INTO api_scenario_report (id, project_id, `name`, create_time, update_time, `status`, user_id, trigger_mode," + + " execute_type, scenario_name, scenario_id, create_user, actuator, end_time, report_version, version_id, description) VALUES "); + for (int i = 0; i < list.size(); i++) { + APIScenarioReportResult result = list.get(i); + sqlList.append(" (") + .append("'") + .append(result.getId()) + .append("','") + .append(result.getProjectId()) + .append("','") + .append(result.getName()) + .append("',") + .append(result.getCreateTime()) + .append(",") + .append(result.getUpdateTime()) + .append(",'") + .append(result.getStatus()) + .append("','") + .append(result.getUserId()) + .append("','") + .append(result.getTriggerMode()) + .append("','") + .append(result.getExecuteType()) + .append("','") + .append(result.getScenarioName()) + .append("','") + .append(result.getScenarioId()) + .append("','") + .append(result.getCreateUser()) + .append("','") + .append(result.getActuator()) + .append("',") + .append(result.getEndTime()) + .append(",") + .append(2) + .append(",'") + .append(result.getVersionId()) + .append("','") + .append(result.getDescription()) + .append("'") + .append(")"); + if (i < list.size() - 1) { + sqlList.append(","); + } + } + return sqlList.toString(); + } +} diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java index f15ca5a7ca..3b767b6284 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -123,10 +123,10 @@ public class TestPlanReportService { return list; } - public void setTestPlanReportPassRate(List list){ - for(TestPlanReportDTO testPlanReportDTO : list){ + public void setTestPlanReportPassRate(List list) { + for (TestPlanReportDTO testPlanReportDTO : list) { // 如果数据库查询成功率字段为空或 0 则重新计算一次 - if(testPlanReportDTO.getPassRate() == null || testPlanReportDTO.getPassRate() == 0){ + if (testPlanReportDTO.getPassRate() == null || testPlanReportDTO.getPassRate() == 0) { TestPlanReportContentExample example = new TestPlanReportContentExample(); example.createCriteria().andTestPlanReportIdEqualTo(testPlanReportDTO.getId()); List testPlanReportContents = testPlanReportContentMapper.selectByExampleWithBLOBs(example); @@ -156,7 +156,7 @@ public class TestPlanReportService { // 性能用例 planReportCaseDTOS = extTestPlanLoadCaseMapper.selectForPlanReport(planId); TestPlanUtils.buildStatusResultMap(planReportCaseDTOS, statusResultMap, report, TestPlanLoadCaseStatus.success.name()); - }else{ + } else { // 报告 ID 集合 List reportIds = null; if (MapUtils.isNotEmpty(testPlanExecuteReportDTO.getTestPlanApiCaseIdAndReportIdMap())) { @@ -513,7 +513,7 @@ public class TestPlanReportService { public TestPlanReportContentWithBLOBs parseReportDaoToReportContent(TestPlanSimpleReportDTO reportDTO, TestPlanReportContentWithBLOBs testPlanReportContentWithBLOBs) { String id = testPlanReportContentWithBLOBs.getId(); String testPlanReportId = testPlanReportContentWithBLOBs.getTestPlanReportId(); - if(testPlanReportContentWithBLOBs.getEndTime() != null){ + if (testPlanReportContentWithBLOBs.getEndTime() != null) { reportDTO.setEndTime(testPlanReportContentWithBLOBs.getEndTime()); } BeanUtils.copyBean(testPlanReportContentWithBLOBs, reportDTO); @@ -859,25 +859,20 @@ public class TestPlanReportService { } public void createTestPlanReportContentReportIds(String testPlanReportID, Map apiCaseReportMap, Map scenarioReportIdMap, Map loadCaseReportIdMap) { - TestPlanReportContentExample example = new TestPlanReportContentExample(); - example.createCriteria().andTestPlanReportIdEqualTo(testPlanReportID); - long dataCount = testPlanReportContentMapper.countByExample(example); - if (dataCount == 0) { - TestPlanReportContentWithBLOBs content = new TestPlanReportContentWithBLOBs(); - content.setId(UUID.randomUUID().toString()); - content.setTestPlanReportId(testPlanReportID); + TestPlanReportContentWithBLOBs content = new TestPlanReportContentWithBLOBs(); + content.setId(UUID.randomUUID().toString()); + content.setTestPlanReportId(testPlanReportID); - if (MapUtils.isNotEmpty(apiCaseReportMap)) { - content.setPlanApiCaseReportStruct(JSONObject.toJSONString(apiCaseReportMap)); - } - if (MapUtils.isNotEmpty(scenarioReportIdMap)) { - content.setPlanScenarioReportStruct(JSONObject.toJSONString(scenarioReportIdMap)); - } - if (MapUtils.isNotEmpty(loadCaseReportIdMap)) { - content.setPlanLoadCaseReportStruct(JSONObject.toJSONString(loadCaseReportIdMap)); - } - testPlanReportContentMapper.insert(content); + if (MapUtils.isNotEmpty(apiCaseReportMap)) { + content.setPlanApiCaseReportStruct(JSONObject.toJSONString(apiCaseReportMap)); } + if (MapUtils.isNotEmpty(scenarioReportIdMap)) { + content.setPlanScenarioReportStruct(JSONObject.toJSONString(scenarioReportIdMap)); + } + if (MapUtils.isNotEmpty(loadCaseReportIdMap)) { + content.setPlanLoadCaseReportStruct(JSONObject.toJSONString(loadCaseReportIdMap)); + } + testPlanReportContentMapper.insert(content); } public TestPlanExecuteReportDTO genTestPlanExecuteReportDTOByTestPlanReportContent(TestPlanReportContentWithBLOBs testPlanReportContentWithBLOBs) { diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index 4a0bf5eb3b..fc70f93004 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -4,9 +4,6 @@ package io.metersphere.track.service; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import io.metersphere.api.dto.APIReportResult; import io.metersphere.api.dto.EnvironmentType; @@ -14,11 +11,6 @@ import io.metersphere.api.dto.automation.*; import io.metersphere.api.dto.definition.ApiTestCaseRequest; import io.metersphere.api.dto.definition.BatchRunDefinitionRequest; import io.metersphere.api.dto.definition.TestPlanApiCaseDTO; -import io.metersphere.api.dto.definition.request.ElementUtil; -import io.metersphere.api.dto.definition.request.MsScenario; -import io.metersphere.api.dto.definition.request.MsTestPlan; -import io.metersphere.api.dto.definition.request.MsThreadGroup; -import io.metersphere.api.dto.definition.request.variable.ScenarioVariable; import io.metersphere.api.service.ApiAutomationService; import io.metersphere.api.service.ApiDefinitionService; import io.metersphere.api.service.ApiScenarioReportService; @@ -43,7 +35,6 @@ import io.metersphere.performance.request.RunTestPlanRequest; import io.metersphere.performance.service.MetricQueryService; import io.metersphere.performance.service.PerformanceReportService; import io.metersphere.performance.service.PerformanceTestService; -import io.metersphere.plugin.core.MsTestElement; import io.metersphere.service.*; import io.metersphere.track.Factory.ReportComponentFactory; import io.metersphere.track.domain.ReportComponent; @@ -55,6 +46,7 @@ import io.metersphere.track.request.testplan.LoadCaseReportRequest; import io.metersphere.track.request.testplan.LoadCaseRequest; import io.metersphere.track.request.testplan.TestplanRunRequest; import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest; +import io.metersphere.utils.LoggerUtil; import org.apache.commons.beanutils.BeanMap; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; @@ -526,8 +518,8 @@ public class TestPlanService { boolean isSelectAll = request.getRequest() != null && request.getRequest().isSelectAll(); if (isSelectAll) { Map maintainerMap = extTestCaseMapper.getMaintainerMap(request.getRequest()); - for (String k : maintainerMap.keySet()) { - userMap.put(k, maintainerMap.get(k).getMaintainer()); + for (String k : maintainerMap.keySet()) { + userMap.put(k, maintainerMap.get(k).getMaintainer()); } } else { TestCaseExample testCaseExample = new TestCaseExample(); @@ -1017,11 +1009,15 @@ public class TestPlanService { //执行接口案例任务 + LoggerUtil.info("开始执行测试计划接口用例 " + planReportId); Map apiCaseReportMap = this.executeApiTestCase(triggerMode, planReportId, userId, new ArrayList<>(reportInfoDTO.getApiTestCaseDataMap().keySet()), runModeConfig); //执行场景执行任务 + LoggerUtil.info("开始执行测试计划场景用例 " + planReportId); Map scenarioReportMap = this.executeScenarioCase(planReportId, testPlanID, projectID, runModeConfig, triggerMode, userId, reportInfoDTO.getPlanScenarioIdMap()); //执行性能测试任务 + LoggerUtil.info("开始执行测试计划性能用例 " + planReportId); Map loadCaseReportMap = this.executeLoadCaseTask(runModeConfig, triggerMode, reportInfoDTO.getPerformanceIdMap()); + LoggerUtil.info("开始生成测试计划报告 " + planReportId); testPlanReportService.createTestPlanReportContentReportIds(planReportId, apiCaseReportMap, scenarioReportMap, loadCaseReportMap); return planReportId; } @@ -1040,9 +1036,9 @@ public class TestPlanService { private Map executeScenarioCase(String planReportId, String testPlanID, String projectID, RunModeConfigDTO runModeConfig, String triggerMode, String userId, Map planScenarioIdMap) { if (!planScenarioIdMap.isEmpty()) { SchedulePlanScenarioExecuteRequest scenarioRequest = new SchedulePlanScenarioExecuteRequest(); - String senarionReportID = UUID.randomUUID().toString(); - scenarioRequest.setId(senarionReportID); - scenarioRequest.setReportId(senarionReportID); + String scenarioReportID = UUID.randomUUID().toString(); + scenarioRequest.setId(scenarioReportID); + scenarioRequest.setReportId(scenarioReportID); scenarioRequest.setProjectId(projectID); if (StringUtils.equals(triggerMode, ReportTriggerMode.API.name())) { scenarioRequest.setTriggerMode(ReportTriggerMode.API.name());