fix(测试计划): 修复测试计划执行超时状态判断错误的问题

修复测试计划执行超时状态判断错误的问题
This commit is contained in:
song-tianyang 2022-01-13 18:34:50 +08:00 committed by fit2-zhao
parent 50f8eb2d71
commit b8100c5098
2 changed files with 10 additions and 7 deletions

View File

@ -73,7 +73,7 @@ public class ApiExecutionQueueService {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
ApiExecutionQueueDetailMapper batchMapper = sqlSession.getMapper(ApiExecutionQueueDetailMapper.class);
if (StringUtils.equalsAny(type, ApiRunMode.DEFINITION.name(), ApiRunMode.API_PLAN.name())) {
if (StringUtils.equalsAnyIgnoreCase(type, ApiRunMode.DEFINITION.name(), ApiRunMode.API_PLAN.name())) {
final int[] sort = {0};
Map<String, ApiDefinitionExecResult> runMap = (Map<String, ApiDefinitionExecResult>) runObj;
if (envMap == null) {
@ -163,7 +163,7 @@ public class ApiExecutionQueueService {
if (executionQueue.getFailure()) {
LoggerUtil.info("进入失败停止处理:" + executionQueue.getId());
boolean isError = false;
if (StringUtils.equalsAny(dto.getRunMode(), ApiRunMode.SCENARIO.name(),
if (StringUtils.equalsAnyIgnoreCase(dto.getRunMode(), ApiRunMode.SCENARIO.name(),
ApiRunMode.SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(),
ApiRunMode.SCHEDULE_SCENARIO.name(), ApiRunMode.JENKINS_SCENARIO_PLAN.name())) {
ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(executionQueue.getNowReportId());
@ -232,12 +232,11 @@ public class ApiExecutionQueueService {
if (CollectionUtils.isNotEmpty(queueDetails)) {
queueDetails.forEach(item -> {
if (StringUtils.equalsAny(item.getType(), ApiRunMode.SCENARIO.name(), ApiRunMode.SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO.name(), ApiRunMode.JENKINS_SCENARIO_PLAN.name())) {
if (StringUtils.equalsAnyIgnoreCase(item.getType(), ApiRunMode.SCENARIO.name(), ApiRunMode.SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO.name(), ApiRunMode.JENKINS_SCENARIO_PLAN.name())) {
ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(item.getReportId());
if (report != null && StringUtils.equalsAny(report.getStatus(), TestPlanReportStatus.RUNNING.name()) && (System.currentTimeMillis() - report.getUpdateTime()) < now) {
if (report != null && StringUtils.equalsAnyIgnoreCase(report.getStatus(), TestPlanReportStatus.RUNNING.name()) && (System.currentTimeMillis() - report.getUpdateTime()) < now) {
report.setStatus(ScenarioStatus.Timeout.name());
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
executionQueueDetailMapper.deleteByPrimaryKey(item.getId());
ResultDTO dto = new ResultDTO();
dto.setQueueId(item.getQueueId());
@ -247,13 +246,16 @@ public class ApiExecutionQueueService {
dto.setTestPlanReportId(executionQueue.getReportId());
dto.setReportId(executionQueue.getReportId());
dto.setRunMode(executionQueue.getRunMode());
dto.setRunType(RunModeConstants.SERIAL.toString());
dto.setReportType(executionQueue.getReportType());
queueNext(dto);
}else {
executionQueueDetailMapper.deleteByPrimaryKey(item.getId());
}
}
} else {
ApiDefinitionExecResult result = apiDefinitionExecResultMapper.selectByPrimaryKey(item.getReportId());
if (result != null && StringUtils.equalsAny(result.getStatus(), TestPlanReportStatus.RUNNING.name())) {
if (result != null && StringUtils.equalsAnyIgnoreCase(result.getStatus(), TestPlanReportStatus.RUNNING.name())) {
result.setStatus(ScenarioStatus.Timeout.name());
apiDefinitionExecResultMapper.updateByPrimaryKeySelective(result);
executionQueueDetailMapper.deleteByPrimaryKey(item.getId());
@ -268,7 +270,7 @@ public class ApiExecutionQueueService {
if (CollectionUtils.isNotEmpty(executionQueues)) {
executionQueues.forEach(item -> {
ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(item.getReportId());
if (report != null && StringUtils.equalsAny(report.getStatus(), TestPlanReportStatus.RUNNING.name()) && report.getUpdateTime() < now) {
if (report != null && StringUtils.equalsAnyIgnoreCase(report.getStatus(), TestPlanReportStatus.RUNNING.name()) && (System.currentTimeMillis() - report.getUpdateTime()) < now) {
report.setStatus(ScenarioStatus.Timeout.name());
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
}

View File

@ -46,6 +46,7 @@
<status-table-item v-else-if="row.lastResult === 'STOP'" :value="'STOP'"/>
<status-table-item v-else-if="row.lastResult === 'Running'" :value="'Underway'"/>
<status-table-item v-else-if="row.lastResult === 'Waiting'" :value="'Waiting'"/>
<status-table-item v-else-if="row.lastResult === 'Timeout'" :value="'Timeout'"/>
<status-table-item v-else :value="'Prepare'"/>
</template>
</ms-table-column>