fix(测试计划定时任务): 更改定时任务配置以及执行方式

更改定时任务配置以及执行方式
This commit is contained in:
song-tianyang 2021-12-16 14:44:44 +08:00 committed by BugKing
parent e2088407f9
commit 5b4e8a836b
3 changed files with 15 additions and 16 deletions

View File

@ -16,22 +16,9 @@ import org.quartz.*;
public class TestPlanTestJob extends MsScheduleJob { public class TestPlanTestJob extends MsScheduleJob {
private String projectID; private String projectID;
// private PerformanceTestService performanceTestService;
// private TestPlanScenarioCaseService testPlanScenarioCaseService;
// private TestPlanApiCaseService testPlanApiCaseService;
// private ApiTestCaseService apiTestCaseService;
// private TestPlanReportService testPlanReportService;
// private TestPlanLoadCaseService testPlanLoadCaseService;
private TestPlanService testPlanService; private TestPlanService testPlanService;
public TestPlanTestJob() { public TestPlanTestJob() {
// this.performanceTestService = CommonBeanFactory.getBean(PerformanceTestService.class);
// this.testPlanScenarioCaseService = CommonBeanFactory.getBean(TestPlanScenarioCaseService.class);
// this.testPlanApiCaseService = CommonBeanFactory.getBean(TestPlanApiCaseService.class);
// this.apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
// this.testPlanReportService = CommonBeanFactory.getBean(TestPlanReportService.class);
// this.testPlanLoadCaseService = CommonBeanFactory.getBean(TestPlanLoadCaseService.class);
this.testPlanService = CommonBeanFactory.getBean(TestPlanService.class); this.testPlanService = CommonBeanFactory.getBean(TestPlanService.class);
@ -63,7 +50,16 @@ public class TestPlanTestJob extends MsScheduleJob {
JobDataMap jobDataMap = context.getJobDetail().getJobDataMap(); JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
String config = jobDataMap.getString("config"); String config = jobDataMap.getString("config");
testPlanService.run(this.resourceId, this.projectID, this.userId, ReportTriggerMode.SCHEDULE.name(),config); String runResourceId = this.resourceId;
String runProjectId = this.projectID;
String runUserId = this.userId;
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
testPlanService.run(runResourceId, runProjectId, runUserId, ReportTriggerMode.SCHEDULE.name(),config);
}
});
thread.run();
} }
public static JobKey getJobKey(String testId) { public static JobKey getJobKey(String testId) {

View File

@ -69,7 +69,8 @@ public class AppStartListener implements ApplicationListener<ApplicationReadyEve
@Value("${jmeter.home}") @Value("${jmeter.home}")
private String jmeterHome; private String jmeterHome;
@Value("${quartz.properties.org.quartz.jobStore.acquireTriggersWithinLock}")
private String acquireTriggersWithinLock;
@Value("${quartz.enabled}") @Value("${quartz.enabled}")
private boolean quartzEnable; private boolean quartzEnable;
@Value("${quartz.scheduler-name}") @Value("${quartz.scheduler-name}")
@ -101,6 +102,7 @@ public class AppStartListener implements ApplicationListener<ApplicationReadyEve
e.printStackTrace(); e.printStackTrace();
} }
LogUtil.info("开始启动定时任务。 相关设置:" + LogUtil.info("开始启动定时任务。 相关设置:" +
"quartz.acquireTriggersWithinLock :" + acquireTriggersWithinLock + "\r\n" +
"quartz.enabled :" + quartzEnable + "\r\n" + "quartz.enabled :" + quartzEnable + "\r\n" +
"quartz.scheduler-name :" + quartzScheduleName + "\r\n" + "quartz.scheduler-name :" + quartzScheduleName + "\r\n" +
"quartz.thread-count :" + quartzThreadCount + "\r\n"); "quartz.thread-count :" + quartzThreadCount + "\r\n");

View File

@ -92,7 +92,8 @@ jmeter.home=/opt/jmeter
# quartz # quartz
quartz.enabled=true quartz.enabled=true
quartz.scheduler-name=msServerJob quartz.scheduler-name=msServerJob
quartz.thread-count=30 quartz.thread-count=60
quartz.properties.org.quartz.jobStore.acquireTriggersWithinLock=true
# file upload # file upload
spring.servlet.multipart.max-file-size=500MB spring.servlet.multipart.max-file-size=500MB
spring.servlet.multipart.max-request-size=500MB spring.servlet.multipart.max-request-size=500MB