fix: 修改图标、修改"一件创建性能测试"时压力配置下方显示的内容
修改图标、修改"一件创建性能测试"时压力配置下方显示的内容
This commit is contained in:
parent
f6490cb5ed
commit
c7dfb4160b
|
@ -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);
|
||||
|
|
|
@ -127,7 +127,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;
|
||||
|
@ -586,7 +592,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()) {
|
||||
|
@ -594,11 +600,26 @@ 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);
|
||||
|
||||
|
||||
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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue