fix(接口测试): 修复失败重跑状态统计错误问题

--bug=1018239 --user=赵勇 【接口测试】测试报告Case集合报告执行完成后显示状态不正确 https://www.tapd.cn/55049933/s/1264753
This commit is contained in:
fit2-zhao 2022-10-17 17:45:09 +08:00 committed by f2c-ci-robot[bot]
parent 671f609866
commit 631e3b3b6f
8 changed files with 30 additions and 30 deletions

View File

@ -158,7 +158,7 @@ public class ApiScenarioExecuteService {
if (request.isRerun()) {
ApiScenarioReportWithBLOBs report = new ApiScenarioReportWithBLOBs();
report.setId(serialReportId);
report.setStatus(ApiReportStatus.RUNNING.name());
report.setStatus(ApiReportStatus.RERUNNING.name());
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
} else {
LoggerUtil.info("Scenario run-执行脚本装载-初始化集成报告:" + serialReportId);

View File

@ -297,10 +297,6 @@ public class ApiScenarioReportService {
if (StringUtils.isNotEmpty(report.getTriggerMode()) && report.getTriggerMode().equals("CASE")) {
report.setTriggerMode(TriggerMode.MANUAL.name());
}
// UI 调试类型报告不记录更新状态
if (report.getExecuteType().equals(ExecuteType.Debug.name()) && report.getReportType().equals(ReportTypeConstants.UI_INDEPENDENT.name())) {
return report;
}
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
return report;
}

View File

@ -8,7 +8,7 @@ import io.metersphere.api.dto.automation.RunScenarioRequest;
import io.metersphere.api.exec.api.ApiCaseExecuteService;
import io.metersphere.api.exec.scenario.ApiScenarioExecuteService;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ApiScenarioMapper;
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
import io.metersphere.base.mapper.ext.ExtApiScenarioReportResultMapper;
import io.metersphere.commons.constants.ApiRunMode;
@ -28,10 +28,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;
@Service
@ -79,7 +76,8 @@ public class ApiScenarioRerunService {
if (CollectionUtils.isNotEmpty(reportResults)) {
List<String> resourceIds = reportResults.stream().map(ApiDefinitionExecResult::getResourceId).collect(Collectors.toList());
// 执行资源
Map<String, ApiDefinitionExecResultWithBLOBs> map = reportResults.stream().collect(Collectors.toMap(ApiDefinitionExecResult::getResourceId, api -> api));
LinkedHashMap<String, ApiDefinitionExecResultWithBLOBs> map = reportResults.stream().collect(
Collectors.toMap(ApiDefinitionExecResultWithBLOBs::getResourceId, order -> order, (k1, k2) -> k1, LinkedHashMap::new));
ApiCaseRunRequest request = new ApiCaseRunRequest();
request.setRerun(true);

View File

@ -424,6 +424,7 @@ public class ApiScenarioService {
* @param scenario
*/
public void deleteUpdateBodyFile(ApiScenarioWithBLOBs scenario, ApiScenarioWithBLOBs oldScenario) {
try {
Set<String> newRequestIds = getRequestIds(scenario.getScenarioDefinition());
MsTestElement msTestElement = GenerateHashTreeUtil.parseScenarioDefinition(oldScenario.getScenarioDefinition());
List<MsHTTPSamplerProxy> oldRequests = MsHTTPSamplerProxy.findHttpSampleFromHashTree(msTestElement);
@ -432,6 +433,9 @@ public class ApiScenarioService {
FileUtils.deleteBodyFiles(item.getId());
}
});
} catch (Exception e) {
LogUtil.error("Historical data processing exception");
}
}
public Set<String> getRequestIds(String scenarioDefinition) {
@ -707,6 +711,7 @@ public class ApiScenarioService {
if (scenarioWithBLOBs != null && StringUtils.isNotEmpty(scenarioWithBLOBs.getScenarioDefinition())) {
JSONObject element = JSONUtil.parseObject(scenarioWithBLOBs.getScenarioDefinition());
hashTreeService.dataFormatting(element);
ElementUtil.dataFormatting(element);
scenarioWithBLOBs.setScenarioDefinition(element.toString());
}
return scenarioWithBLOBs;
@ -1376,6 +1381,8 @@ public class ApiScenarioService {
for (int i = 0; i < data.size(); i++) {
ApiScenarioWithBLOBs item = data.get(i);
JSONObject jsonObject = JSONUtil.parseObject(JSON.toJSONString(item));
ElementUtil.dataFormatting(jsonObject);
if (StringUtils.isBlank(item.getName())) {
MSException.throwException(Translator.get("scenario_name_is_null"));
}

View File

@ -20,7 +20,7 @@
<!-- content header chart -->
<ms-metric-chart :content="content" :totalTime="totalTime" :report="report"/>
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tabs v-model="activeName" @tab-click="handleClick" style="min-width: 1000px">
<!-- all step-->
<el-tab-pane label="All" name="total">
<ms-scenario-results

View File

@ -29,7 +29,7 @@
@select-all="handleSelectAll"
@select="handleSelect"
:height="screenHeight"
@filter-change="filter" @row-click="handleView">
@filter-change="filter" @row-click="handleView" v-if="loadIsOver">
<el-table-column
type="selection"/>
<el-table-column width="40" :resizable="false" align="center">
@ -227,7 +227,7 @@ export default {
selectDataCounts: 0,
screenHeight: 'calc(100vh - 160px)',
trashActiveDom: 'left',
userFilters: []
userFilters: [],
}
},
watch: {
@ -274,12 +274,12 @@ export default {
}
if (this.trashActiveDom === 'left') {
this.reportTypeFilters = this.reportScenarioFilters;
getReportPage(this.currentPage, this.pageSize, this.condition).then(res => {
this.result = getReportPage(this.currentPage, this.pageSize, this.condition).then(res => {
this.setData(res);
})
} else {
this.reportTypeFilters = this.reportCaseFilters;
getApiReportPage(this.currentPage, this.pageSize, this.condition).then(res => {
this.result = getApiReportPage(this.currentPage, this.pageSize, this.condition).then(res => {
this.setData(res);
})
}
@ -288,17 +288,12 @@ export default {
let data = response.data;
this.total = data.itemCount;
this.tableData = data.listObject;
this.tableData.forEach(item => {
if (item.status === 'STOP') {
item.status = 'stopped'
}
})
this.selectRows.clear();
this.unSelection = data.listObject.map(s => s.id);
},
handleView(report) {
this.reportId = report.id;
if (report.status === 'Running' || report.status === 'Rerunning') {
if (report.status === 'RUNNING' || report.status === 'RERUNNING') {
this.$warning(this.$t('commons.run_warning'))
return;
}

View File

@ -227,4 +227,7 @@ export default {
.report-name {
border-bottom: 1px solid var(--primary_color);
}
.report-header{
min-width: 1000px;
}
</style>

View File

@ -171,6 +171,7 @@ export default {
{id: 'STARTING', label: 'Starting'},
{id: 'PENDING', label: 'Pending'},
{id: 'RUNNING', label: 'Running'},
{id: 'RERUNNING', label: 'Rerunning'},
{id: 'REPORTING', label: 'Reporting'},
{id: 'SUCCESS', label: 'Success'},
{id: "FAKE_ERROR", label: 'FakeError'},