testplan -> performance

This commit is contained in:
Captain.B 2020-04-02 17:59:01 +08:00
parent 1db8c03a42
commit 3612b9b2c7
11 changed files with 33 additions and 33 deletions

View File

@ -10,7 +10,7 @@ import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.testplan.*; import io.metersphere.controller.request.testplan.*;
import io.metersphere.dto.LoadTestDTO; import io.metersphere.dto.LoadTestDTO;
import io.metersphere.service.FileService; import io.metersphere.service.FileService;
import io.metersphere.service.LoadTestService; import io.metersphere.service.PerformanceTestService;
import io.metersphere.user.SessionUtils; import io.metersphere.user.SessionUtils;
import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles; import org.apache.shiro.authz.annotation.RequiresRoles;
@ -24,11 +24,11 @@ import javax.annotation.Resource;
import java.util.List; import java.util.List;
@RestController @RestController
@RequestMapping(value = "/testplan") @RequestMapping(value = "performance")
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR) @RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
public class LoadTestController { public class PerformanceTestController {
@Resource @Resource
private LoadTestService loadTestService; private PerformanceTestService performanceTestService;
@Resource @Resource
private FileService fileService; private FileService fileService;
@ -38,14 +38,14 @@ public class LoadTestController {
QueryTestPlanRequest request = new QueryTestPlanRequest(); QueryTestPlanRequest request = new QueryTestPlanRequest();
request.setWorkspaceId(currentWorkspaceId); request.setWorkspaceId(currentWorkspaceId);
PageHelper.startPage(1, count, true); PageHelper.startPage(1, count, true);
return loadTestService.recentTestPlans(request); return performanceTestService.recentTestPlans(request);
} }
@PostMapping("/list/{goPage}/{pageSize}") @PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<LoadTestDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) { public Pager<List<LoadTestDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true); Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
return PageUtils.setPageInfo(page, loadTestService.list(request)); return PageUtils.setPageInfo(page, performanceTestService.list(request));
} }
@PostMapping(value = "/save", consumes = {"multipart/form-data"}) @PostMapping(value = "/save", consumes = {"multipart/form-data"})
@ -53,7 +53,7 @@ public class LoadTestController {
@RequestPart("request") SaveTestPlanRequest request, @RequestPart("request") SaveTestPlanRequest request,
@RequestPart(value = "file") List<MultipartFile> files @RequestPart(value = "file") List<MultipartFile> files
) { ) {
return loadTestService.save(request, files); return performanceTestService.save(request, files);
} }
@PostMapping(value = "/edit", consumes = {"multipart/form-data"}) @PostMapping(value = "/edit", consumes = {"multipart/form-data"})
@ -61,32 +61,32 @@ public class LoadTestController {
@RequestPart("request") EditTestPlanRequest request, @RequestPart("request") EditTestPlanRequest request,
@RequestPart(value = "file", required = false) List<MultipartFile> files @RequestPart(value = "file", required = false) List<MultipartFile> files
) { ) {
return loadTestService.edit(request, files); return performanceTestService.edit(request, files);
} }
@GetMapping("/get/{testId}") @GetMapping("/get/{testId}")
public LoadTestDTO get(@PathVariable String testId) { public LoadTestDTO get(@PathVariable String testId) {
return loadTestService.get(testId); return performanceTestService.get(testId);
} }
@GetMapping("/get-advanced-config/{testId}") @GetMapping("/get-advanced-config/{testId}")
public String getAdvancedConfiguration(@PathVariable String testId) { public String getAdvancedConfiguration(@PathVariable String testId) {
return loadTestService.getAdvancedConfiguration(testId); return performanceTestService.getAdvancedConfiguration(testId);
} }
@GetMapping("/get-load-config/{testId}") @GetMapping("/get-load-config/{testId}")
public String getLoadConfiguration(@PathVariable String testId) { public String getLoadConfiguration(@PathVariable String testId) {
return loadTestService.getLoadConfiguration(testId); return performanceTestService.getLoadConfiguration(testId);
} }
@PostMapping("/delete") @PostMapping("/delete")
public void delete(@RequestBody DeleteTestPlanRequest request) { public void delete(@RequestBody DeleteTestPlanRequest request) {
loadTestService.delete(request); performanceTestService.delete(request);
} }
@PostMapping("/run") @PostMapping("/run")
public void run(@RequestBody RunTestPlanRequest request) { public void run(@RequestBody RunTestPlanRequest request) {
boolean started = loadTestService.run(request); boolean started = performanceTestService.run(request);
if (!started) { if (!started) {
MSException.throwException("Start engine error, please check log."); MSException.throwException("Start engine error, please check log.");
} }

View File

@ -11,7 +11,7 @@ import io.metersphere.commons.constants.TestStatus;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.config.JmeterProperties; import io.metersphere.config.JmeterProperties;
import io.metersphere.service.LoadTestService; import io.metersphere.service.PerformanceTestService;
import io.metersphere.service.TestResourcePoolService; import io.metersphere.service.TestResourcePoolService;
import io.metersphere.service.TestResourceService; import io.metersphere.service.TestResourceService;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
@ -25,7 +25,7 @@ public abstract class AbstractEngine implements Engine {
private Long startTime; private Long startTime;
private String reportId; private String reportId;
protected LoadTestWithBLOBs loadTest; protected LoadTestWithBLOBs loadTest;
protected LoadTestService loadTestService; protected PerformanceTestService performanceTestService;
protected Integer threadNum; protected Integer threadNum;
protected List<TestResource> resourceList; protected List<TestResource> resourceList;
@ -46,7 +46,7 @@ public abstract class AbstractEngine implements Engine {
} }
this.loadTest = loadTest; this.loadTest = loadTest;
this.loadTestService = CommonBeanFactory.getBean(LoadTestService.class); this.performanceTestService = CommonBeanFactory.getBean(PerformanceTestService.class);
threadNum = getThreadNum(loadTest); threadNum = getThreadNum(loadTest);
String resourcePoolId = loadTest.getTestResourcePoolId(); String resourcePoolId = loadTest.getTestResourcePoolId();
@ -67,7 +67,7 @@ public abstract class AbstractEngine implements Engine {
} }
protected Integer getRunningThreadNum() { protected Integer getRunningThreadNum() {
List<LoadTestWithBLOBs> loadTests = loadTestService.selectByTestResourcePoolId(loadTest.getTestResourcePoolId()); List<LoadTestWithBLOBs> loadTests = performanceTestService.selectByTestResourcePoolId(loadTest.getTestResourcePoolId());
// 使用当前资源池正在运行的测试占用的并发数 // 使用当前资源池正在运行的测试占用的并发数
return loadTests.stream() return loadTests.stream()
.filter(t -> TestStatus.Running.name().equals(t.getStatus())) .filter(t -> TestStatus.Running.name().equals(t.getStatus()))

View File

@ -29,7 +29,7 @@ import java.util.stream.Collectors;
@Service @Service
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class LoadTestService { public class PerformanceTestService {
private static final String HEADERS = "timestamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect"; private static final String HEADERS = "timestamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect";
@Resource @Resource

View File

@ -19,7 +19,7 @@
mounted() { mounted() {
if (hasRoles(ROLE_TEST_VIEWER, ROLE_TEST_USER, ROLE_TEST_MANAGER)) { if (hasRoles(ROLE_TEST_VIEWER, ROLE_TEST_USER, ROLE_TEST_MANAGER)) {
this.$get('/testplan/recent/5', (response) => { this.$get('/performance/recent/5', (response) => {
this.recentTestPlans = response.data; this.recentTestPlans = response.data;
}); });
} }

View File

@ -54,9 +54,9 @@
result: {}, result: {},
testPlan: {}, testPlan: {},
listProjectPath: "/project/listAll", listProjectPath: "/project/listAll",
savePath: "/testplan/save", savePath: "/performance/save",
editPath: "/testplan/edit", editPath: "/performance/edit",
runPath: "/testplan/run", runPath: "/performance/run",
projects: [], projects: [],
active: '0', active: '0',
tabs: [{ tabs: [{
@ -88,7 +88,7 @@
let testId = to.path.split('/')[4]; // find testId let testId = to.path.split('/')[4]; // find testId
if (testId) { if (testId) {
this.result = this.$get('/testplan/get/' + testId, response => { this.result = this.$get('/performance/get/' + testId, response => {
if (response.data) { if (response.data) {
this.testPlan = response.data; this.testPlan = response.data;
} }
@ -100,7 +100,7 @@
created() { created() {
let testId = this.$route.path.split('/')[4]; let testId = this.$route.path.split('/')[4];
if (testId) { if (testId) {
this.result = this.$get('/testplan/get/' + testId, response => { this.result = this.$get('/performance/get/' + testId, response => {
this.testPlan = response.data; this.testPlan = response.data;
}); });
} }

View File

@ -20,7 +20,7 @@
const roles = rolesString.split(','); const roles = rolesString.split(',');
if (roles.indexOf(ROLE_TEST_MANAGER) > -1 || roles.indexOf(ROLE_TEST_USER) > -1 || roles.indexOf(ROLE_TEST_VIEWER) > -1) { if (roles.indexOf(ROLE_TEST_MANAGER) > -1 || roles.indexOf(ROLE_TEST_USER) > -1 || roles.indexOf(ROLE_TEST_VIEWER) > -1) {
this.$get('/testplan/recent/5', (response) => { this.$get('/performance/recent/5', (response) => {
this.recentTestPlans = response.data; this.recentTestPlans = response.data;
}); });
} }

View File

@ -81,8 +81,8 @@
data() { data() {
return { return {
result: {}, result: {},
queryPath: "/testplan/list", queryPath: "/performance/list",
deletePath: "/testplan/delete", deletePath: "/performance/delete",
condition: "", condition: "",
projectId: null, projectId: null,
tableData: [], tableData: [],

View File

@ -245,7 +245,7 @@
}); });
}, },
getAdvancedConfig(testId) { getAdvancedConfig(testId) {
this.$get('/testplan/get-advanced-config/' + testId, (response) => { this.$get('/performance/get-advanced-config/' + testId, (response) => {
if (response.data) { if (response.data) {
let data = JSON.parse(response.data); let data = JSON.parse(response.data);
this.timeout = data.timeout || 10; this.timeout = data.timeout || 10;

View File

@ -58,9 +58,9 @@
data() { data() {
return { return {
result: {}, result: {},
getFileMetadataPath: "/testplan/file/metadata", getFileMetadataPath: "/performance/file/metadata",
jmxDownloadPath: '/testplan/file/download', jmxDownloadPath: '/performance/file/download',
jmxDeletePath: '/testplan/file/delete', jmxDeletePath: '/performance/file/delete',
fileList: [], fileList: [],
tableData: [], tableData: [],
uploadList: [], uploadList: [],

View File

@ -155,7 +155,7 @@
getLoadConfig(testId) { getLoadConfig(testId) {
if (testId) { if (testId) {
this.$get('/testplan/get-load-config/' + testId, (response) => { this.$get('/performance/get-load-config/' + testId, (response) => {
if (response.data) { if (response.data) {
let data = JSON.parse(response.data); let data = JSON.parse(response.data);

View File

@ -20,7 +20,7 @@
const roles = rolesString.split(','); const roles = rolesString.split(',');
if (roles.indexOf(ROLE_TEST_MANAGER) > -1 || roles.indexOf(ROLE_TEST_USER) > -1 || roles.indexOf(ROLE_TEST_VIEWER) > -1) { if (roles.indexOf(ROLE_TEST_MANAGER) > -1 || roles.indexOf(ROLE_TEST_USER) > -1 || roles.indexOf(ROLE_TEST_VIEWER) > -1) {
this.$get('/testplan/recent/5', (response) => { this.$get('/performance/recent/5', (response) => {
this.recentTestPlans = response.data; this.recentTestPlans = response.data;
}); });
} }