fix(场景自动化) 终止执行队列
This commit is contained in:
parent
8b50869490
commit
fa3d750e2d
|
@ -1146,6 +1146,11 @@ public class ApiAutomationService {
|
|||
ApiTestEnvironmentService apiTestEnvironmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);
|
||||
HashTreeUtil hashTreeUtil = new HashTreeUtil();
|
||||
for (String key : executeQueue.keySet()) {
|
||||
// 终止执行
|
||||
if (MessageCache.terminationOrderDeque.contains(key)) {
|
||||
MessageCache.terminationOrderDeque.remove(key);
|
||||
break;
|
||||
}
|
||||
reportIds.add(key);
|
||||
APIScenarioReportResult report = executeQueue.get(key).getReport();
|
||||
if (StringUtils.isNotEmpty(serialReportId)) {
|
||||
|
|
|
@ -36,7 +36,7 @@ public class SerialScenarioExecTask<T> implements Callable<T> {
|
|||
try {
|
||||
if (MessageCache.terminationOrderDeque.contains(runModeDataDTO.getReport().getId())) {
|
||||
MessageCache.terminationOrderDeque.remove(runModeDataDTO.getReport().getId());
|
||||
return (T) report;
|
||||
return null;
|
||||
}
|
||||
if (request.getConfig() != null && StringUtils.isNotBlank(request.getConfig().getResourcePoolId())) {
|
||||
jMeterService.runTest(runModeDataDTO.getTestId(), runModeDataDTO.getReport().getId(), request.getRunMode(), request.getPlanScenarioId(), request.getConfig());
|
||||
|
|
|
@ -23,6 +23,7 @@ import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
|
|||
import io.metersphere.api.dto.definition.request.sampler.MsJDBCSampler;
|
||||
import io.metersphere.api.dto.definition.request.sampler.MsTCPSampler;
|
||||
import io.metersphere.api.jmeter.JMeterService;
|
||||
import io.metersphere.api.jmeter.MessageCache;
|
||||
import io.metersphere.api.jmeter.ResourcePoolCalculation;
|
||||
import io.metersphere.api.service.ApiDefinitionExecResultService;
|
||||
import io.metersphere.api.service.ApiTestCaseService;
|
||||
|
@ -420,6 +421,10 @@ public class TestPlanApiCaseService {
|
|||
public void run() {
|
||||
for (TestPlanApiCase testPlanApiCase : executeQueue.keySet()) {
|
||||
try {
|
||||
if (MessageCache.terminationOrderDeque.contains(executeQueue.get(testPlanApiCase).getId())) {
|
||||
MessageCache.terminationOrderDeque.remove(executeQueue.get(testPlanApiCase).getId());
|
||||
break;
|
||||
}
|
||||
ApiDefinitionExecResult execResult = executeQueue.get(testPlanApiCase);
|
||||
execResult.setId(executeQueue.get(testPlanApiCase).getId());
|
||||
execResult.setStatus(APITestStatus.Running.name());
|
||||
|
|
|
@ -6,6 +6,7 @@ package io.metersphere.track.service.task;
|
|||
import io.metersphere.api.dto.RunModeDataDTO;
|
||||
import io.metersphere.api.dto.automation.RunModeConfig;
|
||||
import io.metersphere.api.jmeter.JMeterService;
|
||||
import io.metersphere.api.jmeter.MessageCache;
|
||||
import io.metersphere.base.domain.ApiDefinitionExecResult;
|
||||
import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
|
||||
import io.metersphere.commons.constants.APITestStatus;
|
||||
|
@ -33,6 +34,10 @@ public class SerialApiExecTask<T> implements Callable<T> {
|
|||
@Override
|
||||
public T call() {
|
||||
try {
|
||||
if (MessageCache.terminationOrderDeque.contains(runModeDataDTO.getReport().getId())) {
|
||||
MessageCache.terminationOrderDeque.remove(runModeDataDTO.getReport().getId());
|
||||
return null;
|
||||
}
|
||||
if (config != null && StringUtils.isNotBlank(config.getResourcePoolId())) {
|
||||
jMeterService.runTest(runModeDataDTO.getTestId(), runModeDataDTO.getApiCaseId(), runMode, null, config);
|
||||
} else {
|
||||
|
@ -48,6 +53,10 @@ public class SerialApiExecTask<T> implements Callable<T> {
|
|||
if (report != null && !report.getStatus().equals(APITestStatus.Running.name())) {
|
||||
break;
|
||||
}
|
||||
if (MessageCache.terminationOrderDeque.contains(runModeDataDTO.getReport().getId())) {
|
||||
MessageCache.terminationOrderDeque.remove(runModeDataDTO.getReport().getId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 执行失败了,恢复报告状态
|
||||
if (index == 200 && report != null && report.getStatus().equals(APITestStatus.Running.name())) {
|
||||
|
|
Loading…
Reference in New Issue