mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-05 05:29:29 +08:00
feat(项目管理): 项目管理-应用设置-性能测试配置功能
This commit is contained in:
parent
ac387b6fd0
commit
3435390650
@ -145,6 +145,8 @@ public class PermissionConstants {
|
||||
public static final String PROJECT_APPLICATION_TEST_PLAN_UPDATE = "PROJECT_APPLICATION_TEST_PLAN:UPDATE";
|
||||
public static final String PROJECT_APPLICATION_UI_READ = "PROJECT_APPLICATION_UI:READ";
|
||||
public static final String PROJECT_APPLICATION_UI_UPDATE = "PROJECT_APPLICATION_UI:UPDATE";
|
||||
public static final String PROJECT_APPLICATION_PERFORMANCE_TEST_READ = "PROJECT_APPLICATION_PERFORMANCE_TEST:READ";
|
||||
public static final String PROJECT_APPLICATION_PERFORMANCE_TEST_UPDATE = "PROJECT_APPLICATION_PERFORMANCE_TEST:UPDATE";
|
||||
/*------ end: PROJECT_APPLICATION ------*/
|
||||
public static final String PROJECT_BASE_INFO_READ = "PROJECT_BASE_INFO:READ";
|
||||
}
|
||||
|
@ -32,6 +32,21 @@ public enum ProjectApplicationType {
|
||||
APPLICATION_SHARE_UI_REPORT,
|
||||
|
||||
|
||||
//性能测试
|
||||
/**
|
||||
* 性能测试报告保留范围 value
|
||||
*/
|
||||
APPLICATION_CLEAN_PERFORMANCE_TEST_REPORT,
|
||||
/**
|
||||
* 性能测试报告有效期 value
|
||||
*/
|
||||
APPLICATION_SHARE_PERFORMANCE_TEST_REPORT,
|
||||
/**
|
||||
* 性能测试脚本审核人
|
||||
*/
|
||||
APPLICATION_PERFORMANCE_TEST_SCRIPT_REVIEWER,
|
||||
|
||||
|
||||
//缺陷管理
|
||||
/**
|
||||
* 同步缺陷 标识
|
||||
|
@ -109,5 +109,7 @@ permission.project_application_test_plan.read=Test plan read
|
||||
permission.project_application_test_plan.update=Test plan update
|
||||
permission.project_application_ui.read=UI test read
|
||||
permission.project_application_ui.update=UI test update
|
||||
permission.project_application_performance_test.read=Performance test read
|
||||
permission.project_application_performance_test.update=Performance test update
|
||||
permission.project_base_info.name=Project base info
|
||||
permission.project_log.name=Operation log
|
||||
|
@ -109,5 +109,7 @@ permission.project_application_test_plan.read=测试计划-查询
|
||||
permission.project_application_test_plan.update=测试计划-编辑
|
||||
permission.project_application_ui.read=UI测试-查询
|
||||
permission.project_application_ui.update=UI测试-编辑
|
||||
permission.project_application_performance_test.read=性能测试-查询
|
||||
permission.project_application_performance_test.update=性能测试-编辑
|
||||
permission.project_base_info.name=基本信息
|
||||
permission.project_log.name=日志
|
||||
|
@ -109,5 +109,7 @@ permission.project_application_test_plan.read=測試計劃-查詢
|
||||
permission.project_application_test_plan.update=測試計劃-編輯
|
||||
permission.project_application_ui.read=UI測試-查詢
|
||||
permission.project_application_ui.update=UI測試-編輯
|
||||
permission.project_application_performance_test.read=性能測試-查詢
|
||||
permission.project_application_performance_test.update=性能測試-編輯
|
||||
permission.project_base_info.name=基本信息
|
||||
permission.project_log.name=日誌
|
@ -6,10 +6,14 @@ import io.metersphere.project.service.ProjectApplicationService;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.log.annotation.Log;
|
||||
import io.metersphere.sdk.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.util.SessionUtils;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.service.UserService;
|
||||
import io.metersphere.validation.groups.Updated;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -23,7 +27,8 @@ import java.util.List;
|
||||
public class ProjectApplicationController {
|
||||
@Resource
|
||||
private ProjectApplicationService projectApplicationService;
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* ==========测试计划==========
|
||||
@ -63,4 +68,31 @@ public class ProjectApplicationController {
|
||||
public List<ProjectApplication> getUI(@Validated @RequestBody ProjectApplicationRequest request) {
|
||||
return projectApplicationService.get(request);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ==========性能测试==========
|
||||
*/
|
||||
|
||||
@PostMapping("/update/performance-test")
|
||||
@Operation(summary = "应用设置-性能测试-配置")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_APPLICATION_PERFORMANCE_TEST_UPDATE)
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updatePerformanceLog(#application)", msClass = ProjectApplicationService.class)
|
||||
public ProjectApplication updatePerformanceTest(@Validated({Updated.class}) @RequestBody ProjectApplication application) {
|
||||
return projectApplicationService.update(application);
|
||||
}
|
||||
|
||||
@PostMapping("/performance-test")
|
||||
@Operation(summary = "应用设置-性能测试-获取配置")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_APPLICATION_PERFORMANCE_TEST_READ)
|
||||
public List<ProjectApplication> getPerformanceTest(@Validated @RequestBody ProjectApplicationRequest request) {
|
||||
return projectApplicationService.get(request);
|
||||
}
|
||||
|
||||
@GetMapping("/performance-test/user/{projectId}")
|
||||
@Operation(summary = "应用设置-性能测试-获取审核人")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_APPLICATION_PERFORMANCE_TEST_READ)
|
||||
public List<User> getCheckUser(@PathVariable String projectId) {
|
||||
return projectApplicationService.getProjectUserList(StringUtils.defaultIfBlank(projectId, SessionUtils.getCurrentProjectId()));
|
||||
}
|
||||
}
|
||||
|
@ -17,4 +17,11 @@ public interface ExtProjectUserRoleMapper {
|
||||
* @return 项目成员列表
|
||||
*/
|
||||
List<User> listProjectRoleMember(@Param("request") ProjectUserRoleMemberRequest request);
|
||||
|
||||
/**
|
||||
* 根据项目id获取 项目成员
|
||||
* @param sourceId
|
||||
* @return
|
||||
*/
|
||||
List<User> getProjectUserList(@Param("sourceId") String sourceId);
|
||||
}
|
||||
|
@ -10,4 +10,16 @@
|
||||
and u.name like concat('%', #{request.keyword}, '%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getProjectUserList" resultType="io.metersphere.system.domain.User">
|
||||
SELECT
|
||||
u.id,
|
||||
u.NAME
|
||||
FROM
|
||||
`user` u
|
||||
LEFT JOIN user_role_relation urr ON u.id = urr.user_id
|
||||
WHERE
|
||||
urr.source_id = #{sourceId} and u.deleted = false
|
||||
order by u.create_time desc
|
||||
</select>
|
||||
</mapper>
|
@ -3,6 +3,7 @@ package io.metersphere.project.service;
|
||||
import io.metersphere.project.domain.ProjectApplication;
|
||||
import io.metersphere.project.domain.ProjectApplicationExample;
|
||||
import io.metersphere.project.job.CleanUpReportJob;
|
||||
import io.metersphere.project.mapper.ExtProjectUserRoleMapper;
|
||||
import io.metersphere.project.mapper.ProjectApplicationMapper;
|
||||
import io.metersphere.project.request.ProjectApplicationRequest;
|
||||
import io.metersphere.sdk.constants.OperationLogConstants;
|
||||
@ -15,6 +16,8 @@ import io.metersphere.sdk.sechedule.BaseScheduleService;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.SessionUtils;
|
||||
import io.metersphere.system.domain.Schedule;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.mapper.ExtUserMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
@ -35,6 +38,9 @@ public class ProjectApplicationService {
|
||||
@Resource
|
||||
private BaseScheduleService baseScheduleService;
|
||||
|
||||
@Resource
|
||||
private ExtProjectUserRoleMapper extProjectUserRoleMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 更新配置信息
|
||||
@ -67,8 +73,9 @@ public class ProjectApplicationService {
|
||||
String type = application.getType();
|
||||
//TODO 自定义id配置 &其他配置
|
||||
if (StringUtils.equals(type, ProjectApplicationType.APPLICATION_CLEAN_TEST_PLAN_REPORT.name())
|
||||
|| StringUtils.equals(type, ProjectApplicationType.APPLICATION_CLEAN_UI_REPORT.name())) {
|
||||
//清除 测试计划/UI 报告 定时任务
|
||||
|| StringUtils.equals(type, ProjectApplicationType.APPLICATION_CLEAN_UI_REPORT.name())
|
||||
|| StringUtils.equals(type, ProjectApplicationType.APPLICATION_CLEAN_PERFORMANCE_TEST_REPORT.name())) {
|
||||
//清除 测试计划/UI测试/性能测试 报告 定时任务
|
||||
this.doHandleSchedule(application);
|
||||
}
|
||||
}
|
||||
@ -110,6 +117,7 @@ public class ProjectApplicationService {
|
||||
|
||||
/**
|
||||
* 获取配置信息
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@ -124,6 +132,11 @@ public class ProjectApplicationService {
|
||||
}
|
||||
|
||||
|
||||
public List<User> getProjectUserList(String projectId) {
|
||||
return extProjectUserRoleMapper.getProjectUserList(projectId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 测试计划 日志
|
||||
*
|
||||
@ -145,6 +158,15 @@ public class ProjectApplicationService {
|
||||
return delLog(application, OperationLogModule.PROJECT_PROJECT_MANAGER, "UI配置");
|
||||
}
|
||||
|
||||
/**
|
||||
* 性能测试 日志
|
||||
*
|
||||
* @param application
|
||||
* @return
|
||||
*/
|
||||
public LogDTO updatePerformanceLog(ProjectApplication application) {
|
||||
return delLog(application, OperationLogModule.PROJECT_PROJECT_MANAGER, "性能测试配置");
|
||||
}
|
||||
|
||||
private LogDTO delLog(ProjectApplication application, String module, String content) {
|
||||
ProjectApplicationExample example = new ProjectApplicationExample();
|
||||
|
@ -143,6 +143,14 @@
|
||||
{
|
||||
"id": "PROJECT_APPLICATION_UI:UPDATE",
|
||||
"name": "permission.project_application_ui.update"
|
||||
},
|
||||
{
|
||||
"id": "PROJECT_APPLICATION_PERFORMANCE_TEST:READ",
|
||||
"name": "permission.project_application_performance_test.read"
|
||||
},
|
||||
{
|
||||
"id": "PROJECT_APPLICATION_PERFORMANCE_TEST:UPDATE",
|
||||
"name": "permission.project_application_performance_test.update"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -77,7 +77,6 @@ public class ProjectApplicationControllerTests extends BaseTest {
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ==========UI测试 start==========
|
||||
*/
|
||||
@ -90,7 +89,6 @@ public class ProjectApplicationControllerTests extends BaseTest {
|
||||
@Test
|
||||
@Order(4)
|
||||
public void testUiClean() throws Exception {
|
||||
this.testGetTestPlan();
|
||||
//新增
|
||||
ProjectApplication request = creatRequest(ProjectApplicationType.APPLICATION_CLEAN_UI_REPORT.name(), TIME_TYPE_VALUE);
|
||||
this.requestPost(UI_UPDATE_URL, request);
|
||||
@ -131,6 +129,71 @@ public class ProjectApplicationControllerTests extends BaseTest {
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* ==========性能测试 start==========
|
||||
*/
|
||||
// 性能测试
|
||||
public static final String PERFORMANCE_UPDATE_URL = "/project/application/update/performance-test";
|
||||
//获取配置
|
||||
public static final String GET_PERFORMANCE_URL = "/project/application/performance-test";
|
||||
//获取脚本审核人
|
||||
public static final String GET_USER_URL = "/project/application/performance-test/user";
|
||||
|
||||
//应用配置 - UI测试 - 清理报告配置
|
||||
@Test
|
||||
@Order(7)
|
||||
public void testPerformanceClean() throws Exception {
|
||||
//新增
|
||||
ProjectApplication request = creatRequest(ProjectApplicationType.APPLICATION_CLEAN_PERFORMANCE_TEST_REPORT.name(), TIME_TYPE_VALUE);
|
||||
this.requestPost(PERFORMANCE_UPDATE_URL, request);
|
||||
//更新
|
||||
request.setTypeValue("4M");
|
||||
this.requestPost(PERFORMANCE_UPDATE_URL, request);
|
||||
// @@异常参数校验
|
||||
updatedGroupParamValidateTest(ProjectApplicationDefinition.class, PERFORMANCE_UPDATE_URL);
|
||||
|
||||
}
|
||||
|
||||
//应用管理 - UI测试 - 分享报告配置
|
||||
@Test
|
||||
@Order(8)
|
||||
public void testPerformanceShare() throws Exception {
|
||||
//新增
|
||||
ProjectApplication request = creatRequest(ProjectApplicationType.APPLICATION_SHARE_PERFORMANCE_TEST_REPORT.name(), TIME_TYPE_VALUE);
|
||||
this.requestPost(PERFORMANCE_UPDATE_URL, request);
|
||||
//更新
|
||||
request.setTypeValue("5M");
|
||||
this.requestPost(PERFORMANCE_UPDATE_URL, request);
|
||||
}
|
||||
|
||||
//应用管理 - UI测试 - 脚本审核
|
||||
@Test
|
||||
@Order(9)
|
||||
public void testPerformanceReviewer() throws Exception {
|
||||
//新增
|
||||
ProjectApplication request = creatRequest(ProjectApplicationType.APPLICATION_PERFORMANCE_TEST_SCRIPT_REVIEWER.name(), "admin");
|
||||
this.requestPost(PERFORMANCE_UPDATE_URL, request);
|
||||
}
|
||||
|
||||
//应用管理 - UI测试 - 获取配置
|
||||
@Test
|
||||
@Order(10)
|
||||
public void testGetPerformance() throws Exception {
|
||||
//清理报告 + 分享报告
|
||||
List<String> types = Arrays.asList(ProjectApplicationType.APPLICATION_CLEAN_PERFORMANCE_TEST_REPORT.name(), ProjectApplicationType.APPLICATION_SHARE_PERFORMANCE_TEST_REPORT.name(), ProjectApplicationType.APPLICATION_PERFORMANCE_TEST_SCRIPT_REVIEWER.name());
|
||||
ProjectApplicationRequest request = this.getRequest(types);
|
||||
this.requestPostWithOkAndReturn(GET_PERFORMANCE_URL, request);
|
||||
// @@异常参数校验
|
||||
updatedGroupParamValidateTest(ProjectApplicationRequestDefinition.class, GET_PERFORMANCE_URL);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(11)
|
||||
public void testGetUser() throws Exception {
|
||||
this.requestGetWithOkAndReturn(GET_USER_URL + "/default-project-2");
|
||||
}
|
||||
|
||||
|
||||
private ProjectApplicationRequest getRequest(List<String> types) {
|
||||
ProjectApplicationRequest request = new ProjectApplicationRequest();
|
||||
request.setProjectId(PROJECT_ID);
|
||||
|
Loading…
Reference in New Issue
Block a user