feat(接口自动化): 去除重合部分功能
This commit is contained in:
parent
3e15d419fb
commit
d3040ee9df
|
@ -9,7 +9,6 @@ import io.metersphere.api.dto.automation.SaveApiScenarioRequest;
|
||||||
import io.metersphere.api.dto.definition.RunDefinitionRequest;
|
import io.metersphere.api.dto.definition.RunDefinitionRequest;
|
||||||
import io.metersphere.api.service.ApiAutomationService;
|
import io.metersphere.api.service.ApiAutomationService;
|
||||||
import io.metersphere.base.domain.ApiScenario;
|
import io.metersphere.base.domain.ApiScenario;
|
||||||
import io.metersphere.base.domain.Schedule;
|
|
||||||
import io.metersphere.commons.constants.RoleConstants;
|
import io.metersphere.commons.constants.RoleConstants;
|
||||||
import io.metersphere.commons.utils.PageUtils;
|
import io.metersphere.commons.utils.PageUtils;
|
||||||
import io.metersphere.commons.utils.Pager;
|
import io.metersphere.commons.utils.Pager;
|
||||||
|
@ -20,7 +19,6 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -48,16 +46,6 @@ public class ApiAutomationController {
|
||||||
apiAutomationService.update(request, bodyFiles);
|
apiAutomationService.update(request, bodyFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/schedule/update")
|
|
||||||
public void updateSchedule(@RequestBody Schedule schedule) {
|
|
||||||
apiAutomationService.updateSchedule(schedule);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping(value = "/schedule/create")
|
|
||||||
public void createSchedule(@RequestBody Schedule schedule) {
|
|
||||||
apiAutomationService.createSchedule(schedule);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/delete/{id}")
|
@GetMapping("/delete/{id}")
|
||||||
public void delete(@PathVariable String id) {
|
public void delete(@PathVariable String id) {
|
||||||
apiAutomationService.delete(id);
|
apiAutomationService.delete(id);
|
||||||
|
|
|
@ -17,14 +17,13 @@ import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.ApiScenarioMapper;
|
import io.metersphere.base.mapper.ApiScenarioMapper;
|
||||||
import io.metersphere.base.mapper.ApiTagMapper;
|
import io.metersphere.base.mapper.ApiTagMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtApiScenarioMapper;
|
import io.metersphere.base.mapper.ext.ExtApiScenarioMapper;
|
||||||
import io.metersphere.commons.constants.*;
|
import io.metersphere.commons.constants.APITestStatus;
|
||||||
|
import io.metersphere.commons.constants.ApiRunMode;
|
||||||
|
import io.metersphere.commons.constants.ReportTriggerMode;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
import io.metersphere.commons.utils.SessionUtils;
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
import io.metersphere.i18n.Translator;
|
import io.metersphere.i18n.Translator;
|
||||||
import io.metersphere.job.sechedule.ApiTestJob;
|
|
||||||
import io.metersphere.job.sechedule.ScenarioJob;
|
|
||||||
import io.metersphere.service.ScheduleService;
|
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.jorphan.collections.HashTree;
|
import org.apache.jorphan.collections.HashTree;
|
||||||
|
@ -35,7 +34,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -58,8 +56,6 @@ public class ApiAutomationService {
|
||||||
private ApiTestEnvironmentService environmentService;
|
private ApiTestEnvironmentService environmentService;
|
||||||
@Resource
|
@Resource
|
||||||
private ApiScenarioReportService apiReportService;
|
private ApiScenarioReportService apiReportService;
|
||||||
@Resource
|
|
||||||
private ScheduleService scheduleService;
|
|
||||||
|
|
||||||
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||||
|
|
||||||
|
@ -125,27 +121,6 @@ public class ApiAutomationService {
|
||||||
createBodyFiles(bodyUploadIds, bodyFiles);
|
createBodyFiles(bodyUploadIds, bodyFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Schedule buildApiTestSchedule(Schedule request) {
|
|
||||||
Schedule schedule = scheduleService.buildApiTestSchedule(request);
|
|
||||||
schedule.setJob(ScenarioJob.class.getName());
|
|
||||||
schedule.setGroup(ScheduleGroup.SCENARIO_TEST.name());
|
|
||||||
schedule.setType(ScheduleType.CRON.name());
|
|
||||||
return schedule;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addOrUpdateApiTestCronJob(Schedule request) {
|
|
||||||
scheduleService.addOrUpdateCronJob(request, ApiTestJob.getJobKey(request.getResourceId()), ApiTestJob.getTriggerKey(request.getResourceId()), ApiTestJob.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateSchedule(Schedule schedule) {
|
|
||||||
scheduleService.addSchedule(buildApiTestSchedule(schedule));
|
|
||||||
addOrUpdateApiTestCronJob(schedule);
|
|
||||||
}
|
|
||||||
public void createSchedule(Schedule request) {
|
|
||||||
scheduleService.addSchedule(buildApiTestSchedule(request));
|
|
||||||
addOrUpdateApiTestCronJob(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(SaveApiScenarioRequest request, List<MultipartFile> bodyFiles) {
|
public void update(SaveApiScenarioRequest request, List<MultipartFile> bodyFiles) {
|
||||||
checkNameExist(request);
|
checkNameExist(request);
|
||||||
List<String> bodyUploadIds = new ArrayList<>(request.getBodyUploadIds());
|
List<String> bodyUploadIds = new ArrayList<>(request.getBodyUploadIds());
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package io.metersphere.commons.constants;
|
package io.metersphere.commons.constants;
|
||||||
|
|
||||||
public enum ScheduleGroup {
|
public enum ScheduleGroup {
|
||||||
API_TEST, PERFORMANCE_TEST,SCENARIO_TEST
|
API_TEST, PERFORMANCE_TEST
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
package io.metersphere.job.sechedule;
|
|
||||||
|
|
||||||
import io.metersphere.api.dto.automation.RunScenarioRequest;
|
|
||||||
import io.metersphere.api.service.ApiAutomationService;
|
|
||||||
import io.metersphere.commons.constants.ReportTriggerMode;
|
|
||||||
import io.metersphere.commons.constants.ScheduleGroup;
|
|
||||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
|
||||||
import org.quartz.JobExecutionContext;
|
|
||||||
import org.quartz.JobKey;
|
|
||||||
import org.quartz.TriggerKey;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
public class ScenarioJob extends MsScheduleJob {
|
|
||||||
|
|
||||||
ApiAutomationService apiAutomationService;
|
|
||||||
|
|
||||||
public ScenarioJob() {
|
|
||||||
apiAutomationService = (ApiAutomationService) CommonBeanFactory.getBean(ApiAutomationService.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
void businessExecute(JobExecutionContext context) {
|
|
||||||
RunScenarioRequest request = new RunScenarioRequest();
|
|
||||||
request.setId(resourceId);
|
|
||||||
List<String> ids = new ArrayList<>();
|
|
||||||
ids.add(resourceId);
|
|
||||||
request.setScenarioIds(ids);
|
|
||||||
request.setTriggerMode(ReportTriggerMode.SCHEDULE.name());
|
|
||||||
apiAutomationService.run(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JobKey getJobKey(String testId) {
|
|
||||||
return new JobKey(testId, ScheduleGroup.SCENARIO_TEST.name());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TriggerKey getTriggerKey(String testId) {
|
|
||||||
return new TriggerKey(testId, ScheduleGroup.SCENARIO_TEST.name());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -45,12 +45,13 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="passRate" :label="$t('api_test.automation.passing_rate')"
|
<el-table-column prop="passRate" :label="$t('api_test.automation.passing_rate')"
|
||||||
show-overflow-tooltip/>
|
show-overflow-tooltip/>
|
||||||
<el-table-column :label="$t('commons.operating')" width="160">
|
<el-table-column :label="$t('commons.operating')" width="200px">
|
||||||
<template v-slot:default="{row}">
|
<template v-slot:default="{row}">
|
||||||
<el-button type="text" @click="edit(row)">{{ $t('api_test.automation.edit') }}</el-button>
|
<el-button type="text" @click="edit(row)">{{ $t('api_test.automation.edit') }}</el-button>
|
||||||
<el-button type="text" @click="execute(row)">{{ $t('api_test.automation.execute') }}</el-button>
|
<el-button type="text" @click="execute(row)">{{ $t('api_test.automation.execute') }}</el-button>
|
||||||
<el-button type="text" @click="copy(row)">{{ $t('api_test.automation.copy') }}</el-button>
|
<el-button type="text" @click="copy(row)">{{ $t('api_test.automation.copy') }}</el-button>
|
||||||
<ms-table-more-btn :is-show="true" :row="row" :buttons="tableButtons"/>
|
<el-button type="text" @click="remove(row)">{{ $t('api_test.automation.remove') }}</el-button>
|
||||||
|
<ms-scenario-extend-buttons :row="row"/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
@ -63,13 +64,6 @@
|
||||||
<el-drawer :visible.sync="runVisible" :destroy-on-close="true" direction="ltr" :withHeader="false" :title="$t('test_track.plan_view.test_result')" :modal="false" size="90%">
|
<el-drawer :visible.sync="runVisible" :destroy-on-close="true" direction="ltr" :withHeader="false" :title="$t('test_track.plan_view.test_result')" :modal="false" size="90%">
|
||||||
<ms-api-report-detail @refresh="search" :infoDb="infoDb" :report-id="reportId" :currentProjectId="currentProject!=undefined ? currentProject.id:''"/>
|
<ms-api-report-detail @refresh="search" :infoDb="infoDb" :report-id="reportId" :currentProjectId="currentProject!=undefined ? currentProject.id:''"/>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
|
|
||||||
<!--定时任务-->
|
|
||||||
<!--<ms-schedule-config :schedule="currentScenario.schedule" :is-read-only="false" :save="saveCronExpression"-->
|
|
||||||
<!--@scheduleChange="saveSchedule" :test-id="currentScenario.id" :check-open="checkScheduleEdit"/>-->
|
|
||||||
<ms-schedule-edit :is-read-only="false" :schedule="schedule" :test-id="currentScenario.id" :save="saveCronExpression"
|
|
||||||
ref="scheduleEdit"/>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
|
@ -84,12 +78,12 @@
|
||||||
import {getUUID} from "@/common/js/utils";
|
import {getUUID} from "@/common/js/utils";
|
||||||
import MsApiReportDetail from "../report/ApiReportDetail";
|
import MsApiReportDetail from "../report/ApiReportDetail";
|
||||||
import MsTableMoreBtn from "./TableMoreBtn";
|
import MsTableMoreBtn from "./TableMoreBtn";
|
||||||
import MsScheduleConfig from "../../../common/components/MsScheduleConfig";
|
import MsScenarioExtendButtons from "@/business/components/api/automation/scenario/ScenarioExtendBtns";
|
||||||
import MsScheduleEdit from "../../../common/components/MsScheduleEdit";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsApiScenarioList",
|
name: "MsApiScenarioList",
|
||||||
components: {ShowMoreBtn, MsTablePagination, MsTableHeader, MsTag, MsApiReportDetail, MsTableMoreBtn, MsScheduleConfig, MsScheduleEdit},
|
components: {MsTablePagination, MsTableMoreBtn, ShowMoreBtn, MsTableHeader, MsTag, MsApiReportDetail, MsScenarioExtendButtons},
|
||||||
props: {
|
props: {
|
||||||
currentProject: Object,
|
currentProject: Object,
|
||||||
currentModule: Object,
|
currentModule: Object,
|
||||||
|
@ -117,15 +111,6 @@
|
||||||
name: this.$t('api_test.automation.batch_execute'), handleClick: this.handleBatchExecute
|
name: this.$t('api_test.automation.batch_execute'), handleClick: this.handleBatchExecute
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
tableButtons: [
|
|
||||||
{
|
|
||||||
name: this.$t('api_test.automation.remove'), handleClick: this.remove
|
|
||||||
}, {
|
|
||||||
name: '查看引用', handleClick: this.handleQuote
|
|
||||||
}, {
|
|
||||||
name: this.$t('commons.trigger_mode.schedule'), handleClick: this.handleSchedule
|
|
||||||
}
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|
|
@ -11,28 +11,28 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MsReferenceView from "@/business/components/api/automation/scenario/ReferenceView";
|
import MsReferenceView from "@/business/components/api/automation/scenario/ReferenceView";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsScenarioExtendButtons",
|
name: "MsScenarioExtendButtons",
|
||||||
components: {MsReferenceView},
|
components: {MsReferenceView},
|
||||||
props: {
|
props: {
|
||||||
row: Object
|
row: Object
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
handleCommand(cmd) {
|
|
||||||
switch (cmd) {
|
|
||||||
case "ref":
|
|
||||||
this.$refs.viewRef.open(this.row);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
handleCommand(cmd) {
|
||||||
|
switch (cmd) {
|
||||||
|
case "ref":
|
||||||
|
this.$refs.viewRef.open(this.row);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.scenario-ext-btn {
|
.scenario-ext-btn {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue