refactor(接口测试): 去除无用消息分发和监听方法

This commit is contained in:
fit2-zhao 2022-10-21 10:05:05 +08:00 committed by f2c-ci-robot[bot]
parent 0b4433b992
commit 7b0284f38f
6 changed files with 2 additions and 37 deletions

View File

@ -3,7 +3,6 @@ package io.metersphere.api.jmeter;
import io.metersphere.api.exec.queue.PoolExecBlockingQueueUtil;
import io.metersphere.cache.JMeterEngineCache;
import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.FileUtils;
import io.metersphere.commons.utils.FixedCapacityUtil;
@ -88,9 +87,6 @@ public class MsApiBackendListener extends AbstractBackendListenerClient implemen
LoggerUtil.info("Check Processing Test Plan report status" + dto.getQueueId() + "" + dto.getTestId());
apiExecutionQueueService.testPlanReportTestEnded(dto.getTestPlanReportId());
}
if (StringUtils.equalsAnyIgnoreCase(dto.getRunMode(), ApiRunMode.API_PLAN.name(), ApiRunMode.SCENARIO_PLAN.name())) {
apiExecutionQueueService.sendMessage(dto.getReportId());
}
LoggerUtil.info("TEST-END处理结果集完成", dto.getReportId());
} catch (Exception e) {
LoggerUtil.error("结果集处理异常", dto.getReportId(), e);

View File

@ -38,12 +38,6 @@ public class KafkaConfig {
.build();
}
@Bean
public NewTopic testPlanApiCaseMessageTopic() {
return TopicBuilder.name(KafkaTopicConstants.TEST_PLAN_API_REPORT_TOPIC)
.build();
}
public static Map<String, Object> getKafka() {
KafkaProperties kafkaProperties = CommonBeanFactory.getBean(KafkaProperties.class);
Map<String, Object> producerProps = new HashMap<>();

View File

@ -276,11 +276,6 @@ public class ApiExecutionQueueService {
kafkaTemplate.send(KafkaTopicConstants.TEST_PLAN_REPORT_TOPIC, testPlanReportId);
}
public void sendMessage(String reportId) {
// 发送执行通知
kafkaTemplate.send(KafkaTopicConstants.TEST_PLAN_API_REPORT_TOPIC, reportId, ApiReportStatus.SUCCESS.name());
}
public void queueNext(ResultDTO dto) {
LoggerUtil.info("开始处理队列:" + dto.getReportId() + "QID" + dto.getQueueId());
if (StringUtils.equals(dto.getRunType(), RunModeConstants.PARALLEL.toString())) {

View File

@ -252,7 +252,7 @@
</filter>
<File>${logging.file.path}/ms-jmeter-run.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logging.file.path}/history/ms-jmeter-run.%d{yyyyMMdd}-%i.log
<FileNamePattern>${logging.file.path}/history/ms-jmeter-run-log.%d{yyyyMMdd}-%i.log
</FileNamePattern>
<maxHistory>${logger.max.history:-30}</maxHistory>
<TimeBasedFileNamingAndTriggeringPolicy
@ -272,7 +272,7 @@
<queueSize>10000</queueSize>
<appender-ref ref="apiRunLogAppender"/>
</appender>
<logger name="ms-jmeter-run" additivity="false">
<logger name="ms-jmeter-run-log" additivity="false">
<level value="${logger.level:INFO}"/>
<appender-ref ref="runLogAppender"/>
</logger>

View File

@ -9,9 +9,6 @@ public interface KafkaTopicConstants {
String API_REPORT_TOPIC = "ms-api-exec-topic";
// 测试计划接收执行结果TOPIC
String TEST_PLAN_REPORT_TOPIC = "TEST_PLAN_REPORT_TOPIC";
// 测试计划接收条数结果TOPIC
String TEST_PLAN_API_REPORT_TOPIC = "TEST_PLAN_API_REPORT_TOPIC";
// 保存当前站点时检查MOCK环境
String CHECK_MOCK_ENV_TOPIC = "CHECK_MOCK_ENV_TOPIC";

View File

@ -7,10 +7,8 @@ import io.metersphere.base.mapper.ApiExecutionQueueDetailMapper;
import io.metersphere.base.mapper.ApiExecutionQueueMapper;
import io.metersphere.commons.constants.KafkaTopicConstants;
import io.metersphere.commons.constants.TestPlanReportStatus;
import io.metersphere.dto.MsgDTO;
import io.metersphere.plan.service.TestPlanReportService;
import io.metersphere.utils.LoggerUtil;
import io.metersphere.utils.WebSocketUtil;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
@ -23,8 +21,6 @@ import java.util.stream.Collectors;
@Component
public class ExecReportListener {
public static final String CONSUME_ID = "exec-test-plan-report";
public static final String DEBUG_CONSUME_ID = "exec-test-plan-debug-report";
@Resource
protected ApiExecutionQueueMapper queueMapper;
@Resource
@ -38,17 +34,6 @@ public class ExecReportListener {
this.testPlanReportTestEnded(record.value());
}
@KafkaListener(id = DEBUG_CONSUME_ID, topics = KafkaTopicConstants.TEST_PLAN_API_REPORT_TOPIC, groupId = "${spring.application.name}")
public void debugConsume(ConsumerRecord<?, String> record) {
LoggerUtil.info("Received debug results", record.value());
MsgDTO dto = new MsgDTO();
dto.setExecEnd(false);
dto.setReportId("send." + record.key());
dto.setToReport(record.key().toString());
dto.setContent(record.value());
WebSocketUtil.sendMessageSingle(dto);
}
public void testPlanReportTestEnded(String testPlanReportId) {
// 检查测试计划中其他队列是否结束
ApiExecutionQueueExample executionQueueExample = new ApiExecutionQueueExample();
@ -72,6 +57,4 @@ public class ExecReportListener {
}
}
}
}