perf(接口测试): 及时释放部分全局变量
This commit is contained in:
parent
3b7d41f001
commit
24fab2517b
|
@ -2,6 +2,7 @@ package io.metersphere.api.exec.queue;
|
|||
|
||||
import io.metersphere.api.jmeter.JMeterService;
|
||||
import io.metersphere.api.jmeter.JmeterThreadUtils;
|
||||
import io.metersphere.cache.JMeterEngineCache;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.dto.JmeterRunRequestDTO;
|
||||
import io.metersphere.utils.LoggerUtil;
|
||||
|
@ -20,11 +21,13 @@ public class ExecTask implements Runnable {
|
|||
@Override
|
||||
public void run() {
|
||||
LoggerUtil.info("开始执行报告ID:【 " + request.getReportId() + " 】,资源ID【 " + request.getTestId() + " 】");
|
||||
JMeterService jMeterService = CommonBeanFactory.getBean(JMeterService.class);
|
||||
jMeterService.addQueue(request);
|
||||
CommonBeanFactory.getBean(JMeterService.class).addQueue(request);
|
||||
Object res = PoolExecBlockingQueueUtil.take(request.getReportId());
|
||||
if (res == null && !JmeterThreadUtils.isRunning(request.getReportId(), request.getTestId())) {
|
||||
LoggerUtil.info("执行报告:【 " + request.getReportId() + " 】,资源ID【 " + request.getTestId() + " 】执行超时");
|
||||
if (JMeterEngineCache.runningEngine.containsKey(request.getReportId())) {
|
||||
JMeterEngineCache.runningEngine.remove(request.getReportId());
|
||||
}
|
||||
}
|
||||
LoggerUtil.info("任务:【 " + request.getReportId() + " 】执行完成");
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package io.metersphere.api.jmeter;
|
|||
import io.metersphere.api.exec.queue.PoolExecBlockingQueueUtil;
|
||||
import io.metersphere.api.service.ApiExecutionQueueService;
|
||||
import io.metersphere.api.service.TestResultService;
|
||||
import io.metersphere.cache.JMeterEngineCache;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.dto.ResultDTO;
|
||||
import io.metersphere.jmeter.MsExecListener;
|
||||
|
@ -26,6 +27,9 @@ public class APISingleResultListener extends MsExecListener {
|
|||
@Override
|
||||
public void testEnded(ResultDTO dto, Map<String, Object> kafkaConfig) {
|
||||
try {
|
||||
if (JMeterEngineCache.runningEngine.containsKey(dto.getReportId())) {
|
||||
JMeterEngineCache.runningEngine.remove(dto.getReportId());
|
||||
}
|
||||
LoggerUtil.info("进入TEST-END处理报告【" + dto.getReportId() + " 】整体执行完成;" + dto.getRunMode());
|
||||
// 全局并发队列
|
||||
PoolExecBlockingQueueUtil.offer(dto.getReportId());
|
||||
|
|
Loading…
Reference in New Issue