From 93c3f5ed8a5f77deeb8f86703763f3cbdd0a4d5b Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Tue, 7 Feb 2023 16:23:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E5=AE=9A=E6=97=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=85=BC=E5=AE=B9=E5=BE=AE=E6=9C=8D=E5=8A=A1=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1022487 --user=赵勇 【定时任务】2.2.1版本升级到2.6.1版本,测试计划和接口场景的定时任务初始化报错,也没按时执行 https://www.tapd.cn/55049933/s/1332341 --- .../service/BaseScheduleService.java | 2 ++ .../job/sechedule/MsScheduleJob.java | 29 ------------------- .../job/sechedule/PerformanceTestJob.java | 3 +- 3 files changed, 4 insertions(+), 30 deletions(-) delete mode 100644 performance-test/backend/src/main/java/io/metersphere/job/sechedule/MsScheduleJob.java diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/BaseScheduleService.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/BaseScheduleService.java index d4bb3f2b79..897c4cae53 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/BaseScheduleService.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/BaseScheduleService.java @@ -48,6 +48,7 @@ public class BaseScheduleService { private final String API_SCENARIO_JOB = "io.metersphere.sechedule.ApiScenarioTestJob"; private final String API_SWAGGER_IMPORT_JOB = "io.metersphere.sechedule.SwaggerUrlImportJob"; + private final String TEST_PLAN_JOB = "io.metersphere.plan.job.TestPlanTestJob"; public void addSchedule(Schedule schedule) { schedule.setId(UUID.randomUUID().toString()); @@ -143,6 +144,7 @@ public class BaseScheduleService { switch (group) { case API_SCENARIO_TEST -> schedule.setJob(API_SCENARIO_JOB); case SWAGGER_IMPORT -> schedule.setJob(API_SWAGGER_IMPORT_JOB); + case TEST_PLAN_TEST -> schedule.setJob(TEST_PLAN_JOB); } } diff --git a/performance-test/backend/src/main/java/io/metersphere/job/sechedule/MsScheduleJob.java b/performance-test/backend/src/main/java/io/metersphere/job/sechedule/MsScheduleJob.java deleted file mode 100644 index 94cd1ffc22..0000000000 --- a/performance-test/backend/src/main/java/io/metersphere/job/sechedule/MsScheduleJob.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.metersphere.job.sechedule; - -import io.metersphere.commons.utils.LogUtil; -import org.quartz.*; - -public abstract class MsScheduleJob implements Job { - - protected String resourceId; - - protected String userId; - - protected String expression; - - @Override - public void execute(JobExecutionContext context) throws JobExecutionException { - - JobKey jobKey = context.getTrigger().getJobKey(); - JobDataMap jobDataMap = context.getJobDetail().getJobDataMap(); - this.resourceId = jobDataMap.getString("resourceId"); - this.userId = jobDataMap.getString("userId"); - this.expression = jobDataMap.getString("expression"); - - LogUtil.info(jobKey.getGroup() + " Running: " + resourceId); - LogUtil.info("CronExpression: " + expression); - businessExecute(context); - } - - abstract void businessExecute(JobExecutionContext context); -} diff --git a/performance-test/backend/src/main/java/io/metersphere/job/sechedule/PerformanceTestJob.java b/performance-test/backend/src/main/java/io/metersphere/job/sechedule/PerformanceTestJob.java index a97322e721..8a58e95442 100644 --- a/performance-test/backend/src/main/java/io/metersphere/job/sechedule/PerformanceTestJob.java +++ b/performance-test/backend/src/main/java/io/metersphere/job/sechedule/PerformanceTestJob.java @@ -4,6 +4,7 @@ import io.metersphere.commons.constants.ReportTriggerMode; import io.metersphere.commons.constants.ScheduleGroup; import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.request.RunTestPlanRequest; +import io.metersphere.sechedule.MsScheduleJob; import io.metersphere.service.PerformanceTestService; import org.quartz.JobExecutionContext; import org.quartz.JobKey; @@ -18,7 +19,7 @@ public class PerformanceTestJob extends MsScheduleJob { } @Override - void businessExecute(JobExecutionContext context) { + protected void businessExecute(JobExecutionContext context) { RunTestPlanRequest request = new RunTestPlanRequest(); request.setId(resourceId); request.setUserId(userId);