2025-06-03 11:30:05 +08:00
|
|
|
|
package cd.casic.server;
|
2025-06-02 20:53:53 +08:00
|
|
|
|
|
2025-06-11 09:50:36 +08:00
|
|
|
|
import cd.casic.ci.process.dto.req.stage.StageCreateReq;
|
|
|
|
|
import cd.casic.ci.process.dto.req.task.TaskUpdateReq;
|
2025-06-02 20:53:53 +08:00
|
|
|
|
import cd.casic.ci.process.process.service.stage.StageService;
|
|
|
|
|
import cd.casic.ci.process.process.service.task.TaskService;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import jakarta.annotation.Resource;
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
|
import org.springframework.test.context.ActiveProfiles;
|
|
|
|
|
|
|
|
|
|
@SpringBootTest(classes = {OpsServerApplication.class})
|
|
|
|
|
@ActiveProfiles("local")
|
|
|
|
|
public class TaskTest {
|
|
|
|
|
@Resource
|
|
|
|
|
StageService stageService;
|
|
|
|
|
@Resource
|
|
|
|
|
TaskService taskService;
|
|
|
|
|
// 添加串行任务
|
|
|
|
|
@Test
|
|
|
|
|
public void createStageAndTask1(){
|
|
|
|
|
// 传入一级stageid ,传入task所属二级stageId,因为结合sort 创建task
|
|
|
|
|
String reqStr = "{\n" +
|
|
|
|
|
" \"stageId\": \"716299524129296385\",\n" +
|
|
|
|
|
" \"task\": {\n" +
|
|
|
|
|
" \"taskType\": \"AFL\",\n" +
|
|
|
|
|
" \"taskSort\": 2,\n" +
|
|
|
|
|
" \"stageId\": \"716299524129296386\",\n" +
|
|
|
|
|
" \"taskName\": \"AFL执行\",\n" +
|
|
|
|
|
" \"taskProperties\": {},\n" +
|
|
|
|
|
" \"pipelineId\": \"716299522803896320\"\n" +
|
|
|
|
|
" }\n" +
|
|
|
|
|
"}";
|
|
|
|
|
StageCreateReq req = JSON.parseObject(reqStr,StageCreateReq.class);
|
|
|
|
|
stageService.createStagesOrTask(req);
|
|
|
|
|
}
|
|
|
|
|
// 添加并行任务
|
|
|
|
|
@Test
|
|
|
|
|
public void createStageAndTask2(){
|
|
|
|
|
// 因为添加并行任务添加顺序固定,而且需要创建二级stage所以不传二级stageid,且不传sort
|
|
|
|
|
String reqStr = "{\n" +
|
|
|
|
|
" \"stageId\": \"716299524129296385\",\n" +
|
|
|
|
|
" \"task\": {\n" +
|
|
|
|
|
" \"taskType\": \"AFL\",\n" +
|
|
|
|
|
" \"taskName\": \"AFL执行\",\n" +
|
|
|
|
|
" \"taskProperties\": {},\n" +
|
|
|
|
|
" \"pipelineId\": \"716299522803896320\"\n" +
|
|
|
|
|
" }\n" +
|
|
|
|
|
"}";
|
|
|
|
|
StageCreateReq req = JSON.parseObject(reqStr,StageCreateReq.class);
|
|
|
|
|
stageService.createStagesOrTask(req);
|
|
|
|
|
}
|
|
|
|
|
// 添加阶段并添加task
|
|
|
|
|
@Test
|
|
|
|
|
public void createStageAndTask3(){
|
|
|
|
|
// 添加阶段所以一级stageId 不传,改为传stageSort,因为二级stage,task永远是第一个,所以都taskSort,和二级stage的stageSort都不需要传
|
|
|
|
|
String reqStr = "{\n" +
|
|
|
|
|
" \"stageSort\": 4,\n" +
|
|
|
|
|
" \"task\": {\n" +
|
|
|
|
|
" \"taskType\": \"AFL\",\n" +
|
|
|
|
|
" \"taskName\": \"AFL执行\",\n" +
|
|
|
|
|
" \"taskProperties\": {},\n" +
|
|
|
|
|
" \"pipelineId\": \"716299522803896320\"\n" +
|
|
|
|
|
" }\n" +
|
|
|
|
|
"}";
|
|
|
|
|
StageCreateReq req = JSON.parseObject(reqStr,StageCreateReq.class);
|
|
|
|
|
stageService.createStagesOrTask(req);
|
|
|
|
|
}
|
|
|
|
|
@Test
|
|
|
|
|
public void updateTask(){
|
|
|
|
|
String reqStr = "{\n" +
|
|
|
|
|
" \"id\": \"716299524330622976\",\n" +
|
|
|
|
|
" \"taskType\": \"TEST_CASE_GENERATION\",\n" +
|
|
|
|
|
" \"taskName\": \"测试用例生成\",\n" +
|
|
|
|
|
" \"taskProperties\": {\n" +
|
|
|
|
|
" \"buildScript\": \"cd /home/casic/706/yunqi/CaseGenerator\\nPYTHONPATH=$PWD/src python3 ./src/CaseGenerator/main.py --work-dir ./testdata/libpng/libpng/ --binary ./testdata/libpng/libpng/pngfix --output-dir ../case --count 100\"\n" +
|
|
|
|
|
" }\n" +
|
|
|
|
|
"}";
|
|
|
|
|
TaskUpdateReq req = JSON.parseObject(reqStr, TaskUpdateReq.class);
|
|
|
|
|
taskService.updateTask(req);
|
|
|
|
|
}
|
|
|
|
|
}
|