This commit is contained in:
chenjianxing 2021-01-20 20:27:28 +08:00
commit deae6d6053
17 changed files with 52 additions and 65 deletions

View File

@ -218,7 +218,8 @@
</include>
</if>
<if test="request.name != null">
and api_definition.name like CONCAT('%', #{request.name},'%')
and (api_definition.name like CONCAT('%', #{request.name},'%')
or api_definition.tags like CONCAT('%', #{request.name},'%'))
</if>
<if test="request.protocol != null">
AND api_definition.protocol = #{request.protocol}

View File

@ -114,7 +114,7 @@
</if>
<if test="request.name != null">
and api_scenario.name like CONCAT('%', #{request.name},'%')
and (api_scenario.name like CONCAT('%', #{request.name},'%') or api_scenario.tags like CONCAT('%', #{request.name},'%'))
</if>
<if test="request.workspaceId != null">
AND project.workspace_id = #{request.workspaceId}

View File

@ -278,8 +278,9 @@
</include>
</if>
<if test="request.name != null">
and (test_case.name like CONCAT('%', #{request.name},'%') or test_case.num like CONCAT('%',
#{request.name},'%'))
and (test_case.name like CONCAT('%', #{request.name},'%')
or test_case.num like CONCAT('%', #{request.name},'%')
or test_case.tags like CONCAT('%', #{request.name},'%'))
</if>
<if test="request.nodeIds != null and request.nodeIds.size() > 0">
and test_case.node_id in

View File

@ -238,6 +238,7 @@
<select id="findIdByPerformanceReportId" resultType="java.lang.String">
SELECT report.id FROM test_plan_report report INNER JOIN test_plan_report_data reportData ON report.id = reportData.test_plan_report_id
WHERE reportData.performance_info like CONCAT('%', #{0},'%')
AND report.is_performance_executing = true;
</select>
</mapper>

View File

@ -7,5 +7,6 @@ public enum ReportTriggerMode {
/**
* 性能测试用例执行触发报告
*/
CASE
CASE,
TEST_PLAN_SCHEDULE
}

View File

@ -141,7 +141,7 @@ public class TestPlanTestJob extends MsScheduleJob {
RunTestPlanRequest performanceRequest = new RunTestPlanRequest();
performanceRequest.setId(caseID);
performanceRequest.setTestPlanLoadId(caseID);
performanceRequest.setTriggerMode(ReportTriggerMode.SCHEDULE.name());
performanceRequest.setTriggerMode(ReportTriggerMode.TEST_PLAN_SCHEDULE.name());
String reportId = null;
try {

View File

@ -105,7 +105,7 @@ public class ShiroDBRealm extends AuthorizingRealm {
if (user == null) {
msg = "The user does not exist: " + userId;
logger.warn(msg);
throw new UnknownAccountException(Translator.get("user_not_exist") + userId);
throw new UnknownAccountException(Translator.get("password_is_incorrect") + userId);
}
}
return user;
@ -119,7 +119,7 @@ public class ShiroDBRealm extends AuthorizingRealm {
if (user == null) {
msg = "The user does not exist: " + userId;
logger.warn(msg);
throw new UnknownAccountException(Translator.get("user_not_exist") + userId);
throw new UnknownAccountException(Translator.get("password_is_incorrect") + userId);
}
userId = user.getId();
}

View File

@ -0,0 +1,17 @@
package io.metersphere.track.dto;
import lombok.Getter;
import lombok.Setter;
/**
* @author song.tianyang
* @Date 2021/1/20 4:07 下午
* @Description 测试计划性能测试执行完毕后的回调参数
*/
@Getter
@Setter
public class TestPlanLoadCaseEventDTO {
private String reportId;
private String triggerMode;
private String status;
}

View File

@ -7,6 +7,7 @@ import io.metersphere.commons.constants.PerformanceTestStatus;
import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.consumer.LoadTestFinishEvent;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.track.dto.TestPlanLoadCaseEventDTO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -25,11 +26,12 @@ public class TestPlanLoadCaseEvent implements LoadTestFinishEvent {
@Override
public void execute(LoadTestReport loadTestReport) {
LogUtil.info("PerformanceNoticeEvent OVER:" + loadTestReport.getTriggerMode()+";"+loadTestReport.getStatus());
if (StringUtils.equals(NoticeConstants.Mode.SCHEDULE, loadTestReport.getTriggerMode()) ) {
if (StringUtils.equalsAny(loadTestReport.getStatus(),
PerformanceTestStatus.Completed.name(), PerformanceTestStatus.Error.name())) {
testPlanReportService.updatePerformanceTestStatus(loadTestReport.getId(), ReportTriggerMode.SCHEDULE.name());
}
if (StringUtils.equals(ReportTriggerMode.TEST_PLAN_SCHEDULE.name(), loadTestReport.getTriggerMode()) ) {
TestPlanLoadCaseEventDTO eventDTO = new TestPlanLoadCaseEventDTO();
eventDTO.setReportId(loadTestReport.getId());
eventDTO.setTriggerMode(ReportTriggerMode.SCHEDULE.name());
eventDTO.setStatus(loadTestReport.getStatus());
testPlanReportService.updatePerformanceTestStatus(eventDTO);
}
}
}

View File

@ -199,6 +199,7 @@ public class TestPlanReportService {
QueryTestPlanRequest queryTestPlanRequest = new QueryTestPlanRequest();
queryTestPlanRequest.setId(testPlanReport.getTestPlanId());
TestPlanDTO testPlan = extTestPlanMapper.list(queryTestPlanRequest).get(0);
String issuesInfo = null;
//因为接口案例的定时任务是单个案例开线程运行 所以要检查是否都执行完成全部执行完成时才会进行统一整理
if (StringUtils.equals(ReportTriggerMode.SCHEDULE.name(),triggerMode)
@ -209,6 +210,8 @@ public class TestPlanReportService {
return;
}
}
}else if(StringUtils.equals(ReportTriggerMode.TEST_PLAN_SCHEDULE.name(),triggerMode)){
issuesInfo = ReportTriggerMode.TEST_PLAN_SCHEDULE.name();
}
testPlanReport.setEndTime(System.currentTimeMillis());
@ -251,6 +254,9 @@ public class TestPlanReportService {
testPlanReportData.setExecuteResult(JSONObject.toJSONString(testCaseReportMetricDTO.getExecuteResult()));
testPlanReportData.setFailurTestCases(JSONObject.toJSONString(testCaseReportMetricDTO.getFailureTestCases()));
testPlanReportData.setModuleExecuteResult(JSONArray.toJSONString(testCaseReportMetricDTO.getModuleExecuteResult()));
if(issuesInfo!=null){
testPlanReportData.setIssuesInfo(issuesInfo);
}
testPlanReportDataMapper.updateByPrimaryKeyWithBLOBs(testPlanReportData);
}
@ -336,54 +342,11 @@ public class TestPlanReportService {
models.setPerformanceInfo(JSONArray.toJSONString(performaneReportIDList));
testPlanReportDataMapper.updateByPrimaryKeyWithBLOBs(models);
}
/**
* 虽然kafka已经设置了topic推送但是在1.18日测试时发现无法收到消息
* 由于Tapd为完成任务较多无法抽时间查看问题暂时先保留以下逻辑解决完Tpad任务之后查看原因再删除以下代码
*/
executorService.submit(() -> {
//错误数据检查集合 如果错误数据出现超过20次则取消该条数据的检查
Map<String,Integer> errorDataCheckMap = new HashMap<>();
while (performaneReportIDList.size()>0) {
List<String> selectList = new ArrayList<>(performaneReportIDList);
for (String loadTestReportId:selectList) {
LoadTestReportWithBLOBs loadTestReportFromDatabase = loadTestReportMapper.selectByPrimaryKey(loadTestReportId);
if(loadTestReportFromDatabase == null){
//检查错误数据
if(errorDataCheckMap.containsKey(loadTestReportId)){
if(errorDataCheckMap.get(loadTestReportId)>20){
performaneReportIDList.remove(loadTestReportId);
}else {
errorDataCheckMap.put(loadTestReportId,errorDataCheckMap.get(loadTestReportId)+1);
}
}else {
errorDataCheckMap.put(loadTestReportId,1);
}
}else if (StringUtils.equalsAny(loadTestReportFromDatabase.getStatus(),
PerformanceTestStatus.Completed.name(), PerformanceTestStatus.Error.name())) {
performaneReportIDList.remove(loadTestReportId);
System.out.println("over");
}
}
if(performaneReportIDList.isEmpty()){
List<String> testPlanReportList = new ArrayList<>();
testPlanReportList.add(testPlanReport.getId());
this.updateReport(testPlanReportList, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name(),triggerMode);
}else {
try {
//查询定时任务是否关闭
Thread.sleep(1000 * 10);// 检查 loadtest 的状态
} catch (InterruptedException e) {
}
}
}
return true;
});
}
public void updatePerformanceTestStatus(String reportId,String triggerMode) {
List<String> testPlanReportId = extTestPlanMapper.findIdByPerformanceReportId(reportId);
this.updateReport(testPlanReportId, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name(),triggerMode);
public void updatePerformanceTestStatus(TestPlanLoadCaseEventDTO eventDTO) {
List<String> testPlanReportId = extTestPlanMapper.findIdByPerformanceReportId(eventDTO.getReportId());
this.updateReport(testPlanReportId, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name(),eventDTO.getTriggerMode());
}
public void delete(List<String> testPlanReportIdList) {

View File

@ -20,7 +20,7 @@ password_modification_failed=The old password is wrong. Please re-enter it
cannot_delete_current_user=Cannot delete the user currently logged in
user_already_exists=The user already exists in the current member list
cannot_remove_current=Unable to remove the currently logged in user
password_is_incorrect=Incorrect password
password_is_incorrect=Incorrect password or username
user_not_exist=user does not exist
user_has_been_disabled=the user has been disabled.
excessive_attempts=Excessive attempts

View File

@ -21,7 +21,7 @@ connection_failed=连接失败
user_already_exists=该用户已存在于当前成员列表中
cannot_remove_current=无法移除当前登录用户
login_fail=登录失败
password_is_incorrect=密码不正确
password_is_incorrect=用户名或密码不正确
user_not_exist=用户不存在:
user_has_been_disabled=用户已被禁用
excessive_attempts=操作频繁

View File

@ -20,7 +20,7 @@ password_modification_failed=舊密碼輸入錯誤,請重新輸入
cannot_delete_current_user=無法刪除當前登錄用戶
user_already_exists=該用戶已存在於當前成員列表中
cannot_remove_current=無法移除當前登錄用戶
password_is_incorrect=密碼不正確
password_is_incorrect=用戶名或密碼不正確
user_not_exist=用戶不存在:
user_has_been_disabled=用戶已被禁用
excessive_attempts=操作頻繁

View File

@ -92,7 +92,7 @@
<!-- 场景步骤-->
<div v-loading="loading">
<div @click="showAll">
<p class="tip">{{$t('api_test.automation.scenario_stepscenario_step')}} </p>
<p class="tip">{{$t('api_test.automation.scenario_step')}} </p>
</div>
<el-row>
<el-col :span="21">

View File

@ -202,7 +202,7 @@ export default {
if (!this.httpForm.path || this.httpForm.path.indexOf('?') === -1) return;
let url = this.getURL(this.addProtocol(this.httpForm.path));
if (url) {
this.httpForm.path = decodeURIComponent("/" + url.hostname + url.pathname);
this.httpForm.path = decodeURIComponent(this.httpForm.path.substr(0,this.httpForm.path.indexOf("?")));
}
},
addProtocol(url) {

View File

@ -2,6 +2,7 @@
<span>
<span v-if="triggerMode === 'MANUAL'">{{$t('commons.trigger_mode.manual')}}</span>
<span v-if="triggerMode === 'SCHEDULE'">{{$t('commons.trigger_mode.schedule')}}</span>
<span v-if="triggerMode === 'TEST_PLAN_SCHEDULE'">{{$t('commons.trigger_mode.schedule')}}</span>
<span v-if="triggerMode === 'API'">{{$t('commons.trigger_mode.api')}}</span>
<span v-if="triggerMode === 'CASE'">用例触发</span>
</span>

View File

@ -3,7 +3,7 @@
<el-dialog :close-on-click-modal="false" class="case-dialog"
@close="close"
:title="operationType == 'edit' ? ( readOnly ? $t('test_track.case.view_case') : $t('test_track.case.edit_case')) : $t('test_track.case.create')"
:visible.sync="dialogFormVisible" width="85%">
:visible.sync="dialogFormVisible" width="85%" v-if="dialogFormVisible">
<el-row :gutter="10">
<div>