feat(测试用例): 修复测试计划能发现回收站用例的问题、用例评审过长导致无法发送数据#1005661

修复测试计划能发现回收站用例的问题、--bug=1005661 --user=宋天阳 【测试计划】评论添加图片链接,无法发送
https://www.tapd.cn/55049933/s/1032840
This commit is contained in:
song-tianyang 2021-08-05 16:41:28 +08:00 committed by 刘瑞斌
parent 9f24c19bef
commit 08e6bf5f25
8 changed files with 56 additions and 32 deletions

View File

@ -101,7 +101,7 @@ public class TestResult {
if (result != null && CollectionUtils.isNotEmpty(result.getRequestResults())) {
result.getRequestResults().forEach(item -> {
String itemAndScenarioName = "";
if (StringUtils.isNotEmpty(item.getScenario())) {
if (StringUtils.isNotEmpty(item.getScenario())) {
//第1个当前场景 第all_id_names个最后一层场景
List<String> all_id_names = JSON.parseObject(item.getScenario(), List.class);
if(all_id_names.size()>1){

View File

@ -24,4 +24,6 @@ public interface ExtTestPlanApiCaseMapper {
List<String> selectIds(@Param("request") ApiTestCaseRequest request);
ApiTestCaseWithBLOBs getApiTestCaseById(String testPlanApiCaseId);
List<TestPlanApiCase> selectLegalDataByTestPlanId(String planId);
}

View File

@ -18,6 +18,13 @@
INNER JOIN test_plan_api_case tpac ON t.id = tpac.api_case_id
WHERE tpac.id = #{0}
</select>
<select id="selectLegalDataByTestPlanId" resultType="io.metersphere.base.domain.TestPlanApiCase">
SELECT t.* FROM test_plan_api_case t WHERE t.test_plan_id = #{0}
AND t.api_case_id IN (
SELECT id FROM api_test_case WHERE status IS NULL OR status != 'Trash'
)
</select>
<select id="list" resultType="io.metersphere.api.dto.definition.TestPlanApiCaseDTO">
select
t.id, t.environment_id, t.create_time, t.update_time,
@ -41,13 +48,13 @@
</if>
<choose>
<when test="request.status == 'Trash'">
and a.status = 'Trash'
and c.status = 'Trash'
</when>
<when test="request.status == null">
and a.status != 'Trash'
and (c.status IS NULL or c.status != 'Trash')
</when>
<when test="request.status == ''">
and a.status != 'Trash'
and (c.status IS NULL or c.status != 'Trash')
</when>
<when test="request.status == 'running'">
and t.status IS NULL

View File

@ -22,4 +22,5 @@ public interface ExtTestPlanScenarioCaseMapper {
List<TestPlanApiScenario> selectByIds(@Param("ids")String ids ,@Param("oderId")String oderId );
List<TestPlanApiScenario> selectLegalDataByTestPlanId(String planId);
}

View File

@ -15,6 +15,13 @@
)
</insert>
<select id="selectLegalDataByTestPlanId" resultType="io.metersphere.base.domain.TestPlanApiScenario">
SELECT t.* FROM test_plan_api_scenario t WHERE t.test_plan_id = #{0}
AND t.api_scenario_id IN (
SELECT id FROM API_SCENARIO WHERE status IS NULL OR status != 'Trash'
)
</select>
<select id="list" resultType="io.metersphere.api.dto.automation.ApiScenarioDTO">
select
t.id, t.environment, t.create_time, t.update_time, t.last_result, t.pass_rate, t.report_id, c.scenario_definition,

View File

@ -9,10 +9,7 @@ import io.metersphere.api.dto.definition.ApiTestCaseRequest;
import io.metersphere.api.dto.definition.TestPlanApiCaseDTO;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanLoadCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanReportMapper;
import io.metersphere.base.mapper.ext.*;
import io.metersphere.commons.constants.*;
import io.metersphere.commons.utils.*;
import io.metersphere.dto.BaseSystemConfigDTO;
@ -59,6 +56,8 @@ public class TestPlanReportService {
@Resource
TestPlanReportDataMapper testPlanReportDataMapper;
@Resource
ExtTestPlanScenarioCaseMapper extTestPlanScenarioCaseMapper;
@Resource
ExtTestPlanLoadCaseMapper extTestPlanLoadCaseMapper;
@Resource
TestPlanApiScenarioMapper testPlanScenarioCaseMapper;
@ -118,15 +117,11 @@ public class TestPlanReportService {
Map<String, String> apiTestCaseIdMap = new LinkedHashMap<>();
Map<String, String> performanceIdMap = new LinkedHashMap<>();
TestPlanApiScenarioExample scenarioCaseExample = new TestPlanApiScenarioExample();
scenarioCaseExample.createCriteria().andTestPlanIdEqualTo(planId);
List<TestPlanApiScenario> testPlanApiScenarioList = testPlanScenarioCaseMapper.selectByExample(scenarioCaseExample);
List<TestPlanApiScenario> testPlanApiScenarioList = extTestPlanScenarioCaseMapper.selectLegalDataByTestPlanId(planId);
for (TestPlanApiScenario model : testPlanApiScenarioList) {
planScenarioIdMap.put(model.getApiScenarioId(), model.getId());
}
TestPlanApiCaseExample apiCaseExample = new TestPlanApiCaseExample();
apiCaseExample.createCriteria().andTestPlanIdEqualTo(planId);
List<TestPlanApiCase> testPlanApiCaseList = testPlanApiCaseMapper.selectByExample(apiCaseExample);
List<TestPlanApiCase> testPlanApiCaseList = extTestPlanApiCaseMapper.selectLegalDataByTestPlanId(planId);
for (TestPlanApiCase model :
testPlanApiCaseList) {
apiTestCaseIdMap.put(model.getApiCaseId(), model.getId());
@ -203,16 +198,12 @@ public class TestPlanReportService {
Map<String, String> performanceInfoMap = new HashMap<>();
if (saveRequest.isCountResources()) {
TestPlanApiCaseExample apiExample = new TestPlanApiCaseExample();
apiExample.createCriteria().andTestPlanIdEqualTo(saveRequest.getPlanId());
List<String> apiCaseIdList = testPlanApiCaseMapper.selectByExample(apiExample)
.stream().map(TestPlanApiCase::getApiCaseId).collect(Collectors.toList());
List<TestPlanApiCase> testPlanApiCaseList = extTestPlanApiCaseMapper.selectLegalDataByTestPlanId(saveRequest.getPlanId());
List<String> apiCaseIdList = testPlanApiCaseList.stream().map(TestPlanApiCase::getApiCaseId).collect(Collectors.toList());
testPlanReport.setIsApiCaseExecuting(!apiCaseIdList.isEmpty());
TestPlanApiScenarioExample example = new TestPlanApiScenarioExample();
example.createCriteria().andTestPlanIdEqualTo(saveRequest.getPlanId());
List<String> scenarioIdList = testPlanScenarioCaseMapper.selectByExample(example)
.stream().map(TestPlanApiScenario::getApiScenarioId).collect(Collectors.toList());
List<TestPlanApiScenario> testPlanApiScenarioList = extTestPlanScenarioCaseMapper.selectLegalDataByTestPlanId(saveRequest.getPlanId());
List<String> scenarioIdList = testPlanApiScenarioList.stream().map(TestPlanApiScenario::getApiScenarioId).collect(Collectors.toList());
testPlanReport.setIsScenarioExecuting(!scenarioIdList.isEmpty());
LoadCaseRequest loadCaseRequest = new LoadCaseRequest();
@ -1012,7 +1003,7 @@ public class TestPlanReportService {
* @param testPlanReport
* @param performaneReportIDList
*/
public void updatePerformanceInfo(TestPlanReport testPlanReport, List<String> performaneReportIDList, String triggerMode) {
public void updatePerformanceInfo(TestPlanReport testPlanReport, Map<String,String> performaneReportIDMap, String triggerMode) {
// TestPlanReportDataExample example = new TestPlanReportDataExample();
// example.createCriteria().andTestPlanReportIdEqualTo(testPlanReport.getId());
// List<TestPlanReportDataWithBLOBs> reportDataList = testPlanReportDataMapper.selectByExampleWithBLOBs(example);
@ -1025,11 +1016,11 @@ public class TestPlanReportService {
* 虽然kafka已经设置了topic推送但是当执行机器性能不够时会影响到报告状态当修改
* 同时如果执行过程中报告删除那么此时也应当记为失败
*/
List<String> updatePerformaneReportIDList = new ArrayList<>(performaneReportIDList);
Map<String, String> finishLoadTestId = new HashMap<>();
executorService.submit(() -> {
//错误数据检查集合 如果错误数据出现超过20次则取消该条数据的检查
Map<String, Integer> errorDataCheckMap = new HashMap<>();
List<String> performaneReportIDList = new ArrayList<>(performaneReportIDMap.keySet());
while (performaneReportIDList.size() > 0) {
List<String> selectList = new ArrayList<>(performaneReportIDList);
for (String loadTestReportId : selectList) {
@ -1039,6 +1030,9 @@ public class TestPlanReportService {
if (errorDataCheckMap.containsKey(loadTestReportId)) {
if (errorDataCheckMap.get(loadTestReportId) > 10) {
performaneReportIDList.remove(loadTestReportId);
if(performaneReportIDMap.containsKey(loadTestReportId)){
finishLoadTestId.put(performaneReportIDMap.get(loadTestReportId), TestPlanApiExecuteStatus.FAILD.name());
}
} else {
errorDataCheckMap.put(loadTestReportId, errorDataCheckMap.get(loadTestReportId) + 1);
}
@ -1053,7 +1047,7 @@ public class TestPlanReportService {
}
if (performaneReportIDList.isEmpty()) {
if (StringUtils.equals(triggerMode, ReportTriggerMode.API.name())) {
for (String string : updatePerformaneReportIDList) {
for (String string : finishLoadTestId.keySet()) {
TestPlanLoadCaseEventDTO eventDTO = new TestPlanLoadCaseEventDTO();
eventDTO.setReportId(string);
eventDTO.setTriggerMode(triggerMode);

View File

@ -1027,7 +1027,7 @@ public class TestPlanService {
Map<String, String> executeScenarioCaseIdMap = new HashMap<>();
//执行性能测试任务
List<String> performaneReportIDList = new ArrayList<>();
Map<String,String> performaneReportIDMap = new LinkedHashMap<>();
for (Map.Entry<String, String> entry : performanceIdMap.entrySet()) {
String id = entry.getKey();
@ -1044,7 +1044,7 @@ public class TestPlanService {
try {
reportId = performanceTestService.run(performanceRequest);
if (reportId != null) {
performaneReportIDList.add(reportId);
performaneReportIDMap.put(reportId,caseID);
TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase();
testPlanLoadCase.setId(performanceRequest.getTestPlanLoadId());
testPlanLoadCase.setLoadReportId(reportId);
@ -1063,9 +1063,9 @@ public class TestPlanService {
executePerformanceIdMap.put(caseID, TestPlanApiExecuteStatus.RUNNING.name());
}
}
if (!performaneReportIDList.isEmpty()) {
if (!performaneReportIDMap.isEmpty()) {
//性能测试时保存性能测试报告ID在结果返回时用于捕捉并进行
testPlanReportService.updatePerformanceInfo(testPlanReport, performaneReportIDList, triggerMode);
testPlanReportService.updatePerformanceInfo(testPlanReport, performaneReportIDMap, triggerMode);
}

View File

@ -15,10 +15,13 @@
</div>
</div>
<div>
<div id="editorsDiv">
<mavon-editor v-if="showEditor" @imgAdd="imgAdd" :default-open="'edit'" class="mavon-editor" :imageFilter="imageFilter"
:toolbars="richDataToolbars" @imgDel="imgDel" v-model="textarea" ref="md"/>
<div class="editorsDivStyle">
<div id="editorsDiv" >
<mavon-editor v-if="showEditor" @imgAdd="imgAdd" :default-open="'edit'" class="review-mavon-editor" :imageFilter="imageFilter"
:toolbars="richDataToolbars" @imgDel="imgDel" v-model="textarea" ref="md"/>
</div>
</div>
<el-button type="primary" size="mini" class="send-btn"
v-permission="['PROJECT_TRACK_REVIEW:READ+COMMENT']"
@click="sendComment" :disabled="isReadOnly">
@ -186,4 +189,14 @@ export default {
.editors-div{
-webkit-box-shadow: 0 0 8px rgb(-1,0,0);
}
.editors_div_style {
height: 300px;
overflow: auto
}
.review-mavon-editor {
min-height: 20px;
height: 300px;
overflow: auto
}
</style>