Merge branch 'master' of https://github.com/metersphere/metersphere
# Conflicts: # backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java
This commit is contained in:
commit
8a47dfa112
|
@ -13,6 +13,7 @@ import io.metersphere.api.dto.definition.RunDefinitionRequest;
|
|||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import io.metersphere.api.dto.scenario.request.dubbo.RegistryCenter;
|
||||
import io.metersphere.api.service.*;
|
||||
import io.metersphere.base.domain.ApiDefinition;
|
||||
import io.metersphere.base.domain.ApiTest;
|
||||
import io.metersphere.base.domain.LoadTest;
|
||||
import io.metersphere.base.domain.Schedule;
|
||||
|
@ -34,6 +35,10 @@ import org.apache.http.entity.ContentType;
|
|||
import org.apache.jorphan.collections.HashTree;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
@ -383,9 +388,20 @@ public class APITestController {
|
|||
}
|
||||
|
||||
@PostMapping(value = "/genPerformanceTestXml", consumes = {"multipart/form-data"})
|
||||
public JmxInfoDTO genPerformanceTest(@RequestPart("request") RunDefinitionRequest runRequest, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
||||
public JmxInfoDTO genPerformanceTest(@RequestPart("request") RunDefinitionRequest runRequest, @RequestPart(value = "files") List<MultipartFile> bodyFiles) throws Exception {
|
||||
HashTree hashTree = runRequest.getTestElement().generateHashTree();
|
||||
String jmxString = runRequest.getTestElement().getJmx(hashTree);
|
||||
|
||||
String testName = runRequest.getName();
|
||||
//将ThreadGroup的testname改为接口名称
|
||||
Document doc = DocumentHelper.parseText(jmxString);// 获取可续保保单列表报文模板
|
||||
Element root = doc.getRootElement();
|
||||
Element rootHashTreeElement = root.element("hashTree");
|
||||
Element innerHashTreeElement = rootHashTreeElement.elements("hashTree").get(0);
|
||||
Element theadGroupElement = innerHashTreeElement.elements("ThreadGroup").get(0);
|
||||
theadGroupElement.attribute("testname").setText(testName);
|
||||
jmxString = root.asXML();
|
||||
|
||||
JmxInfoDTO dto = new JmxInfoDTO();
|
||||
dto.setName(runRequest.getName()+".jmx");
|
||||
dto.setXml(jmxString);
|
||||
|
|
|
@ -128,7 +128,7 @@ public class ApiAutomationController {
|
|||
}
|
||||
|
||||
@PostMapping(value = "/genPerformanceTestJmx")
|
||||
public JmxInfoDTO genPerformanceTestJmx(@RequestBody RunScenarioRequest runRequest) {
|
||||
public JmxInfoDTO genPerformanceTestJmx(@RequestBody RunScenarioRequest runRequest) throws Exception {
|
||||
runRequest.setExecuteType(ExecuteType.Completed.name());
|
||||
return apiAutomationService.genPerformanceTestJmx(runRequest);
|
||||
}
|
||||
|
|
|
@ -42,11 +42,17 @@ 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.dom4j.Document;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
@ -593,7 +599,7 @@ public class ApiAutomationService {
|
|||
request, ApiScenarioTestJob.getJobKey(request.getResourceId()), ApiScenarioTestJob.getTriggerKey(request.getResourceId()), ApiScenarioTestJob.class);
|
||||
}
|
||||
|
||||
public JmxInfoDTO genPerformanceTestJmx(RunScenarioRequest request) {
|
||||
public JmxInfoDTO genPerformanceTestJmx(RunScenarioRequest request) throws Exception {
|
||||
List<ApiScenarioWithBLOBs> apiScenarios = null;
|
||||
List<String> ids = request.getScenarioIds();
|
||||
if (request.isSelectAllDate()) {
|
||||
|
@ -601,11 +607,27 @@ public class ApiAutomationService {
|
|||
request.getModuleIds(), request.getName(), request.getProjectId(), request.getFilters(), request.getUnSelectIds());
|
||||
}
|
||||
apiScenarios = extApiScenarioMapper.selectIds(ids);
|
||||
String testName = "";
|
||||
if(!apiScenarios.isEmpty()){
|
||||
testName = apiScenarios.get(0).getName();
|
||||
}
|
||||
MsTestPlan testPlan = new MsTestPlan();
|
||||
testPlan.setHashTree(new LinkedList<>());
|
||||
|
||||
HashTree jmeterHashTree = generateHashTree(apiScenarios, request, false);
|
||||
|
||||
|
||||
HashTree jmeterHashTree = generateHashTree(apiScenarios, request, null);
|
||||
String jmx = testPlan.getJmx(jmeterHashTree);
|
||||
//将ThreadGroup的testname改为接口名称
|
||||
Document doc = DocumentHelper.parseText(jmx);// 获取可续保保单列表报文模板
|
||||
Element root = doc.getRootElement();
|
||||
Element rootHashTreeElement = root.element("hashTree");
|
||||
Element innerHashTreeElement = rootHashTreeElement.elements("hashTree").get(0);
|
||||
Element theadGroupElement = innerHashTreeElement.elements("ThreadGroup").get(0);
|
||||
theadGroupElement.attribute("testname").setText(testName);
|
||||
jmx = root.asXML();
|
||||
|
||||
String name = request.getName() + ".jmx";
|
||||
|
||||
JmxInfoDTO dto = new JmxInfoDTO();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.base.mapper.ext;
|
||||
|
||||
import io.metersphere.track.dto.TestPlanLoadCaseDTO;
|
||||
import io.metersphere.track.request.testplan.LoadCaseRequest;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -8,6 +9,6 @@ import java.util.List;
|
|||
public interface ExtTestPlanLoadCaseMapper {
|
||||
|
||||
List<String> selectIdsNotInPlan(@Param("projectId") String projectId, @Param("planId") String planId);
|
||||
List<TestPlanLoadCaseDTO> selectTestPlanLoadCaseList(@Param("planId") String planId, @Param("projectId") String projectId);
|
||||
List<TestPlanLoadCaseDTO> selectTestPlanLoadCaseList(@Param("request") LoadCaseRequest request);
|
||||
void updateCaseStatus(@Param("reportId") String reportId, @Param("status") String status);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
<!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.ExtTestPlanLoadCaseMapper">
|
||||
<update id="updateCaseStatus">
|
||||
update test_plan_load_case tplc set status = #{status} where tplc.load_report_id = #{reportId}
|
||||
update test_plan_load_case tplc
|
||||
set status = #{status}
|
||||
where tplc.load_report_id = #{reportId}
|
||||
</update>
|
||||
|
||||
<select id="selectIdsNotInPlan" resultType="java.lang.String">
|
||||
|
@ -15,26 +17,29 @@
|
|||
</select>
|
||||
<select id="selectTestPlanLoadCaseList" resultType="io.metersphere.track.dto.TestPlanLoadCaseDTO">
|
||||
select tplc.id,
|
||||
u.name as userName,
|
||||
tplc.create_time,
|
||||
tplc.update_time,
|
||||
tplc.test_plan_id,
|
||||
tplc.load_case_id,
|
||||
lt.status,
|
||||
lt.num,
|
||||
tplc.status as caseStatus,
|
||||
lt.name as caseName,
|
||||
tplc.load_report_id,
|
||||
p.name as projectName
|
||||
u.name as userName,
|
||||
tplc.create_time,
|
||||
tplc.update_time,
|
||||
tplc.test_plan_id,
|
||||
tplc.load_case_id,
|
||||
lt.status,
|
||||
lt.num,
|
||||
tplc.status as caseStatus,
|
||||
lt.name as caseName,
|
||||
tplc.load_report_id,
|
||||
p.name as projectName
|
||||
from test_plan_load_case tplc
|
||||
inner join load_test lt on tplc.load_case_id = lt.id
|
||||
inner join user u on lt.user_id = u.id
|
||||
inner join project p on lt.project_id = p.id
|
||||
<where>
|
||||
tplc.test_plan_id = #{planId}
|
||||
<if test="projectId != null and projectId != ''">
|
||||
and lt.project_id = #{projectId}
|
||||
</if>
|
||||
</where>
|
||||
inner join load_test lt on tplc.load_case_id = lt.id
|
||||
inner join user u on lt.user_id = u.id
|
||||
inner join project p on lt.project_id = p.id
|
||||
<where>
|
||||
tplc.test_plan_id = #{request.testPlanId}
|
||||
<if test="request.projectId != null and request.projectId != ''">
|
||||
and lt.project_id = #{request.projectId}
|
||||
</if>
|
||||
<if test="request.name != null">
|
||||
and (lt.name like CONCAT('%', #{request.name},'%') or lt.num like CONCAT('%', #{request.name},'%'))
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
|
@ -30,13 +30,13 @@ public class ApiScenarioTestJob extends MsScheduleJob {
|
|||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
|
||||
JobKey jobKey = context.getTrigger().getJobKey();
|
||||
JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
|
||||
String resourceId = jobDataMap.getString("resourceId");
|
||||
this.userId = jobDataMap.getString("userId");
|
||||
this.expression = jobDataMap.getString("expression");
|
||||
this.projectID = jobDataMap.getString("projectId");
|
||||
|
||||
if(resourceId!=null){
|
||||
scenarioIds = new ArrayList<>();
|
||||
scenarioIds.add(resourceId);
|
||||
|
|
|
@ -11,4 +11,5 @@ import java.util.List;
|
|||
public class LoadCaseRequest extends TestPlanLoadCase {
|
||||
private String projectId;
|
||||
private List<String> caseIds;
|
||||
private String name;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class TestPlanLoadCaseService {
|
|||
}
|
||||
|
||||
public List<TestPlanLoadCaseDTO> list(LoadCaseRequest request) {
|
||||
return extTestPlanLoadCaseMapper.selectTestPlanLoadCaseList(request.getTestPlanId(), request.getProjectId());
|
||||
return extTestPlanLoadCaseMapper.selectTestPlanLoadCaseList(request);
|
||||
}
|
||||
|
||||
public void relevanceCase(LoadCaseRequest request) {
|
||||
|
|
|
@ -75,14 +75,9 @@
|
|||
<ms-table-operator-button class="run-button" :is-tester-permission="true" :tip="$t('api_test.automation.execute')"
|
||||
icon="el-icon-video-play"
|
||||
@exec="execute(row)" v-tester/>
|
||||
<ms-table-operator-button :tip="$t('api_test.automation.copy')" icon="el-icon-document"
|
||||
<ms-table-operator-button :tip="$t('api_test.automation.copy')" icon="el-icon-document-copy" type=""
|
||||
@exec="copy(row)"/>
|
||||
<ms-table-operator-button :tip="$t('api_test.automation.remove')" icon="el-icon-delete" @exec="remove(row)" type="danger" v-tester/>
|
||||
|
||||
<!-- <el-button type="text" @click="edit(row)" v-tester>{{ $t('api_test.automation.edit') }}</el-button>-->
|
||||
<!-- <el-button type="text" @click="execute(row)" v-tester>{{ $t('api_test.automation.execute') }}</el-button>-->
|
||||
<!-- <el-button type="text" @click="copy(row)" v-tester>{{ $t('api_test.automation.copy') }}</el-button>-->
|
||||
<!-- <el-button type="text" @click="remove(row)" v-tester>{{ $t('api_test.automation.remove') }}</el-button>-->
|
||||
<ms-scenario-extend-buttons :row="row"/>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -30,6 +30,14 @@
|
|||
</el-menu-item>
|
||||
</el-submenu>
|
||||
|
||||
<el-menu-item v-for="menu in project" :key="menu.index" :index="'/setting/project/all'" class="setting-item"
|
||||
v-permission="['test_user','test_manager', 'org_admin', 'admin']">
|
||||
<template v-slot:title>
|
||||
<font-awesome-icon class="icon" :icon="['fa', 'bars']" size="lg"/>
|
||||
<span>{{ $t(menu.title) }}</span>
|
||||
</template>
|
||||
</el-menu-item>
|
||||
|
||||
<el-submenu index="4">
|
||||
<template v-slot:title>
|
||||
<font-awesome-icon class="icon" :icon="['far', 'user']" size="lg"/>
|
||||
|
@ -41,13 +49,6 @@
|
|||
</el-menu-item>
|
||||
</el-submenu>
|
||||
|
||||
<el-menu-item v-for="menu in project" :key="menu.index" :index="'/setting/project/all'" class="setting-item"
|
||||
v-permission="['test_user','test_manager', 'org_admin', 'admin']">
|
||||
<template v-slot:title>
|
||||
<font-awesome-icon class="icon" :icon="['fa', 'bars']" size="lg"/>
|
||||
<span>{{ $t(menu.title) }}</span>
|
||||
</template>
|
||||
</el-menu-item>
|
||||
|
||||
</el-menu>
|
||||
</template>
|
||||
|
|
|
@ -121,10 +121,10 @@
|
|||
@deleteClick="handleDelete(scope.row)">
|
||||
<template v-slot:middle>
|
||||
<ms-table-operator-button :isTesterPermission="true" style="background-color: #85888E;border-color: #85888E" v-if="!scope.row.reportId"
|
||||
:tip="$t('test_track.plan_view.create_report')" icon="el-icon-document"
|
||||
:tip="$t('test_track.plan_view.create_report')" icon="el-icon-s-data"
|
||||
@exec="openTestReportTemplate(scope.row)"/>
|
||||
<ms-table-operator-button v-if="scope.row.reportId"
|
||||
:tip="$t('test_track.plan_view.view_report')" icon="el-icon-document"
|
||||
:tip="$t('test_track.plan_view.view_report')" icon="el-icon-s-data"
|
||||
@exec="openReport(scope.row.id, scope.row.reportId)"/>
|
||||
</template>
|
||||
</ms-table-operator>
|
||||
|
|
|
@ -186,12 +186,11 @@ export default {
|
|||
initTable() {
|
||||
console.log('init')
|
||||
this.selectRows = new Set();
|
||||
let param = {};
|
||||
param.testPlanId = this.planId;
|
||||
this.condition.testPlanId = this.planId;
|
||||
if (this.selectProjectId && this.selectProjectId !== 'root') {
|
||||
param.projectId = this.selectProjectId;
|
||||
this.condition.projectId = this.selectProjectId;
|
||||
}
|
||||
this.$post("/test/plan/load/case/list/" + this.currentPage + "/" + this.pageSize, param, response => {
|
||||
this.$post("/test/plan/load/case/list/" + this.currentPage + "/" + this.pageSize, this.condition, response => {
|
||||
let data = response.data;
|
||||
let {itemCount, listObject} = data;
|
||||
this.total = itemCount;
|
||||
|
|
Loading…
Reference in New Issue