diff --git a/frontend/src/business/components/api/definition/components/import/ApiImport.vue b/frontend/src/business/components/api/definition/components/import/ApiImport.vue
index 416619781e..ba08997b69 100644
--- a/frontend/src/business/components/api/definition/components/import/ApiImport.vue
+++ b/frontend/src/business/components/api/definition/components/import/ApiImport.vue
@@ -3,17 +3,17 @@
:visible.sync="visible" class="api-import" v-loading="result.loading" @close="close">
@@ -34,7 +34,7 @@
multiple>
- {{$t('api_test.api_import.file_size_limit')}}
+ {{ $t('api_test.api_import.file_size_limit') }}
@@ -47,15 +47,29 @@
:active-text="$t('api_test.api_import.swagger_url_import')">
+
+
+
+
+ {{ $t('api_test.api_import.next_synchronization_time') }}:
+
+
+
+
@@ -63,217 +77,223 @@
diff --git a/frontend/src/business/components/api/definition/components/import/ImportScheduleEdit.vue b/frontend/src/business/components/api/definition/components/import/ImportScheduleEdit.vue
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js
index 0a040ccbdc..a130114e35 100644
--- a/frontend/src/i18n/en-US.js
+++ b/frontend/src/i18n/en-US.js
@@ -826,6 +826,9 @@ export default {
swagger_export_tip: "Export jSON-formatted files via Swagger website",
suffixFormatErr: "The file format does not meet the requirements",
swagger_url_import: "Import using URL",
+ timing_synchronization:"Timing synchronization",
+ next_synchronization_time:"Next synchronization time",
+
},
home_page: {
unit_of_measurement: "",
diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js
index f507566fde..3e4b8690ac 100644
--- a/frontend/src/i18n/zh-CN.js
+++ b/frontend/src/i18n/zh-CN.js
@@ -827,6 +827,10 @@ export default {
swagger_export_tip: "通过 Swagger 页面导出",
suffixFormatErr: "文件格式不符合要求",
swagger_url_import: "使用URL导入",
+ timing_synchronization:"定时同步",
+ next_synchronization_time:"下次同步时间"
+
+
},
home_page: {
unit_of_measurement: "个",
diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js
index 551d04bc7e..bf03c3aa7e 100644
--- a/frontend/src/i18n/zh-TW.js
+++ b/frontend/src/i18n/zh-TW.js
@@ -827,6 +827,9 @@ export default {
swagger_export_tip: "通過 Swagger 頁面導出",
suffixFormatErr: "文件格式不符合要求",
swagger_url_import: "使用URL導入",
+ timing_synchronization:"定時同步",
+ next_synchronization_time:"下次同步時間",
+
},
home_page: {
unit_of_measurement: "個",
From 73d63ce0723d1ba542edfe1b9fd941a001b686d7 Mon Sep 17 00:00:00 2001
From: chenjianxing
Date: Wed, 20 Jan 2021 13:44:21 +0800
Subject: [PATCH 2/5] =?UTF-8?q?refactor:=20=E7=8E=AF=E5=A2=83=E5=8F=98?=
=?UTF-8?q?=E9=87=8F=E6=B7=BB=E5=8A=A0=E6=8F=8F=E8=BF=B0=E5=92=8C=E5=A4=8D?=
=?UTF-8?q?=E5=88=B6=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../components/ApiScenarioVariables.vue | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/frontend/src/business/components/api/definition/components/ApiScenarioVariables.vue b/frontend/src/business/components/api/definition/components/ApiScenarioVariables.vue
index c4cb506c3a..edda13459d 100644
--- a/frontend/src/business/components/api/definition/components/ApiScenarioVariables.vue
+++ b/frontend/src/business/components/api/definition/components/ApiScenarioVariables.vue
@@ -4,7 +4,7 @@
{{description}}
-
+
@@ -18,6 +18,15 @@
+
+
+
+
+
+
+
@@ -59,6 +68,11 @@
this.items.splice(index, 1);
this.$emit('change', this.items);
},
+ copy: function (item, index) {
+ let copy = {};
+ Object.assign(copy, item);
+ this.items.splice(index + 1, 0, copy);
+ },
change: function () {
let isNeedCreate = true;
let removeIndex = -1;
@@ -105,7 +119,7 @@
margin-top: 10px;
}
- .kv-delete {
+ .kv-delete,.kv-copy {
width: 60px;
}
From 8512f8f2620a32bf26e94398c241ccb9261dfd8d Mon Sep 17 00:00:00 2001
From: wenyann <64353056+wenyann@users.noreply.github.com>
Date: Wed, 20 Jan 2021 13:56:58 +0800
Subject: [PATCH 3/5] =?UTF-8?q?feat:=20swagger=E5=AE=9A=E6=97=B6=E5=90=8C?=
=?UTF-8?q?=E6=AD=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../controller/ApiDefinitionController.java | 7 +-
.../api/jmeter/APIBackendListenerClient.java | 4 -
.../api/service/ApiDefinitionService.java | 30 ++-
.../io/metersphere/base/domain/Schedule.java | 5 +-
.../commons/constants/ScheduleGroup.java | 2 +-
.../job/sechedule/SwaggerUrlImportJob.java | 37 +++
.../metersphere/service/ScheduleService.java | 3 +-
backend/src/main/java/io/metersphere/xpack | 2 +-
.../components/import/ApiImport.vue | 9 +-
.../components/import/ImportScheduleEdit.vue | 213 ++++++++++++++++++
10 files changed, 287 insertions(+), 25 deletions(-)
create mode 100644 backend/src/main/java/io/metersphere/job/sechedule/SwaggerUrlImportJob.java
diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java
index 8ec04b224d..548efbfca9 100644
--- a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java
+++ b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java
@@ -10,6 +10,7 @@ import io.metersphere.api.dto.definition.*;
import io.metersphere.api.dto.definition.parse.ApiDefinitionImport;
import io.metersphere.api.service.ApiDefinitionService;
import io.metersphere.base.domain.ApiDefinition;
+import io.metersphere.base.domain.Schedule;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.json.JSONSchemaGenerator;
import io.metersphere.commons.utils.PageUtils;
@@ -139,6 +140,11 @@ public class ApiDefinitionController {
return apiDefinitionService.apiTestImport(file, request);
}
+ @PostMapping(value = "/schedule/create")
+ public void createSchedule(@RequestBody Schedule request) {
+ apiDefinitionService.createSchedule(request);
+ }
+
@PostMapping("/getReference")
public ReferenceDTO getReference(@RequestBody ApiScenarioRequest request) {
return apiDefinitionService.getReference(request);
@@ -165,5 +171,4 @@ public class ApiDefinitionController {
public String preview(@RequestBody String jsonSchema) {
return JSONSchemaGenerator.getJson(jsonSchema);
}
-
}
diff --git a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java
index 80f77afc5d..bf200a4aa5 100644
--- a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java
+++ b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java
@@ -172,10 +172,6 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
// 调试操作,不需要存储结果
apiDefinitionService.addResult(testResult);
if (StringUtils.isBlank(debugReportId)) {
- if (StringUtils.isBlank(debugReportId)) {
- apiDefinitionService.addResult(testResult);
- } else {
- apiDefinitionService.addResult(testResult);
apiDefinitionExecResultService.saveApiResult(testResult, ApiRunMode.DELIMIT.name());
}
} else if (StringUtils.equalsAny(this.runMode, ApiRunMode.API_PLAN.name(), ApiRunMode.SCHEDULE_API_PLAN.name())) {
diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java
index 380d39c2c3..8588e5a8e5 100644
--- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java
+++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java
@@ -2,19 +2,13 @@ package io.metersphere.api.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
import io.metersphere.api.dto.APIReportResult;
import io.metersphere.api.dto.ApiTestImportRequest;
import io.metersphere.api.dto.automation.ApiScenarioRequest;
import io.metersphere.api.dto.automation.ReferenceDTO;
-import io.metersphere.api.dto.automation.RunScenarioRequest;
import io.metersphere.api.dto.datacount.ApiDataCountResult;
import io.metersphere.api.dto.definition.*;
import io.metersphere.api.dto.definition.parse.ApiDefinitionImport;
-import io.metersphere.api.dto.definition.request.*;
-import io.metersphere.api.dto.definition.request.variable.ScenarioVariable;
import io.metersphere.api.dto.scenario.request.RequestType;
import io.metersphere.api.jmeter.JMeterService;
import io.metersphere.api.jmeter.TestResult;
@@ -30,11 +24,14 @@ import io.metersphere.base.mapper.ext.ExtApiScenarioMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanMapper;
import io.metersphere.commons.constants.APITestStatus;
import io.metersphere.commons.constants.ApiRunMode;
-import io.metersphere.commons.constants.ReportTriggerMode;
+import io.metersphere.commons.constants.ScheduleGroup;
+import io.metersphere.commons.constants.ScheduleType;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.*;
import io.metersphere.i18n.Translator;
+import io.metersphere.job.sechedule.SwaggerUrlImportJob;
import io.metersphere.service.FileService;
+import io.metersphere.service.ScheduleService;
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
import org.apache.commons.collections.CollectionUtils;
@@ -43,9 +40,7 @@ import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.jorphan.collections.HashTree;
-import org.apache.jorphan.collections.ListedHashTree;
import org.aspectj.util.FileUtil;
-import org.aspectj.weaver.ast.Test;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@@ -82,6 +77,8 @@ public class ApiDefinitionService {
private ExtTestPlanMapper extTestPlanMapper;
@Resource
private ProjectMapper projectMapper;
+ @Resource
+ private ScheduleService scheduleService;
private static Cache cache = Cache.newHardMemoryCache(0, 3600 * 24);
@@ -575,4 +572,19 @@ public class ApiDefinitionService {
}
}
}
+
+ /*swagger定时导入*/
+ public void createSchedule(Schedule request) {
+ Schedule schedule = scheduleService.buildApiTestSchedule(request);
+ schedule.setJob(SwaggerUrlImportJob.class.getName());
+ schedule.setGroup(ScheduleGroup.SWAGGER_IMPORT.name());
+ schedule.setType(ScheduleType.CRON.name());
+ scheduleService.addSchedule(schedule);
+ this.addOrUpdateSwaggerImportCronJob(request);
+
+ }
+
+ private void addOrUpdateSwaggerImportCronJob(Schedule request) {
+ scheduleService.addOrUpdateCronJob(request, SwaggerUrlImportJob.getJobKey(request.getResourceId()), SwaggerUrlImportJob.getTriggerKey(request.getResourceId()), SwaggerUrlImportJob.class);
+ }
}
\ No newline at end of file
diff --git a/backend/src/main/java/io/metersphere/base/domain/Schedule.java b/backend/src/main/java/io/metersphere/base/domain/Schedule.java
index 7637d9f699..0dcf9e8966 100644
--- a/backend/src/main/java/io/metersphere/base/domain/Schedule.java
+++ b/backend/src/main/java/io/metersphere/base/domain/Schedule.java
@@ -1,8 +1,9 @@
package io.metersphere.base.domain;
-import java.io.Serializable;
import lombok.Data;
+import java.io.Serializable;
+
@Data
public class Schedule implements Serializable {
private String id;
@@ -35,4 +36,6 @@ public class Schedule implements Serializable {
//定时任务来源: 测试计划/测试场景
private String scheduleFrom;
+
+ private String swaggerUrl;
}
\ No newline at end of file
diff --git a/backend/src/main/java/io/metersphere/commons/constants/ScheduleGroup.java b/backend/src/main/java/io/metersphere/commons/constants/ScheduleGroup.java
index 90b1c5aba7..1d56f1abec 100644
--- a/backend/src/main/java/io/metersphere/commons/constants/ScheduleGroup.java
+++ b/backend/src/main/java/io/metersphere/commons/constants/ScheduleGroup.java
@@ -1,5 +1,5 @@
package io.metersphere.commons.constants;
public enum ScheduleGroup {
- API_TEST, PERFORMANCE_TEST, API_SCENARIO_TEST,TEST_PLAN_TEST
+ API_TEST, PERFORMANCE_TEST, API_SCENARIO_TEST, TEST_PLAN_TEST, SWAGGER_IMPORT
}
diff --git a/backend/src/main/java/io/metersphere/job/sechedule/SwaggerUrlImportJob.java b/backend/src/main/java/io/metersphere/job/sechedule/SwaggerUrlImportJob.java
new file mode 100644
index 0000000000..4cf4fd7479
--- /dev/null
+++ b/backend/src/main/java/io/metersphere/job/sechedule/SwaggerUrlImportJob.java
@@ -0,0 +1,37 @@
+package io.metersphere.job.sechedule;
+
+import io.metersphere.api.dto.ApiTestImportRequest;
+import io.metersphere.api.service.ApiDefinitionService;
+import io.metersphere.commons.constants.ScheduleGroup;
+import io.metersphere.commons.utils.CommonBeanFactory;
+import org.quartz.JobDataMap;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobKey;
+import org.quartz.TriggerKey;
+
+public class SwaggerUrlImportJob extends MsScheduleJob {
+ private ApiDefinitionService apiDefinitionService;
+
+ public SwaggerUrlImportJob() {
+ apiDefinitionService = (ApiDefinitionService) CommonBeanFactory.getBean(ApiDefinitionService.class);
+ }
+
+ @Override
+ void businessExecute(JobExecutionContext context) {
+ JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
+ String resourceId = jobDataMap.getString("resourceId");
+ String swaggerUrl = jobDataMap.getString("swaggerUrl");
+ ApiTestImportRequest request = new ApiTestImportRequest();
+ request.setProjectId(resourceId);
+ request.setSwaggerUrl(swaggerUrl);
+ apiDefinitionService.apiTestImport(null, request);
+ }
+
+ public static JobKey getJobKey(String resourceId) {
+ return new JobKey(resourceId, ScheduleGroup.SWAGGER_IMPORT.name());
+ }
+
+ public static TriggerKey getTriggerKey(String resourceId) {
+ return new TriggerKey(resourceId, ScheduleGroup.SWAGGER_IMPORT.name());
+ }
+}
diff --git a/backend/src/main/java/io/metersphere/service/ScheduleService.java b/backend/src/main/java/io/metersphere/service/ScheduleService.java
index 0b387b9f72..12820f9114 100644
--- a/backend/src/main/java/io/metersphere/service/ScheduleService.java
+++ b/backend/src/main/java/io/metersphere/service/ScheduleService.java
@@ -104,6 +104,7 @@ public class ScheduleService {
public void startEnableSchedules() {
List Schedules = getEnableSchedule();
+
Schedules.forEach(schedule -> {
try {
if (schedule.getEnable()) {
@@ -122,7 +123,7 @@ public class ScheduleService {
public Schedule buildApiTestSchedule(Schedule request) {
Schedule schedule = new Schedule();
schedule.setResourceId(request.getResourceId());
- schedule.setEnable(request.getEnable());
+ schedule.setEnable(true);
schedule.setValue(request.getValue().trim());
schedule.setKey(request.getResourceId());
schedule.setUserId(SessionUtils.getUser().getId());
diff --git a/backend/src/main/java/io/metersphere/xpack b/backend/src/main/java/io/metersphere/xpack
index 36116c1bff..8d5b1ebeab 160000
--- a/backend/src/main/java/io/metersphere/xpack
+++ b/backend/src/main/java/io/metersphere/xpack
@@ -1 +1 @@
-Subproject commit 36116c1bff736377e6b8a3b828c5fa9bd8b2f2f8
+Subproject commit 8d5b1ebeabf5ebaee9ca186087ac8a34cf888518
diff --git a/frontend/src/business/components/api/definition/components/import/ApiImport.vue b/frontend/src/business/components/api/definition/components/import/ApiImport.vue
index ba08997b69..b119b49ad2 100644
--- a/frontend/src/business/components/api/definition/components/import/ApiImport.vue
+++ b/frontend/src/business/components/api/definition/components/import/ApiImport.vue
@@ -47,18 +47,13 @@
:active-text="$t('api_test.api_import.swagger_url_import')">
+
-
- {{ $t('api_test.api_import.next_synchronization_time') }}:
-
-
@@ -155,7 +150,7 @@ export default {
methods: {
scheduleEdit(){
if(this.swaggerSynchronization){
- /* this.$refs.scheduleEdit.open();*/
+ this.$refs.scheduleEdit.open(this.buildParam());
}
},
open(module) {
diff --git a/frontend/src/business/components/api/definition/components/import/ImportScheduleEdit.vue b/frontend/src/business/components/api/definition/components/import/ImportScheduleEdit.vue
index e69de29bb2..e8a74cb502 100644
--- a/frontend/src/business/components/api/definition/components/import/ImportScheduleEdit.vue
+++ b/frontend/src/business/components/api/definition/components/import/ImportScheduleEdit.vue
@@ -0,0 +1,213 @@
+
+
+
+
+
+
+
+
+
+ {{
+ $t('commons.save')
+ }}
+
+
+
+
+ {{ $t('schedule.generate_expression') }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 201b3b8f309ddc4f7c83634df7e0711fc3b1e625 Mon Sep 17 00:00:00 2001
From: chenjianxing
Date: Wed, 20 Jan 2021 14:02:15 +0800
Subject: [PATCH 4/5] =?UTF-8?q?refactor:=20=E5=9C=BA=E6=99=AF=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E6=B7=BB=E5=8A=A0=E7=8A=B6=E6=80=81=E5=88=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../api/automation/scenario/ApiScenarioList.vue | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue
index cb789b2788..dd04068e14 100644
--- a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue
+++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue
@@ -30,10 +30,13 @@
-
-
-
-
+
+
+
+
+
+
@@ -115,10 +118,14 @@
import MsTableSelectAll from "../../../common/components/table/MsTableSelectAll";
import {API_CASE_CONFIGS} from "@/business/components/common/components/search/search-components";
import MsTableOperatorButton from "@/business/components/common/components/MsTableOperatorButton";
+ import PriorityTableItem from "../../../track/common/tableItems/planview/PriorityTableItem";
+ import PlanStatusTableItem from "../../../track/common/tableItems/plan/PlanStatusTableItem";
export default {
name: "MsApiScenarioList",
components: {
+ PlanStatusTableItem,
+ PriorityTableItem,
MsTableSelectAll,
MsTablePagination,
MsTableMoreBtn,
From dd974949e3a8c07fdeffde15831c33fb2b652c38 Mon Sep 17 00:00:00 2001
From: wenyann <64353056+wenyann@users.noreply.github.com>
Date: Wed, 20 Jan 2021 14:07:39 +0800
Subject: [PATCH 5/5] =?UTF-8?q?feat:=20swagger=E5=AE=9A=E6=97=B6=E5=90=8C?=
=?UTF-8?q?=E6=AD=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/io/metersphere/api/service/ApiTestCaseService.java | 2 --
1 file changed, 2 deletions(-)
diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java
index 6164cbc3f6..1d179da506 100644
--- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java
+++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java
@@ -528,8 +528,6 @@ public class ApiTestCaseService {
ApiDefinitionExecResultExample.Criteria criteria = apidefinitionexecresultexample.createCriteria();
criteria.andResourceIdEqualTo(id);
String status = apiDefinitionExecResultMapper.selectByExample(apidefinitionexecresultexample).get(0).getStatus();
- public String getExecResult(String id){
- String status=apiDefinitionExecResultMapper.selectExecResult(id);
return status;
}
}