This commit is contained in:
chenjianxing 2021-01-28 14:10:59 +08:00
commit b87d046dca
6 changed files with 41 additions and 8 deletions

View File

@ -217,7 +217,7 @@ public class ApiAutomationService {
ids.add(scenarioId);
deleteApiScenarioReport(ids);
scheduleService.deleteByResourceId(scenarioId);
scheduleService.deleteScheduleAndJobByResourceId(scenarioId,ScheduleGroup.API_SCENARIO_TEST.name());
TestPlanApiScenarioExample example = new TestPlanApiScenarioExample();
example.createCriteria().andApiScenarioIdEqualTo(scenarioId);
List<TestPlanApiScenario> testPlanApiScenarioList = testPlanApiScenarioMapper.selectByExample(example);
@ -282,6 +282,10 @@ public class ApiAutomationService {
public void removeToGc(List<String> apiIds) {
extApiScenarioMapper.removeToGc(apiIds);
//将这些场景的定时任务删除掉
for (String id : apiIds) {
scheduleService.deleteScheduleAndJobByResourceId(id,ScheduleGroup.API_SCENARIO_TEST.name());
}
}
public void reduction(List<SaveApiScenarioRequest> requests) {

View File

@ -33,5 +33,4 @@ public interface ScheduleMapper {
int updateByPrimaryKeyWithBLOBs(Schedule record);
int updateByPrimaryKey(Schedule record);
}

View File

@ -53,14 +53,14 @@ public class MailService {
props.put("mail.smtp.starttls.enable", result);
props.put("mail.smtp.starttls.required", result);
break;
case "smtp.anon":
/* case "smtp.anon":
boolean isAnon = BooleanUtils.toBoolean(p.getParamValue());
if (isAnon) {
props.put("mail.smtp.auth", "false");
javaMailSender.setUsername(null);
javaMailSender.setPassword(null);
}
break;
break;*/
default:
break;
}

View File

@ -18,10 +18,7 @@ import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.OrderRequest;
import io.metersphere.controller.request.QueryScheduleRequest;
import io.metersphere.dto.ScheduleDao;
import io.metersphere.job.sechedule.ApiScenarioTestJob;
import io.metersphere.job.sechedule.ApiTestJob;
import io.metersphere.job.sechedule.ScheduleManager;
import io.metersphere.job.sechedule.TestPlanTestJob;
import io.metersphere.job.sechedule.*;
import org.apache.commons.lang3.StringUtils;
import org.quartz.JobKey;
import org.quartz.SchedulerException;
@ -98,6 +95,25 @@ public class ScheduleService {
return scheduleMapper.deleteByExample(scheduleExample);
}
public int deleteScheduleAndJobByResourceId(String resourceId,String group) {
ScheduleExample scheduleExample = new ScheduleExample();
scheduleExample.createCriteria().andResourceIdEqualTo(resourceId);
removeJob(resourceId,group);
return scheduleMapper.deleteByExample(scheduleExample);
}
public void removeJob(String resourceId,String group) {
if(StringUtils.equals(ScheduleGroup.API_SCENARIO_TEST.name(),group)){
scheduleManager.removeJob(ApiScenarioTestJob.getJobKey(resourceId), ApiScenarioTestJob.getTriggerKey(resourceId));
}else if(StringUtils.equals(ScheduleGroup.TEST_PLAN_TEST.name(),group)){
scheduleManager.removeJob(TestPlanTestJob.getJobKey(resourceId), TestPlanTestJob.getTriggerKey(resourceId));
}else if(StringUtils.equals(ScheduleGroup.SWAGGER_IMPORT.name(),group)){
scheduleManager.removeJob(SwaggerUrlImportJob.getJobKey(resourceId), SwaggerUrlImportJob.getTriggerKey(resourceId));
}else{
scheduleManager.removeJob(ApiTestJob.getJobKey(resourceId), ApiTestJob.getTriggerKey(resourceId));
}
}
public List<Schedule> listSchedule() {
ScheduleExample example = new ScheduleExample();
return scheduleMapper.selectByExample(example);

View File

@ -28,6 +28,7 @@ import io.metersphere.dto.BaseSystemConfigDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.notice.sender.NoticeModel;
import io.metersphere.notice.service.NoticeSendService;
import io.metersphere.service.ScheduleService;
import io.metersphere.service.SystemParameterService;
import io.metersphere.track.Factory.ReportComponentFactory;
import io.metersphere.track.domain.ReportComponent;
@ -62,6 +63,8 @@ public class TestPlanService {
@Resource
ExtTestPlanMapper extTestPlanMapper;
@Resource
ScheduleService scheduleService;
@Resource
ExtTestPlanTestCaseMapper extTestPlanTestCaseMapper;
@Resource
TestCaseMapper testCaseMapper;
@ -315,6 +318,10 @@ public class TestPlanService {
testPlanProjectService.deleteTestPlanProjectByPlanId(planId);
testPlanApiCaseService.deleteByPlanId(planId);
testPlanScenarioCaseService.deleteByPlanId(planId);
//删除定时任务
scheduleService.deleteScheduleAndJobByResourceId(planId,ScheduleGroup.TEST_PLAN_TEST.name());
int num = testPlanMapper.deleteByPrimaryKey(planId);
List<String> relatedUsers = new ArrayList<>();
AddTestPlanRequest testPlans = new AddTestPlanRequest();

View File

@ -235,15 +235,22 @@
this.$refs.environmentConfig.open(getCurrentProjectID());
},
initDataSource() {
let flag = false;
for (let i in this.environments) {
if (this.environments[i].id === this.request.environmentId) {
this.databaseConfigsOptions = [];
this.environments[i].config.databaseConfigs.forEach(item => {
if (item.id === this.request.dataSourceId) {
flag = true;
}
this.databaseConfigsOptions.push(item);
});
break;
}
}
if (!flag) {
this.request.dataSourceId = undefined;
}
},
setDataSource() {
for (let item of this.databaseConfigsOptions) {