fix(测试计划) 修复并发执行问题
--bug=1006849 --user=赵勇 【测试计划】-批量执行接口用例失败 https://www.tapd.cn/55049933/s/1049783
This commit is contained in:
parent
e99a3ecb11
commit
49c1bd8816
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.api.jmeter;
|
||||
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.engine.JMeterEngineException;
|
||||
import org.apache.jmeter.engine.StandardJMeterEngine;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
@ -20,7 +21,9 @@ public class LocalRunner {
|
|||
engine.configure(jmxTree);
|
||||
try {
|
||||
engine.runTest();
|
||||
if (StringUtils.isNotEmpty(report)) {
|
||||
MessageCache.runningEngine.put(report, engine);
|
||||
}
|
||||
} catch (JMeterEngineException e) {
|
||||
engine.stopTest(true);
|
||||
}
|
||||
|
@ -29,7 +32,7 @@ public class LocalRunner {
|
|||
public void stop(String report) {
|
||||
try {
|
||||
StandardJMeterEngine engine = MessageCache.runningEngine.get(report);
|
||||
if (engine != null) {
|
||||
if (engine != null && StringUtils.isNotEmpty(report)) {
|
||||
engine.stopTest();
|
||||
MessageCache.runningEngine.remove(report);
|
||||
}
|
||||
|
|
|
@ -480,9 +480,9 @@ public class TestPlanApiCaseService {
|
|||
ApiDefinitionExecResult report = addResult(request, key, APITestStatus.Running.name(), batchMapper);
|
||||
modeDataDTO.setApiCaseId(report.getId());
|
||||
if (request.getConfig() != null && StringUtils.isNotEmpty(request.getConfig().getResourcePoolId())) {
|
||||
jMeterService.runTest(modeDataDTO.getTestId(), modeDataDTO.getApiCaseId(), ApiRunMode.API_PLAN.name(), null, request.getConfig());
|
||||
jMeterService.runTest(report.getId(), modeDataDTO.getApiCaseId(), ApiRunMode.API_PLAN.name(), null, request.getConfig());
|
||||
} else {
|
||||
jMeterService.runLocal(modeDataDTO.getTestId(), modeDataDTO.getHashTree(), TriggerMode.BATCH.name() , ApiRunMode.API_PLAN.name());
|
||||
jMeterService.runLocal(report.getId(), modeDataDTO.getHashTree(), TriggerMode.BATCH.name() , ApiRunMode.API_PLAN.name());
|
||||
}
|
||||
}
|
||||
sqlSession.flushStatements();
|
||||
|
|
Loading…
Reference in New Issue