Merge remote-tracking branch 'origin/master'

This commit is contained in:
Captain.B 2021-03-24 17:01:36 +08:00
commit 95be5207b2
21 changed files with 204 additions and 162 deletions

View File

@ -84,7 +84,9 @@ public class MsTCPSampler extends MsTestElement {
this.setProjectId(config.getProjectId());
config.setConfig(getEnvironmentConfig(useEnvironment));
}
if(config.getConfig()!=null){
parseEnvironment(config.getConfig().get(this.projectId));
}
// 添加环境中的公共变量
Arguments arguments = this.addArguments(config);

View File

@ -20,4 +20,5 @@ public class ApiDocumentRequest {
private String type;
private String orderCondition;
private List<String> apiIdList;
private boolean trashEnable;
}

View File

@ -5,7 +5,6 @@ import io.metersphere.api.service.*;
import io.metersphere.base.domain.ApiDefinitionExecResult;
import io.metersphere.base.domain.ApiScenarioReport;
import io.metersphere.base.domain.ApiTestReport;
import io.metersphere.base.domain.TestPlanReport;
import io.metersphere.commons.constants.*;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil;
@ -15,7 +14,6 @@ import io.metersphere.notice.sender.NoticeModel;
import io.metersphere.notice.service.NoticeSendService;
import io.metersphere.service.SystemParameterService;
import io.metersphere.track.service.TestPlanReportService;
import io.metersphere.track.service.TestPlanService;
import io.metersphere.track.service.TestPlanTestCaseService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -206,7 +204,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
} else {
apiDefinitionExecResultService.saveApiResult(testResult, ApiRunMode.API_PLAN.name());
}
} else if (StringUtils.equalsAny(this.runMode, ApiRunMode.SCENARIO.name(), ApiRunMode.SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name())) {
} else if (StringUtils.equalsAny(this.runMode, ApiRunMode.SCENARIO.name(), ApiRunMode.SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(),ApiRunMode.SCHEDULE_SCENARIO.name())) {
// 执行报告不需要存储由用户确认后在存储
testResult.setTestId(testId);
ApiScenarioReport scenarioReport = apiScenarioReportService.complete(testResult, this.runMode);

View File

@ -269,6 +269,9 @@ public class ApiAutomationService {
}
private void deleteApiScenarioReport(List<String> scenarioIds) {
if(scenarioIds == null || scenarioIds.isEmpty()){
return;
}
ApiScenarioReportExample scenarioReportExample = new ApiScenarioReportExample();
scenarioReportExample.createCriteria().andScenarioIdIn(scenarioIds);
List<ApiScenarioReport> list = apiScenarioReportMapper.selectByExample(scenarioReportExample);

View File

@ -149,10 +149,11 @@ public class ApiTestCaseService {
public ApiTestCaseWithBLOBs get(String id) {
// ApiTestCaseWithBLOBs returnBlobs = apiTestCaseMapper.selectByPrimaryKey(id);
ApiTestCaseInfo model = extApiTestCaseMapper.selectApiCaseInfoByPrimaryKey(id);
if(model != null ){
if(StringUtils.equalsIgnoreCase(model.getApiMethod(),"esb")){
esbApiParamService.handleApiEsbParams(model);
}
}
return model;
}

View File

@ -2,7 +2,13 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.base.mapper.ext.ExtApiDocumentMapper">
<select id="findApiDocumentSimpleInfoByRequest" resultType="io.metersphere.api.dto.document.ApiDocumentInfoDTO">
SELECT api.id,api.name FROM Api_definition api WHERE api.protocol = 'HTTP' AND api.status != 'Trash'
SELECT api.id,api.name FROM Api_definition api WHERE api.protocol = 'HTTP'
<if test="request.trashEnable == true">
AND api.status = 'Trash'
</if>
<if test="request.trashEnable == false">
AND api.status != 'Trash'
</if>
<if test="request.projectId != null">
AND api.project_Id = #{request.projectId}
</if>

View File

@ -1,5 +1,5 @@
package io.metersphere.commons.constants;
public enum ApiRunMode {
RUN, DEBUG, DEFINITION, SCENARIO, API_PLAN, JENKINS_API_PLAN, JENKINS, SCENARIO_PLAN, API, SCHEDULE_API_PLAN, SCHEDULE_SCENARIO_PLAN, SCHEDULE_PERFORMANCE_TEST
RUN, DEBUG, DEFINITION, SCENARIO, API_PLAN, JENKINS_API_PLAN, JENKINS, SCENARIO_PLAN, API, SCHEDULE_API_PLAN, SCHEDULE_SCENARIO,SCHEDULE_SCENARIO_PLAN, SCHEDULE_PERFORMANCE_TEST
}

View File

@ -3,6 +3,7 @@ package io.metersphere.job.sechedule;
import io.metersphere.api.dto.automation.ExecuteType;
import io.metersphere.api.dto.automation.RunScenarioRequest;
import io.metersphere.api.service.ApiAutomationService;
import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.constants.ScheduleGroup;
import io.metersphere.commons.utils.CommonBeanFactory;
@ -58,6 +59,7 @@ public class ApiScenarioTestJob extends MsScheduleJob {
request.setExecuteType(ExecuteType.Saved.name());
request.setIds(this.scenarioIds);
request.setReportUserID(this.userId);
request.setRunMode(ApiRunMode.SCHEDULE_SCENARIO.name());
apiAutomationService.run(request);
}

View File

@ -611,6 +611,9 @@ public class TestPlanService {
List<ReportComponent> components = ReportComponentFactory.createComponents(componentIds.toJavaList(String.class), testPlan);
List<Issues> issues = buildFunctionalCaseReport(planId, components);
buildApiCaseReport(planId, components);
buildScenarioCaseReport(planId, components);
buildLoadCaseReport(planId, components);
TestCaseReportMetricDTO testCaseReportMetricDTO = new TestCaseReportMetricDTO();
components.forEach(component -> {

View File

@ -268,7 +268,7 @@
if (api) {
let data = JSON.parse(JSON.stringify(api));
data.id = getUUID();
this.httpForm = {id: data.id, name: data.name, protocol: data.protocol, path: data.path, method: REQ_METHOD[0].id, userId: getCurrentUser().id, request: data};
this.httpForm = {id: data.id, name: data.name, protocol: data.protocol, path: data.path, method: api.method, userId: getCurrentUser().id, request: data};
this.getMaintainerOptions();
this.list(data);
this.httpVisible = true;

View File

@ -69,6 +69,7 @@
<api-documents-page class="api-doc-page"
v-if="activeDom==='right'"
:project-id="projectId"
:trash-enable="trashEnable"
:module-ids="selectNodeIds"/>
</ms-tab-button>
<!-- 添加/编辑测试窗口-->
@ -81,13 +82,13 @@
</div>
<!-- 快捷调试 -->
<div v-else-if="item.type=== 'debug'" class="ms-api-div">
<ms-debug-http-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi"
<ms-debug-http-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi" @refreshModule="refreshModule"
v-if="currentProtocol==='HTTP'"/>
<ms-debug-jdbc-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi"
<ms-debug-jdbc-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi" @refreshModule="refreshModule"
v-if="currentProtocol==='SQL'"/>
<ms-debug-tcp-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi"
<ms-debug-tcp-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi" @refreshModule="refreshModule"
v-if="currentProtocol==='TCP'"/>
<ms-debug-dubbo-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi"
<ms-debug-dubbo-page :currentProtocol="currentProtocol" :testCase="item.api" @saveAs="editApi" @refreshModule="refreshModule"
v-if="currentProtocol==='DUBBO'"/>
</div>
@ -356,6 +357,9 @@
}
this.$refs.apiList[0].exportApi(type);
},
refreshModule() {
this.$refs.nodeTree.list();
},
refresh(data) {
this.$refs.apiList[0].initTable(data);
},

View File

@ -278,6 +278,7 @@
let url = '/api/module/getModuleByName/' + getCurrentProjectID() + "/" + this.api.protocol;
this.$get(url, response => {
if (response.data) {
this.$emit('refreshModule');
this.saveApi(row, response.data);
}
});
@ -332,6 +333,10 @@
row.id = data.id;
row.createTime = data.createTime;
row.updateTime = data.updateTime;
if (!row.message) {
this.$success(this.$t('commons.save_success'));
this.$emit('refresh');
}
});
},
saveTestCase(row) {

View File

@ -25,6 +25,7 @@
<api-case-item v-loading="singleLoading && singleRunId === item.id || batchLoadingIds.indexOf(item.id) > -1"
@refresh="refresh"
@singleRun="singleRun"
@refreshModule="refreshModule"
@copyCase="copyCase"
@showExecResult="showExecResult"
@batchEditCase="batchEditCase"
@ -181,7 +182,9 @@
this.apiCaseList = [];
this.visible = false;
},
refreshModule(){
this.$emit('refreshModule');
},
runRefresh() {
this.batchLoadingIds = [];
this.singleLoading = false;

View File

@ -30,25 +30,25 @@
<el-button style="float: right;margin: 20px" type="primary" @click="handleCommand('save_as_api')"> {{$t('commons.save')}}</el-button>
</div>
<!-- 加载用例 -->
<ms-api-case-list :loaded="false" ref="caseList"/>
<ms-api-case-list @refreshModule="refreshModule" :loaded="false" ref="caseList"/>
</div>
</template>
<script>
import MsResponseResult from "../response/ResponseResult";
import MsRequestMetric from "../response/RequestMetric";
import {getUUID} from "@/common/js/utils";
import MsResponseText from "../response/ResponseText";
import MsRun from "../Run";
import {createComponent} from "../jmeter/components";
import {REQ_METHOD} from "../../model/JsonData";
import MsRequestResultTail from "../response/RequestResultTail";
import MsBasisParameters from "../request/dubbo/BasisParameters";
import MsJmxStep from "../step/JmxStep";
import MsApiCaseList from "../case/ApiCaseList";
import MsResponseResult from "../response/ResponseResult";
import MsRequestMetric from "../response/RequestMetric";
import {getUUID} from "@/common/js/utils";
import MsResponseText from "../response/ResponseText";
import MsRun from "../Run";
import {createComponent} from "../jmeter/components";
import {REQ_METHOD} from "../../model/JsonData";
import MsRequestResultTail from "../response/RequestResultTail";
import MsBasisParameters from "../request/dubbo/BasisParameters";
import MsJmxStep from "../step/JmxStep";
import MsApiCaseList from "../case/ApiCaseList";
export default {
export default {
name: "ApiConfig",
components: {
MsRequestResultTail,
@ -122,7 +122,9 @@ export default {
this.runDebug();
}
},
refreshModule() {
this.$emit('refreshModule');
},
runDebug() {
this.loading = true;
this.request.name = getUUID().substring(0, 8);

View File

@ -44,25 +44,25 @@
<el-button style="float: right;margin: 20px" type="primary" @click="handleCommand('save_as_api')"> {{$t('commons.save')}}</el-button>
</div>
<!-- 加载用例 -->
<ms-api-case-list :loaded="false" ref="caseList"/>
<ms-api-case-list @refreshModule="refreshModule" :loaded="false" ref="caseList"/>
</div>
</template>
<script>
import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
import MsResponseResult from "../response/ResponseResult";
import MsRequestMetric from "../response/RequestMetric";
import {getCurrentUser, getUUID} from "@/common/js/utils";
import MsResponseText from "../response/ResponseText";
import MsRun from "../Run";
import {createComponent} from "../jmeter/components";
import {REQ_METHOD} from "../../model/JsonData";
import MsRequestResultTail from "../response/RequestResultTail";
import MsJmxStep from "../step/JmxStep";
import {KeyValue} from "../../model/ApiTestModel";
import MsApiCaseList from "../case/ApiCaseList";
import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
import MsResponseResult from "../response/ResponseResult";
import MsRequestMetric from "../response/RequestMetric";
import {getCurrentUser, getUUID} from "@/common/js/utils";
import MsResponseText from "../response/ResponseText";
import MsRun from "../Run";
import {createComponent} from "../jmeter/components";
import {REQ_METHOD} from "../../model/JsonData";
import MsRequestResultTail from "../response/RequestResultTail";
import MsJmxStep from "../step/JmxStep";
import {KeyValue} from "../../model/ApiTestModel";
import MsApiCaseList from "../case/ApiCaseList";
export default {
export default {
name: "ApiConfig",
components: {
MsRequestResultTail,
@ -166,6 +166,9 @@ export default {
}
})
},
refreshModule() {
this.$emit('refreshModule');
},
runRefresh(data) {
this.responseData = data;
this.loading = false;

View File

@ -32,26 +32,26 @@
<el-button style="float: right;margin: 20px" type="primary" @click="handleCommand('save_as_api')"> {{$t('commons.save')}}</el-button>
</div>
<!-- 加载用例 -->
<ms-api-case-list :loaded="false" ref="caseList"/>
<ms-api-case-list @refreshModule="refreshModule" :loaded="false" ref="caseList"/>
</div>
</template>
<script>
import MsResponseResult from "../response/ResponseResult";
import MsRequestMetric from "../response/RequestMetric";
import {getUUID} from "@/common/js/utils";
import MsResponseText from "../response/ResponseText";
import MsRun from "../Run";
import {createComponent} from "../jmeter/components";
import {REQ_METHOD} from "../../model/JsonData";
import MsRequestResultTail from "../response/RequestResultTail";
import MsBasisParameters from "../request/database/BasisParameters";
import MsJmxStep from "../step/JmxStep";
import MsApiCaseList from "../case/ApiCaseList";
import MsResponseResult from "../response/ResponseResult";
import MsRequestMetric from "../response/RequestMetric";
import {getUUID} from "@/common/js/utils";
import MsResponseText from "../response/ResponseText";
import MsRun from "../Run";
import {createComponent} from "../jmeter/components";
import {REQ_METHOD} from "../../model/JsonData";
import MsRequestResultTail from "../response/RequestResultTail";
import MsBasisParameters from "../request/database/BasisParameters";
import MsJmxStep from "../step/JmxStep";
import MsApiCaseList from "../case/ApiCaseList";
export default {
export default {
name: "ApiConfig",
components: {
MsRequestResultTail,
@ -125,7 +125,9 @@ export default {
this.$refs['requestForm'].validate();
}
},
refreshModule() {
this.$emit('refreshModule');
},
runDebug() {
this.loading = true;
this.request.name = getUUID().substring(0, 8);

View File

@ -42,27 +42,27 @@
<el-button style="float: right;margin: 20px" type="primary" @click="handleCommand('save_as_api')"> {{$t('commons.save')}}</el-button>
</div>
<!-- 加载用例 -->
<ms-api-case-list :loaded="false" ref="caseList"/>
<ms-api-case-list @refreshModule="refreshModule" :loaded="false" ref="caseList"/>
</div>
</template>
<script>
import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
import MsResponseResult from "../response/ResponseResult";
import MsRequestMetric from "../response/RequestMetric";
import {getUUID} from "@/common/js/utils";
import MsResponseText from "../response/ResponseText";
import MsRun from "../Run";
import {createComponent} from "../jmeter/components";
import {REQ_METHOD} from "../../model/JsonData";
import MsRequestResultTail from "../response/RequestResultTail";
import TcpBasisParameters from "../request/tcp/TcpBasisParameters";
import MsJmxStep from "../step/JmxStep";
import MsApiCaseList from "../case/ApiCaseList";
import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
import MsResponseResult from "../response/ResponseResult";
import MsRequestMetric from "../response/RequestMetric";
import {getUUID} from "@/common/js/utils";
import MsResponseText from "../response/ResponseText";
import MsRun from "../Run";
import {createComponent} from "../jmeter/components";
import {REQ_METHOD} from "../../model/JsonData";
import MsRequestResultTail from "../response/RequestResultTail";
import TcpBasisParameters from "../request/tcp/TcpBasisParameters";
import MsJmxStep from "../step/JmxStep";
import MsApiCaseList from "../case/ApiCaseList";
export default {
export default {
name: "ApiConfig",
components: {
MsJmxStep,
@ -130,7 +130,9 @@ export default {
this.$refs['requestForm'].validate();
}
},
refreshModule() {
this.$emit('refreshModule');
},
runDebug() {
this.loading = true;
this.request.name = getUUID().substring(0, 8);

View File

@ -369,6 +369,10 @@ export default {
moduleIds: Array,
sharePage:Boolean,
pageHeaderHeight:Number,
trashEnable: {
type: Boolean,
default: false,
},
},
activated() {
this.initApiDocSimpleList();
@ -409,6 +413,9 @@ export default {
},
clientHeight() { //clientHeight
this.changeFixed(this.clientHeight);
},
trashEnable() {
this.initApiDocSimpleList();
}
},
methods: {
@ -441,7 +448,10 @@ export default {
}
if (this.moduleIds.length > 0) {
simpleRequest.moduleIds = this.moduleIds;
} else {
simpleRequest.moduleIds = [];
}
simpleRequest.trashEnable = this.trashEnable;
let simpleInfoUrl = "/api/document/selectApiSimpleInfo";
this.apiInfoArray = [];
@ -533,9 +543,6 @@ export default {
//
this.checkApiInfoNode(this.apiStepIndex,true);
},
stepClick(stepIndex) {
this.apiStepIndex = stepIndex;
},
getColor(enable, method) {
return this.methodColorMap.get(method);
},
@ -642,8 +649,6 @@ export default {
for(let i = 0;i<this.apiShowArray.length;i++){
names += this.apiShowArray[i].name+";";
}
console.log("["+apiDocDivScrollTop+":"+this.apiStepIndex+"]:["+lastIndex+":"+this.currentApiIndexInApiShowArray+"]-------->"+names);
if(lastIndex < this.currentApiIndexInApiShowArray){
//
if(this.needAsyncSelect){
@ -684,10 +689,6 @@ export default {
}
this.apiStepIndex ++;
}
// this.apiStepIndex = lastIndex;
// // 2
// this.checkApiInfoNode(this.apiStepIndex);
},
redirectScroll(){
//api

View File

@ -1,7 +1,7 @@
<template>
<div>
<!-- <api-document-item :project-id="projectId" :module-ids="moduleIds"/>-->
<api-document-anchor :is-share-page="isSharePage" :project-id="projectId" :module-ids="moduleIds"></api-document-anchor>
<api-document-anchor :is-share-page="isSharePage" :trash-enable="trashEnable" :project-id="projectId" :module-ids="moduleIds"></api-document-anchor>
</div>
</template>
@ -23,6 +23,10 @@ export default {
projectId:String,
moduleIds:Array,
activeDom:String,
trashEnable: {
type: Boolean,
default: false,
},
},
created: function () {
},

View File

@ -43,16 +43,6 @@ export default {
name: "ApiReportView",
component: () => import('@/business/components/api/report/ApiReportView'),
},
{
path: "definition/:redirectID?/:dataType?/:dataSelectRange?",
name: "ApiDefinition",
component: () => import('@/business/components/api/definition/ApiDefinition'),
},
{
path: "automation/:redirectID?/:dataType?/:dataSelectRange?",
name: "ApiAutomation",
component: () => import('@/business/components/api/automation/ApiAutomation'),
},
{
path: "automation/report",
name: "ApiReportList",
@ -64,6 +54,16 @@ export default {
component: () => import('@/business/components/api/automation/report/ApiReportView'),
},
{
path: "definition/:redirectID?/:dataType?/:dataSelectRange?",
name: "ApiDefinition",
component: () => import('@/business/components/api/definition/ApiDefinition'),
},
{
path: "automation/:redirectID?/:dataType?/:dataSelectRange?",
name: "ApiAutomation",
component: () => import('@/business/components/api/automation/ApiAutomation'),
},
{
path: 'monitor/view',
name: 'ApiMonitor',

@ -1 +1 @@
Subproject commit 2115bd28a90854d2b6276a90878934715498c584
Subproject commit 07951ba17aef6f29e50cfd68e40de3266f9a60cd