diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java index 412af5dd91..225ccaa104 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java @@ -338,7 +338,7 @@ public class ElementUtil { put(ElementConstants.EXTRACT, MsExtract.class.getCanonicalName()); put(ElementConstants.JMETER_ELE, MsJmeterElement.class.getCanonicalName()); put(ElementConstants.TEST_PLAN, MsTestPlan.class.getCanonicalName()); - put(ElementConstants.TREAD_GROUP, MsThreadGroup.class.getCanonicalName()); + put(ElementConstants.THREAD_GROUP, MsThreadGroup.class.getCanonicalName()); put(ElementConstants.DNS_CACHE, MsDNSCacheManager.class.getCanonicalName()); put(ElementConstants.DEBUG_SAMPLER, MsDebugSampler.class.getCanonicalName()); put(ElementConstants.AUTH_MANAGER, MsAuthManager.class.getCanonicalName()); diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java index ec05be26f7..cb6bcf76ac 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java @@ -21,7 +21,7 @@ import java.util.List; @EqualsAndHashCode(callSuper = true) public class MsThreadGroup extends MsTestElement { - private String type = ElementConstants.TREAD_GROUP; + private String type = ElementConstants.THREAD_GROUP; private String clazzName = MsThreadGroup.class.getCanonicalName(); private boolean enableCookieShare; diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseExecuteService.java b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseExecuteService.java index 831f131299..cc64b00090 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseExecuteService.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseExecuteService.java @@ -115,7 +115,6 @@ public class ApiCaseExecuteService { resourcePoolId = request.getConfig().getResourcePoolId(); } if (!request.isRerun()) { - Map planProjects = new HashMap<>(); for (TestPlanApiCase testPlanApiCase : planApiCases) { //处理环境配置为空时的情况 RunModeConfigDTO runModeConfigDTO = new RunModeConfigDTO(); @@ -129,16 +128,6 @@ public class ApiCaseExecuteService { } } ApiDefinitionExecResultWithBLOBs report = ApiDefinitionExecResultUtil.addResult(request, runModeConfigDTO, testPlanApiCase, status, caseMap, resourcePoolId); - // todo check -// if (planProjects.containsKey(testPlanApiCase.getTestPlanId())) { -// report.setProjectId(planProjects.get(testPlanApiCase.getTestPlanId())); -// } else { -// TestPlan plan = CommonBeanFactory.getBean(TestPlanMapper.class).selectByPrimaryKey(testPlanApiCase.getTestPlanId()); -// if (plan != null) { -// planProjects.put(plan.getId(), plan.getProjectId()); -// report.setProjectId(plan.getProjectId()); -// } -// } executeQueue.put(testPlanApiCase.getId(), report); responseDTOS.add(new MsExecResponseDTO(testPlanApiCase.getId(), report.getId(), request.getTriggerMode())); LoggerUtil.debug("预生成测试用例结果报告:" + report.getName() + ", ID " + report.getId()); diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseSerialService.java b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseSerialService.java index 8b7a8ac1dd..ac6c0847d1 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseSerialService.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseSerialService.java @@ -15,6 +15,8 @@ import io.metersphere.api.exec.queue.DBTestQueue; import io.metersphere.api.jmeter.JMeterService; import io.metersphere.api.jmeter.NewDriverManager; import io.metersphere.api.jmeter.utils.SmoothWeighted; +import io.metersphere.commons.utils.*; +import io.metersphere.constants.RunModeConstants; import io.metersphere.service.ApiExecutionQueueService; import io.metersphere.service.RemakeReportService; import io.metersphere.base.domain.ApiDefinitionExecResultWithBLOBs; @@ -28,19 +30,11 @@ import io.metersphere.commons.constants.ApiRunMode; import io.metersphere.commons.constants.ElementConstants; import io.metersphere.commons.constants.PropertyConstant; import io.metersphere.commons.enums.ApiReportStatus; -import io.metersphere.commons.utils.BeanUtils; -import io.metersphere.commons.utils.CommonBeanFactory; -import io.metersphere.commons.utils.JSON; -import io.metersphere.commons.utils.LogUtil; import io.metersphere.dto.JmeterRunRequestDTO; import io.metersphere.dto.ResultDTO; import io.metersphere.environment.service.BaseEnvironmentService; import io.metersphere.plugin.core.MsTestElement; -import io.metersphere.commons.utils.GenerateHashTreeUtil; -import io.metersphere.commons.utils.HashTreeUtil; -import io.metersphere.commons.utils.JSONUtil; import io.metersphere.utils.LoggerUtil; -import io.metersphere.commons.utils.RequestParamsUtil; import io.metersphere.xpack.api.service.ApiRetryOnFailureService; import org.apache.commons.lang3.StringUtils; import org.apache.jorphan.collections.HashTree; @@ -155,6 +149,11 @@ public class ApiCaseSerialService { MsThreadGroup group = new MsThreadGroup(); group.setLabel(caseWithBLOBs.getName()); group.setName(runRequest.getReportId()); + // 接口用例集成报告 + if (StringUtils.isNotEmpty(runRequest.getTestPlanReportId()) + && StringUtils.equals(runRequest.getReportType(), RunModeConstants.SET_REPORT.toString())) { + group.setName(runRequest.getTestPlanReportId()); + } group.setProjectId(caseWithBLOBs.getProjectId()); MsTestElement testElement; if (runRequest.isRetryEnable() && runRequest.getRetryNum() > 0) { diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java index f431a589d6..500ad4ab26 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java @@ -22,6 +22,7 @@ import io.metersphere.base.mapper.ApiTestCaseMapper; import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper; import io.metersphere.base.mapper.plan.TestPlanApiCaseMapper; import io.metersphere.commons.constants.ApiRunMode; +import io.metersphere.commons.constants.ElementConstants; import io.metersphere.commons.enums.ApiReportStatus; import io.metersphere.commons.utils.*; import io.metersphere.dto.JmeterRunRequestDTO; @@ -145,6 +146,12 @@ public class ApiExecuteService { } public MsExecResponseDTO debug(RunDefinitionRequest request, List bodyFiles) { + // 补充线程组ID + if (request.getTestElement() != null + && CollectionUtils.isNotEmpty(request.getTestElement().getHashTree()) + && StringUtils.equalsIgnoreCase(request.getTestElement().getHashTree().get(0).getType(), ElementConstants.THREAD_GROUP)) { + request.getTestElement().getHashTree().get(0).setName(request.getId()); + } JmeterRunRequestDTO runRequest = this.initRunRequest(request, bodyFiles); // 开始执行 jMeterService.run(runRequest); @@ -191,7 +198,7 @@ public class ApiExecuteService { // 单接口调试生成tmp临时目录 requests.forEach(item -> { Body body = item.getBody(); - String tmpFilePath = "tmp/" + request.getReportId(); + String tmpFilePath = "tmp/" + request.getId(); body.setTmpFilePath(tmpFilePath); FileUtils.copyBdyFile(item.getId(), tmpFilePath); FileUtils.createBodyFiles(tmpFilePath, bodyFiles); diff --git a/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterLoggerAppender.java b/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterLoggerAppender.java index 96a4c8e4c7..d40001aca5 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterLoggerAppender.java +++ b/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterLoggerAppender.java @@ -9,11 +9,14 @@ import io.metersphere.commons.utils.FixedCapacityUtil; import org.apache.commons.lang3.StringUtils; public class JMeterLoggerAppender extends UnsynchronizedAppenderBase { + private final static String THREAD_SPLIT = " "; + @Override public void append(ILoggingEvent event) { try { - if (!event.getLevel().levelStr.equals(LogUtil.DEBUG)) { + if (!event.getLevel().levelStr.equals(LogUtil.DEBUG) && StringUtils.isNotEmpty(event.getThreadName())) { StringBuffer message = new StringBuffer(); + String threadName = StringUtils.substringBeforeLast(event.getThreadName(), THREAD_SPLIT); message.append(DateUtils.getTimeStr(event.getTimeStamp())).append(StringUtils.SPACE) .append(event.getLevel()).append(StringUtils.SPACE) .append(event.getThreadName()).append(StringUtils.SPACE) @@ -28,12 +31,9 @@ public class JMeterLoggerAppender extends UnsynchronizedAppenderBase fixedCapacityCache = Collections.synchronizedMap(new LRUHashMap<>()); - public final static Map jmeterLogTask = new HashMap<>(); + private static Map fixedCapacityCache = Collections.synchronizedMap(new LRUHashMap<>()); - public static StringBuffer get(Long key) { + public static StringBuffer get(String key) { return fixedCapacityCache.get(key); } - public static void put(Long key, StringBuffer value) { - fixedCapacityCache.put(key, value); + public static boolean containsKey(String key) { + if (StringUtils.isEmpty(key)) { + return false; + } + return fixedCapacityCache.containsKey(key); + } + + public static void put(String key, StringBuffer value) { + if (!fixedCapacityCache.containsKey(key)) { + fixedCapacityCache.put(key, value); + } + } + + public static void remove(String key) { + if (fixedCapacityCache.containsKey(key)) { + fixedCapacityCache.remove(key); + } } public static int size() { @@ -26,7 +40,7 @@ public class FixedCapacityUtil { static class LRUHashMap extends LinkedHashMap { - private int capacity = 100; + private int capacity = 3000; @Override protected boolean removeEldestEntry(Map.Entry eldest) { @@ -34,28 +48,36 @@ public class FixedCapacityUtil { } } - public static String getJmeterLogger(String reportId, boolean isClear) { try { - Long startTime = FixedCapacityUtil.jmeterLogTask.get(reportId); - if (startTime == null) { - startTime = FixedCapacityUtil.jmeterLogTask.get("[" + reportId + "]"); + StringBuffer console = fixedCapacityCache.get(reportId); + if (FileUtils.isFolderExists(reportId)) { + console.append(StringUtils.LF) + .append(DateUtils.getTimeString(new Date())) + .append(" INFO ").append("Tmp folder ") + .append(FileUtils.BODY_FILE_DIR) + .append(File.separator) + .append(reportId) + .append(" has deleted."); } - if (startTime == null) { - startTime = System.currentTimeMillis(); + if (FileUtils.isFolderExists("tmp" + File.separator + reportId)) { + console.append(StringUtils.LF) + .append(DateUtils.getTimeString(new Date())) + .append(" INFO ") + .append("Tmp folder ") + .append(FileUtils.BODY_FILE_DIR) + .append(File.separator) + .append("tmp") + .append(File.separator) + .append(reportId) + .append(" has deleted."); } - Long endTime = System.currentTimeMillis(); - Long finalStartTime = startTime; - String logMessage = FixedCapacityUtil.fixedCapacityCache.entrySet().stream() - .filter(map -> map.getKey() > finalStartTime && map.getKey() <= endTime) - .map(map -> map.getValue()).collect(Collectors.joining()); - - return logMessage; + return console.toString(); } catch (Exception e) { return StringUtils.EMPTY; } finally { - if (isClear && FixedCapacityUtil.jmeterLogTask.containsKey(reportId)) { - FixedCapacityUtil.jmeterLogTask.remove(reportId); + if (isClear && fixedCapacityCache.containsKey(reportId)) { + fixedCapacityCache.remove(reportId); } } } diff --git a/api-test/backend/src/main/java/io/metersphere/service/ApiExecutionQueueService.java b/api-test/backend/src/main/java/io/metersphere/service/ApiExecutionQueueService.java index 1f0b80a6b1..1ceb774232 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/ApiExecutionQueueService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/ApiExecutionQueueService.java @@ -246,14 +246,8 @@ public class ApiExecutionQueueService { // 清除队列 executionQueueDetailMapper.deleteByExample(example); queueMapper.deleteByPrimaryKey(executionQueue.getId()); - - if (StringUtils.equals(dto.getReportType(), RunModeConstants.SET_REPORT.toString())) { - String reportId = dto.getReportId(); - if (StringUtils.equalsIgnoreCase(dto.getRunMode(), ApiRunMode.DEFINITION.name())) { - reportId = dto.getTestPlanReportId(); - } - apiScenarioReportService.margeReport(reportId, dto.getRunMode(), dto.getConsole()); - } + // 集合报告合并 + this.margeReport(dto); return false; } return true; @@ -319,13 +313,8 @@ public class ApiExecutionQueueService { long count = executionQueueDetailMapper.countByExample(queueDetailExample); if (count == 0) { queueMapper.deleteByPrimaryKey(dto.getQueueId()); - if (StringUtils.equals(dto.getReportType(), RunModeConstants.SET_REPORT.toString())) { - String reportId = dto.getReportId(); - if (StringUtils.equalsIgnoreCase(dto.getRunMode(), ApiRunMode.DEFINITION.name())) { - reportId = dto.getTestPlanReportId(); - } - apiScenarioReportService.margeReport(reportId, dto.getRunMode(), dto.getConsole()); - } + // 集合报告合并 + this.margeReport(dto); } return; } @@ -356,13 +345,8 @@ public class ApiExecutionQueueService { } } } else { - if (StringUtils.equalsIgnoreCase(dto.getReportType(), RunModeConstants.SET_REPORT.toString())) { - String reportId = dto.getReportId(); - if (StringUtils.equalsIgnoreCase(dto.getRunMode(), ApiRunMode.DEFINITION.name())) { - reportId = dto.getTestPlanReportId(); - } - apiScenarioReportService.margeReport(reportId, dto.getRunMode(), dto.getConsole()); - } + // 集合报告合并 + this.margeReport(dto); queueMapper.deleteByPrimaryKey(dto.getQueueId()); LoggerUtil.info("Queue execution ends:" + dto.getQueueId()); } @@ -374,6 +358,16 @@ public class ApiExecutionQueueService { LoggerUtil.info("处理队列结束:" + dto.getReportId() + "QID:" + dto.getQueueId()); } + private void margeReport(ResultDTO dto) { + if (StringUtils.equals(dto.getReportType(), RunModeConstants.SET_REPORT.toString())) { + String reportId = dto.getReportId(); + if (StringUtils.equalsIgnoreCase(dto.getRunMode(), ApiRunMode.DEFINITION.name())) { + reportId = dto.getTestPlanReportId(); + } + apiScenarioReportService.margeReport(reportId, dto.getRunMode(), dto.getConsole()); + } + } + public void defendQueue() { final int SECOND_MILLIS = 1000; final int MINUTE_MILLIS = 60 * SECOND_MILLIS; diff --git a/api-test/backend/src/main/java/io/metersphere/service/TestResultService.java b/api-test/backend/src/main/java/io/metersphere/service/TestResultService.java index 9594849330..59ecfd470d 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/TestResultService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/TestResultService.java @@ -2,10 +2,6 @@ package io.metersphere.service; import io.metersphere.api.dto.automation.ApiTestReportVariable; import io.metersphere.api.exec.scenario.ApiEnvironmentRunningParamService; -import io.metersphere.service.definition.ApiDefinitionExecResultService; -import io.metersphere.service.scenario.ApiScenarioService; -import io.metersphere.service.scenario.ApiScenarioExecutionInfoService; -import io.metersphere.service.scenario.ApiScenarioReportService; import io.metersphere.base.domain.ApiDefinitionExecResultExample; import io.metersphere.base.domain.ApiDefinitionExecResultWithBLOBs; import io.metersphere.base.domain.ApiScenarioReport; @@ -22,9 +18,13 @@ import io.metersphere.commons.utils.DateUtils; import io.metersphere.constants.RunModeConstants; import io.metersphere.dto.BaseSystemConfigDTO; import io.metersphere.dto.ResultDTO; -import io.metersphere.i18n.Translator; import io.metersphere.notice.sender.NoticeModel; import io.metersphere.notice.service.NoticeSendService; +import io.metersphere.service.definition.ApiDefinitionExecResultService; +import io.metersphere.service.scenario.ApiScenarioExecutionInfoService; +import io.metersphere.service.scenario.ApiScenarioReportService; +import io.metersphere.service.scenario.ApiScenarioReportStructureService; +import io.metersphere.service.scenario.ApiScenarioService; import org.apache.commons.beanutils.BeanMap; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -33,11 +33,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import java.util.*; @Service @Transactional(rollbackFor = Exception.class) @@ -58,6 +54,8 @@ public class TestResultService { private RedisTemplate redisTemplate; @Resource private ApiScenarioExecutionInfoService scenarioExecutionInfoService; + @Resource + private ApiScenarioReportStructureService apiScenarioReportStructureService; // 场景 private static final List scenarioRunModes = new ArrayList<>() {{ @@ -111,16 +109,14 @@ public class TestResultService { } /** - * 批量存储执行结果 - * - * @param resultDtoMap + * 批量存储来自NODE/K8s的执行结果 */ public void batchSaveResults(Map> resultDtoMap) { // 处理环境 List environmentList = new LinkedList<>(); for (String key : resultDtoMap.keySet()) { - List dtos = resultDtoMap.get(key); - for (ResultDTO dto : dtos) { + List resultDTOS = resultDtoMap.get(key); + for (ResultDTO dto : resultDTOS) { if (dto.getArbitraryData() != null && dto.getArbitraryData().containsKey("ENV")) { environmentList = (List) dto.getArbitraryData().get("ENV"); } @@ -128,14 +124,22 @@ public class TestResultService { if (CollectionUtils.isNotEmpty(environmentList)) { apiEnvironmentRunningParamService.parseEnvironment(environmentList); } + // 处理集合报告的console日志 + if (StringUtils.isNotEmpty(dto.getConsole()) && StringUtils.equals(dto.getReportType(), RunModeConstants.SET_REPORT.toString())) { + String reportId = dto.getReportId(); + if (StringUtils.equalsIgnoreCase(dto.getRunMode(), ApiRunMode.DEFINITION.name())) { + reportId = dto.getTestPlanReportId(); + } + apiScenarioReportStructureService.update(reportId, dto.getConsole(), true); + } } //测试计划定时任务-接口执行逻辑的话,需要同步测试计划的报告数据 if (StringUtils.equals(key, "schedule-task")) { - apiDefinitionExecResultService.batchSaveApiResult(dtos, true); + apiDefinitionExecResultService.batchSaveApiResult(resultDTOS, true); } else if (StringUtils.equals(key, "api-test-case-task")) { - apiDefinitionExecResultService.batchSaveApiResult(dtos, false); + apiDefinitionExecResultService.batchSaveApiResult(resultDTOS, false); } else if (StringUtils.equalsAny(key, "api-scenario-task")) { - apiScenarioReportService.batchSaveResult(dtos); + apiScenarioReportService.batchSaveResult(resultDTOS); } } diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportService.java index 6256b77cae..8b1d647bea 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportService.java @@ -42,11 +42,7 @@ import io.metersphere.base.mapper.plan.TestPlanApiScenarioMapper; import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper; import io.metersphere.base.mapper.ext.ExtApiScenarioReportMapper; import io.metersphere.base.mapper.ext.ExtApiScenarioReportResultMapper; -import io.metersphere.commons.constants.ApiRunMode; -import io.metersphere.commons.constants.NoticeConstants; -import io.metersphere.commons.constants.ReportTriggerMode; -import io.metersphere.commons.constants.ReportTypeConstants; -import io.metersphere.commons.constants.TriggerMode; +import io.metersphere.commons.constants.*; import io.metersphere.commons.enums.ApiReportStatus; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.BeanUtils; @@ -151,7 +147,7 @@ public class ApiScenarioReportService { public ApiScenarioReport testEnded(ResultDTO dto) { if (!StringUtils.equals(dto.getReportType(), RunModeConstants.SET_REPORT.toString())) { // 更新控制台信息 - apiScenarioReportStructureService.update(dto.getReportId(), dto.getConsole()); + apiScenarioReportStructureService.update(dto.getReportId(), dto.getConsole(), false); } // 优化当前执行携带结果作为状态判断依据 ApiScenarioReport scenarioReport; @@ -435,6 +431,7 @@ public class ApiScenarioReportService { public void margeReport(String reportId, String runMode, String console) { // 更新场景状态 + boolean isActuator = false; if (StringUtils.equalsIgnoreCase(runMode, ApiRunMode.DEFINITION.name())) { ApiDefinitionExecResultWithBLOBs result = definitionExecResultMapper.selectByPrimaryKey(reportId); if (!StringUtils.equalsAnyIgnoreCase(result.getStatus(), ApiReportStatus.RERUNNING.name())) { @@ -443,6 +440,7 @@ public class ApiScenarioReportService { List statusList = extApiDefinitionExecResultMapper.selectDistinctStatusByReportId(reportId); result.setStatus(this.getIntegrationReportStatus(statusList)); definitionExecResultMapper.updateByPrimaryKeySelective(result); + isActuator = !StringUtils.equals(result.getActuator(), StorageConstants.LOCAL.name()); } else { ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(reportId); if (report != null) { @@ -455,17 +453,16 @@ public class ApiScenarioReportService { apiScenarioReportMapper.updateByPrimaryKey(report); //场景集合报告,按照集合报告的结果作为场景的最后执行结果 scenarioExecutionInfoService.insertExecutionInfoByScenarioIds(report.getScenarioId(), report.getStatus(), report.getTriggerMode()); + isActuator = !StringUtils.equals(report.getActuator(), StorageConstants.LOCAL.name()); } } console = StringUtils.isNotEmpty(console) ? console : FixedCapacityUtil.getJmeterLogger(reportId, true); - if (StringUtils.isNotEmpty(console)) { - apiScenarioReportStructureService.update(reportId, console); + if (StringUtils.isNotEmpty(console) && !isActuator) { + apiScenarioReportStructureService.update(reportId, console, false); } // 更新控制台信息 - if (FixedCapacityUtil.jmeterLogTask.containsKey(reportId)) { - FixedCapacityUtil.jmeterLogTask.remove(reportId); - } + FixedCapacityUtil.remove(reportId); } public ApiScenarioReport updateScenario(ResultDTO dto) { diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportStructureService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportStructureService.java index 220d929647..d5fbe124a2 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportStructureService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportStructureService.java @@ -116,12 +116,16 @@ public class ApiScenarioReportStructureService { } } - public void update(String reportId, String console) { + public void update(String reportId, String console, boolean isActuator) { ApiScenarioReportStructureExample example = new ApiScenarioReportStructureExample(); example.createCriteria().andReportIdEqualTo(reportId); List structures = mapper.selectByExampleWithBLOBs(example); for (ApiScenarioReportStructureWithBLOBs structure : structures) { - structure.setConsole(console); + if (isActuator) { + structure.setConsole(StringUtils.join(structure.getConsole(), StringUtils.LF, console)); + } else { + structure.setConsole(console); + } mapper.updateByPrimaryKeyWithBLOBs(structure); } } diff --git a/api-test/backend/src/main/resources/logback.xml b/api-test/backend/src/main/resources/logback.xml index 5db65d1f78..846e179c98 100644 --- a/api-test/backend/src/main/resources/logback.xml +++ b/api-test/backend/src/main/resources/logback.xml @@ -229,7 +229,7 @@ UTF-8 - %d [%thread] %-5level %logger{36} %line - %msg%n + %d %t %-5level %logger{36} %line - %msg%n @@ -252,7 +252,7 @@ ${logging.file.path}/ms-jmeter-run.log - ${logging.file.path}/history/ms-jmeter-run-log.%d{yyyyMMdd}-%i.log + ${logging.file.path}/history/ms-jmeter-run.%d{yyyyMMdd}-%i.log ${logger.max.history:-30} UTF-8 - %d [%thread] %-5level %logger{36} %line - %msg%n + %d %t %-5level %logger{36} %line - %msg%n @@ -272,7 +272,7 @@ 10000 - +