diff --git a/backend/src/main/java/io/metersphere/api/exec/schedule/TestPlanReportListenerScheduled.java b/backend/src/main/java/io/metersphere/api/exec/schedule/TestPlanReportListenerScheduled.java index 25d2e1946b..610505dc4e 100644 --- a/backend/src/main/java/io/metersphere/api/exec/schedule/TestPlanReportListenerScheduled.java +++ b/backend/src/main/java/io/metersphere/api/exec/schedule/TestPlanReportListenerScheduled.java @@ -26,9 +26,9 @@ public class TestPlanReportListenerScheduled { } private void listener(String planReportId) { - LoggerUtil.info("检查测试计划执行报告:【" + planReportId + "】"); if (TestPlanReportExecuteCatch.getTestPlanExecuteInfo(planReportId) != null) { if (!CommonBeanFactory.getBean(ExecThreadPoolExecutor.class).checkPlanReport(planReportId)) { + LoggerUtil.info("检查测试计划执行报告:【" + planReportId + "】"); CommonBeanFactory.getBean(TestPlanReportService.class).countReport(planReportId); } } else { diff --git a/backend/src/main/java/io/metersphere/api/service/ApiExecutionQueueService.java b/backend/src/main/java/io/metersphere/api/service/ApiExecutionQueueService.java index 530a668fd7..d53877f287 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiExecutionQueueService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiExecutionQueueService.java @@ -11,6 +11,7 @@ import io.metersphere.base.mapper.ApiExecutionQueueMapper; import io.metersphere.base.mapper.ApiScenarioReportMapper; import io.metersphere.base.mapper.ext.ExtApiExecutionQueueMapper; import io.metersphere.commons.constants.ApiRunMode; +import io.metersphere.commons.constants.TestPlanReportStatus; import io.metersphere.commons.utils.BeanUtils; import io.metersphere.constants.RunModeConstants; import io.metersphere.dto.ResultDTO; @@ -179,8 +180,8 @@ public class ApiExecutionQueueService { final int SECOND_MILLIS = 1000; final int MINUTE_MILLIS = 60 * SECOND_MILLIS; long now = System.currentTimeMillis(); - // 五分钟前的数据 - now = now - 5 * MINUTE_MILLIS; + // 八分钟前的数据 + now = now - 8 * MINUTE_MILLIS; ApiExecutionQueueDetailExample example = new ApiExecutionQueueDetailExample(); example.createCriteria().andCreateTimeLessThan(now); List queueDetails = executionQueueDetailMapper.selectByExample(example); @@ -189,13 +190,13 @@ public class ApiExecutionQueueService { 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())) { ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(item.getReportId()); - if (report != null) { + if (report != null && StringUtils.equalsAny(report.getStatus(), TestPlanReportStatus.RUNNING.name())) { report.setStatus("timeout"); apiScenarioReportMapper.updateByPrimaryKeySelective(report); } } else { ApiDefinitionExecResult result = apiDefinitionExecResultMapper.selectByPrimaryKey(item.getReportId()); - if (result != null) { + if (result != null && StringUtils.equalsAny(result.getStatus(), TestPlanReportStatus.RUNNING.name())) { result.setStatus("timeout"); apiDefinitionExecResultMapper.updateByPrimaryKeySelective(result); } @@ -210,7 +211,7 @@ public class ApiExecutionQueueService { if (CollectionUtils.isNotEmpty(executionQueues)) { executionQueues.forEach(item -> { ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(item.getReportId()); - if (report != null) { + if (report != null && StringUtils.equalsAny(report.getStatus(), TestPlanReportStatus.RUNNING.name())) { report.setStatus("timeout"); apiScenarioReportMapper.updateByPrimaryKeySelective(report); } diff --git a/backend/src/main/resources/db/migration/V103__v1.16_release.sql b/backend/src/main/resources/db/migration/V103__v1.16_release.sql index 21b509d37c..4be971e034 100644 --- a/backend/src/main/resources/db/migration/V103__v1.16_release.sql +++ b/backend/src/main/resources/db/migration/V103__v1.16_release.sql @@ -67,27 +67,27 @@ VALUES (UUID(), 'project_app_manager', 'PROJECT_APP_MANAGER:READ+EDIT', 'PROJECT CREATE TABLE IF NOT EXISTS `api_execution_queue` ( - `id` varchar(50) NOT NULL COMMENT 'ID', - `test_queue` LONGTEXT COMMENT '执行资源Id队列fifo', + `id` varchar(50) NOT NULL COMMENT 'ID', `report_id` varchar(100) COMMENT '集合报告/测试计划报告', `report_type` varchar(100) COMMENT '报告类型/计划报告/单独报告', `run_mode` varchar(100) COMMENT '执行模式/scenario/api/test_paln_api/test_pan_scenario', `pool_id` varchar(100) DEFAULT NULL COMMENT '执行资源池', - create_time bigint(13) NULL COMMENT '创建时间', + create_time bigint(13) NULL COMMENT '创建时间', PRIMARY KEY (`id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; - CREATE TABLE IF NOT EXISTS `api_execution_queue_detail` ( - `id` varchar(50) NOT NULL COMMENT 'ID', - `queue_id` LONGTEXT COMMENT '队列id', - `report_id` varchar(100) COMMENT '报告id', - `test_id` varchar(100) COMMENT '资源id', - `evn_map` varchar(100) COMMENT '环境', - `type` varchar(100) DEFAULT NULL COMMENT '资源类型', + `id` varchar(50) NOT NULL COMMENT 'ID', + `queue_id` varchar(100) COMMENT '队列id', + `sort` int COMMENT '排序', + `report_id` varchar(100) COMMENT '报告id', + `test_id` varchar(100) COMMENT '资源id', + `evn_map` LONGTEXT COMMENT '环境', + `type` varchar(100) DEFAULT NULL COMMENT '资源类型', create_time bigint(13) NULL COMMENT '创建时间', PRIMARY KEY (`id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; + ALTER TABLE load_test MODIFY name VARCHAR(255) NOT NULL COMMENT 'Test name'; \ No newline at end of file