fix (接口自动化):修复串行问题
This commit is contained in:
parent
5033045665
commit
95a664add1
|
@ -58,6 +58,10 @@ public class MsKafkaListener {
|
|||
|
||||
private void save(String execResult) {
|
||||
TestResult testResult = this.formatResult(execResult);
|
||||
String testId = testResult.getTestId();
|
||||
testResultService.saveResult(testResult, testResult.getRunMode(), null, testResult.getTestId());
|
||||
if (StringUtils.isNotEmpty(testId)) {
|
||||
MessageCache.executionQueue.remove(testId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1191,9 +1191,10 @@ public class ApiAutomationService {
|
|||
executeQueue.get(key).setHashTree(hashTree);
|
||||
}
|
||||
Future<ApiScenarioReport> future = executorService.submit(new SerialScenarioExecTask(jMeterService, apiScenarioReportMapper, executeQueue.get(key), request));
|
||||
ApiScenarioReport scenarioReport = future.get();
|
||||
future.get();
|
||||
// 如果开启失败结束执行,则判断返回结果状态
|
||||
if (request.getConfig().isOnSampleError()) {
|
||||
ApiScenarioReport scenarioReport = apiScenarioReportMapper.selectByPrimaryKey(key);
|
||||
if (scenarioReport == null || !scenarioReport.getStatus().equals("Success")) {
|
||||
reportIds.remove(key);
|
||||
break;
|
||||
|
|
|
@ -11,7 +11,6 @@ import io.metersphere.base.domain.ApiScenarioReport;
|
|||
import io.metersphere.base.mapper.ApiScenarioReportMapper;
|
||||
import io.metersphere.commons.constants.APITestStatus;
|
||||
import io.metersphere.commons.constants.TriggerMode;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
@ -44,7 +43,8 @@ public class SerialScenarioExecTask<T> implements Callable<T> {
|
|||
jMeterService.runLocal(runModeDataDTO.getReport().getId(), runModeDataDTO.getHashTree(), TriggerMode.BATCH.name().equals(request.getTriggerMode()) ? TriggerMode.BATCH.name() : request.getReportId(), request.getRunMode());
|
||||
}
|
||||
while (MessageCache.executionQueue.containsKey(runModeDataDTO.getReport().getId())) {
|
||||
long currentSecond = (System.currentTimeMillis() - MessageCache.executionQueue.get(runModeDataDTO.getReport().getId())) / 1000 / 60;
|
||||
long time = MessageCache.executionQueue.get(runModeDataDTO.getReport().getId());
|
||||
long currentSecond = (System.currentTimeMillis() - time) / 1000 / 60;
|
||||
// 设置五分钟超时
|
||||
if (currentSecond > 5) {
|
||||
// 执行失败了,恢复报告状态
|
||||
|
@ -59,12 +59,11 @@ public class SerialScenarioExecTask<T> implements Callable<T> {
|
|||
MessageCache.terminationOrderDeque.remove(runModeDataDTO.getReport().getId());
|
||||
break;
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
report = apiScenarioReportMapper.selectByPrimaryKey(runModeDataDTO.getReport().getId());
|
||||
return (T) report;
|
||||
return null;
|
||||
} catch (Exception ex) {
|
||||
LogUtil.error(ex);
|
||||
MSException.throwException(ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue