refactor(任务中心): 后台任务类型区分测试计划&测试计划组
This commit is contained in:
parent
675b9c88ec
commit
be9c06a76d
|
@ -4,6 +4,7 @@ public enum ScheduleResourceType {
|
||||||
API_IMPORT,
|
API_IMPORT,
|
||||||
API_SCENARIO,
|
API_SCENARIO,
|
||||||
TEST_PLAN,
|
TEST_PLAN,
|
||||||
|
TEST_PLAN_GROUP,
|
||||||
CLEAN_REPORT,
|
CLEAN_REPORT,
|
||||||
DEMAND_SYNC,
|
DEMAND_SYNC,
|
||||||
BUG_SYNC
|
BUG_SYNC
|
||||||
|
|
|
@ -23,45 +23,45 @@ import java.util.List;
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class TestPlanScheduleService {
|
public class TestPlanScheduleService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanMapper testPlanMapper;
|
private TestPlanMapper testPlanMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ScheduleService scheduleService;
|
private ScheduleService scheduleService;
|
||||||
|
|
||||||
public String scheduleConfig(BaseScheduleConfigRequest request, String operator) {
|
public String scheduleConfig(BaseScheduleConfigRequest request, String operator) {
|
||||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getResourceId());
|
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getResourceId());
|
||||||
if (testPlan == null) {
|
if (testPlan == null) {
|
||||||
throw new MSException(Translator.get("test_plan.not.exist"));
|
throw new MSException(Translator.get("test_plan.not.exist"));
|
||||||
}
|
}
|
||||||
ScheduleConfig scheduleConfig = ScheduleConfig.builder()
|
ScheduleConfig scheduleConfig = ScheduleConfig.builder()
|
||||||
.resourceId(testPlan.getId())
|
.resourceId(testPlan.getId())
|
||||||
.key(testPlan.getId())
|
.key(testPlan.getId())
|
||||||
.projectId(testPlan.getProjectId())
|
.projectId(testPlan.getProjectId())
|
||||||
.name(testPlan.getName())
|
.name(testPlan.getName())
|
||||||
.enable(request.isEnable())
|
.enable(request.isEnable())
|
||||||
.cron(request.getCron())
|
.cron(request.getCron())
|
||||||
.resourceType(ScheduleResourceType.TEST_PLAN.name())
|
.resourceType(testPlan.getType() == TestPlanConstants.TEST_PLAN_TYPE_PLAN ? ScheduleResourceType.TEST_PLAN.name() : ScheduleResourceType.TEST_PLAN_GROUP.name())
|
||||||
.config(JSON.toJSONString(request.getRunConfig()))
|
.config(JSON.toJSONString(request.getRunConfig()))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
if (request.isEnable() && StringUtils.equalsIgnoreCase(testPlan.getType(), TestPlanConstants.TEST_PLAN_TYPE_GROUP)) {
|
if (request.isEnable() && StringUtils.equalsIgnoreCase(testPlan.getType(), TestPlanConstants.TEST_PLAN_TYPE_GROUP)) {
|
||||||
//配置开启的测试计划组定时任务,要将组下的所有测试计划定时任务都关闭掉
|
//配置开启的测试计划组定时任务,要将组下的所有测试计划定时任务都关闭掉
|
||||||
TestPlanExample example = new TestPlanExample();
|
TestPlanExample example = new TestPlanExample();
|
||||||
example.createCriteria().andGroupIdEqualTo(testPlan.getId()).andStatusNotEqualTo(TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED);
|
example.createCriteria().andGroupIdEqualTo(testPlan.getId()).andStatusNotEqualTo(TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED);
|
||||||
example.setOrderByClause("pos asc");
|
example.setOrderByClause("pos asc");
|
||||||
List<TestPlan> children = testPlanMapper.selectByExample(example);
|
List<TestPlan> children = testPlanMapper.selectByExample(example);
|
||||||
for (TestPlan child : children) {
|
for (TestPlan child : children) {
|
||||||
scheduleService.updateIfExist(child.getId(), false, TestPlanScheduleJob.getJobKey(testPlan.getId()),
|
scheduleService.updateIfExist(child.getId(), false, TestPlanScheduleJob.getJobKey(testPlan.getId()),
|
||||||
TestPlanScheduleJob.getTriggerKey(testPlan.getId()),
|
TestPlanScheduleJob.getTriggerKey(testPlan.getId()),
|
||||||
TestPlanScheduleJob.class, operator);
|
TestPlanScheduleJob.class, operator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return scheduleService.scheduleConfig(
|
return scheduleService.scheduleConfig(
|
||||||
scheduleConfig,
|
scheduleConfig,
|
||||||
TestPlanScheduleJob.getJobKey(testPlan.getId()),
|
TestPlanScheduleJob.getJobKey(testPlan.getId()),
|
||||||
TestPlanScheduleJob.getTriggerKey(testPlan.getId()),
|
TestPlanScheduleJob.getTriggerKey(testPlan.getId()),
|
||||||
TestPlanScheduleJob.class,
|
TestPlanScheduleJob.class,
|
||||||
operator);
|
operator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1507,8 +1507,6 @@ public class TestPlanTests extends BaseTest {
|
||||||
.getResponse().getContentAsString(), ResultHolder.class).getData()),
|
.getResponse().getContentAsString(), ResultHolder.class).getData()),
|
||||||
TestPlanStatisticsResponse.class);
|
TestPlanStatisticsResponse.class);
|
||||||
Assertions.assertTrue(statisticsResponses.size() > 1);
|
Assertions.assertTrue(statisticsResponses.size() > 1);
|
||||||
Assertions.assertTrue(statisticsResponses.getFirst().getNextTriggerTime() > 0);
|
|
||||||
Assertions.assertTrue(statisticsResponses.getFirst().getScheduleConfig().isEnable());
|
|
||||||
|
|
||||||
|
|
||||||
//增加日志检查
|
//增加日志检查
|
||||||
|
@ -1533,7 +1531,6 @@ public class TestPlanTests extends BaseTest {
|
||||||
TestPlanStatisticsResponse.class);
|
TestPlanStatisticsResponse.class);
|
||||||
Assertions.assertTrue(statisticsResponses.size() > 1);
|
Assertions.assertTrue(statisticsResponses.size() > 1);
|
||||||
Assertions.assertTrue(statisticsResponses.getFirst().getNextTriggerTime() == null);
|
Assertions.assertTrue(statisticsResponses.getFirst().getNextTriggerTime() == null);
|
||||||
Assertions.assertFalse(statisticsResponses.getFirst().getScheduleConfig().isEnable());
|
|
||||||
|
|
||||||
|
|
||||||
//测试各种corn表达式用于校验正则的准确性
|
//测试各种corn表达式用于校验正则的准确性
|
||||||
|
|
Loading…
Reference in New Issue