Merge remote-tracking branch 'origin/master' into master
This commit is contained in:
commit
5f350ed32e
|
@ -9,7 +9,6 @@ import io.metersphere.api.dto.automation.SaveApiScenarioRequest;
|
|||
import io.metersphere.api.dto.definition.RunDefinitionRequest;
|
||||
import io.metersphere.api.service.ApiAutomationService;
|
||||
import io.metersphere.base.domain.ApiScenario;
|
||||
import io.metersphere.base.domain.Schedule;
|
||||
import io.metersphere.commons.constants.RoleConstants;
|
||||
import io.metersphere.commons.utils.PageUtils;
|
||||
import io.metersphere.commons.utils.Pager;
|
||||
|
@ -20,7 +19,6 @@ import org.springframework.web.bind.annotation.*;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
|
@ -48,16 +46,6 @@ public class ApiAutomationController {
|
|||
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}")
|
||||
public void delete(@PathVariable String id) {
|
||||
apiAutomationService.delete(id);
|
||||
|
|
|
@ -17,14 +17,13 @@ import io.metersphere.base.domain.*;
|
|||
import io.metersphere.base.mapper.ApiScenarioMapper;
|
||||
import io.metersphere.base.mapper.ApiTagMapper;
|
||||
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.utils.LogUtil;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
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.lang3.StringUtils;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
@ -35,7 +34,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
|
@ -58,8 +56,6 @@ public class ApiAutomationService {
|
|||
private ApiTestEnvironmentService environmentService;
|
||||
@Resource
|
||||
private ApiScenarioReportService apiReportService;
|
||||
@Resource
|
||||
private ScheduleService scheduleService;
|
||||
|
||||
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||
|
||||
|
@ -125,27 +121,6 @@ public class ApiAutomationService {
|
|||
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) {
|
||||
checkNameExist(request);
|
||||
List<String> bodyUploadIds = new ArrayList<>(request.getBodyUploadIds());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package io.metersphere.commons.constants;
|
||||
|
||||
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 prop="passRate" :label="$t('api_test.automation.passing_rate')"
|
||||
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}">
|
||||
<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="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>
|
||||
|
||||
</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%">
|
||||
<ms-api-report-detail @refresh="search" :infoDb="infoDb" :report-id="reportId" :currentProjectId="currentProject!=undefined ? currentProject.id:''"/>
|
||||
</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>
|
||||
</el-card>
|
||||
|
||||
|
@ -84,12 +78,12 @@
|
|||
import {getUUID} from "@/common/js/utils";
|
||||
import MsApiReportDetail from "../report/ApiReportDetail";
|
||||
import MsTableMoreBtn from "./TableMoreBtn";
|
||||
import MsScheduleConfig from "../../../common/components/MsScheduleConfig";
|
||||
import MsScheduleEdit from "../../../common/components/MsScheduleEdit";
|
||||
import MsScenarioExtendButtons from "@/business/components/api/automation/scenario/ScenarioExtendBtns";
|
||||
|
||||
|
||||
export default {
|
||||
name: "MsApiScenarioList",
|
||||
components: {ShowMoreBtn, MsTablePagination, MsTableHeader, MsTag, MsApiReportDetail, MsTableMoreBtn, MsScheduleConfig, MsScheduleEdit},
|
||||
components: {MsTablePagination, MsTableMoreBtn, ShowMoreBtn, MsTableHeader, MsTag, MsApiReportDetail, MsScenarioExtendButtons},
|
||||
props: {
|
||||
currentProject: Object,
|
||||
currentModule: Object,
|
||||
|
@ -117,15 +111,6 @@
|
|||
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: {
|
||||
|
|
|
@ -11,28 +11,28 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import MsReferenceView from "@/business/components/api/automation/scenario/ReferenceView";
|
||||
import MsReferenceView from "@/business/components/api/automation/scenario/ReferenceView";
|
||||
|
||||
export default {
|
||||
name: "MsScenarioExtendButtons",
|
||||
components: {MsReferenceView},
|
||||
props: {
|
||||
row: Object
|
||||
},
|
||||
methods: {
|
||||
handleCommand(cmd) {
|
||||
switch (cmd) {
|
||||
case "ref":
|
||||
this.$refs.viewRef.open(this.row);
|
||||
break;
|
||||
}
|
||||
export default {
|
||||
name: "MsScenarioExtendButtons",
|
||||
components: {MsReferenceView},
|
||||
props: {
|
||||
row: Object
|
||||
},
|
||||
methods: {
|
||||
handleCommand(cmd) {
|
||||
switch (cmd) {
|
||||
case "ref":
|
||||
this.$refs.viewRef.open(this.row);
|
||||
break;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.scenario-ext-btn {
|
||||
margin-left: 10px;
|
||||
}
|
||||
.scenario-ext-btn {
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Reference in New Issue