fix(接口自动化): 修复批量执行集合报告,单个场景查看结果错误 #1005199
--bug=1005199 --user=赵勇 【接口自动化】-批量执... https://www.tapd.cn/55049933/s/1025792
This commit is contained in:
parent
986d24724a
commit
f9f49e6670
|
@ -325,7 +325,7 @@ public class ApiAutomationService {
|
|||
List<ApiScenario> list = apiScenarioMapper.selectByExample(example);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
return true;
|
||||
}else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -611,7 +611,7 @@ public class ApiAutomationService {
|
|||
}
|
||||
}
|
||||
if (http.isEnable()) {
|
||||
if (StringUtils.isBlank(http.getUrl()) || (http.getIsRefEnvironment()!= null && http.getIsRefEnvironment())) {
|
||||
if (StringUtils.isBlank(http.getUrl()) || (http.getIsRefEnvironment() != null && http.getIsRefEnvironment())) {
|
||||
env.getProjectIds().add(http.getProjectId());
|
||||
env.setFullUrl(false);
|
||||
}
|
||||
|
@ -643,7 +643,7 @@ public class ApiAutomationService {
|
|||
// 校验是否是全路径
|
||||
MsHTTPSamplerProxy httpSamplerProxy = (MsHTTPSamplerProxy) tr;
|
||||
if (httpSamplerProxy.isEnable()) {
|
||||
if (StringUtils.isBlank(httpSamplerProxy.getUrl()) || (httpSamplerProxy.getIsRefEnvironment()!= null && httpSamplerProxy.getIsRefEnvironment())) {
|
||||
if (StringUtils.isBlank(httpSamplerProxy.getUrl()) || (httpSamplerProxy.getIsRefEnvironment() != null && httpSamplerProxy.getIsRefEnvironment())) {
|
||||
env.getProjectIds().add(httpSamplerProxy.getProjectId());
|
||||
env.setFullUrl(false);
|
||||
}
|
||||
|
@ -684,7 +684,7 @@ public class ApiAutomationService {
|
|||
http.setUrl(apiDefinition.getPath());
|
||||
}
|
||||
if (http.isEnable()) {
|
||||
if (StringUtils.isBlank(http.getUrl()) || (http.getIsRefEnvironment()!= null && http.getIsRefEnvironment())) {
|
||||
if (StringUtils.isBlank(http.getUrl()) || (http.getIsRefEnvironment() != null && http.getIsRefEnvironment())) {
|
||||
env.setFullUrl(false);
|
||||
env.getProjectIds().add(http.getProjectId());
|
||||
}
|
||||
|
@ -1040,6 +1040,7 @@ public class ApiAutomationService {
|
|||
public void run() {
|
||||
List<String> reportIds = new LinkedList<>();
|
||||
for (APIScenarioReportResult key : map.keySet()) {
|
||||
key.setExecuteType(ExecuteType.Marge.name());
|
||||
apiScenarioReportMapper.insert(key);
|
||||
reportIds.add(key.getId());
|
||||
try {
|
||||
|
@ -2230,8 +2231,8 @@ public class ApiAutomationService {
|
|||
List<ApiScenarioWithBLOBs> apiScenarioList = extApiScenarioMapper.selectIds(ids);
|
||||
if (CollectionUtils.isEmpty(apiScenarioList)) {
|
||||
return returnList;
|
||||
}else {
|
||||
apiScenarioList.forEach(item ->{
|
||||
} else {
|
||||
apiScenarioList.forEach(item -> {
|
||||
String testName = item.getName();
|
||||
MsTestPlan testPlan = new MsTestPlan();
|
||||
testPlan.setHashTree(new LinkedList<>());
|
||||
|
@ -2250,10 +2251,10 @@ public class ApiAutomationService {
|
|||
ServiceUtils.getSelectAllIds(batchRequest, batchRequest.getCondition(),
|
||||
(query) -> extApiScenarioMapper.selectIdsByQuery((ApiScenarioRequest) query));
|
||||
List<ApiScenarioWithBLOBs> apiScenarioList = extApiScenarioMapper.selectIds(batchRequest.getIds());
|
||||
for (ApiScenarioWithBLOBs apiModel:apiScenarioList) {
|
||||
for (ApiScenarioWithBLOBs apiModel : apiScenarioList) {
|
||||
ApiScenarioWithBLOBs newModel = apiModel;
|
||||
newModel.setId(UUID.randomUUID().toString());
|
||||
newModel.setName("copy_"+apiModel.getName());
|
||||
newModel.setName("copy_" + apiModel.getName());
|
||||
newModel.setCreateTime(System.currentTimeMillis());
|
||||
newModel.setNum(getNextNum(newModel.getProjectId()));
|
||||
|
||||
|
@ -2262,7 +2263,7 @@ public class ApiAutomationService {
|
|||
andProjectIdEqualTo(newModel.getProjectId()).andStatusNotEqualTo("Trash").andIdNotEqualTo(newModel.getId());
|
||||
if (apiScenarioMapper.countByExample(example) > 0) {
|
||||
continue;
|
||||
}else {
|
||||
} else {
|
||||
boolean insertFlag = true;
|
||||
if (StringUtils.isNotBlank(newModel.getCustomNum())) {
|
||||
insertFlag = false;
|
||||
|
@ -2278,13 +2279,14 @@ public class ApiAutomationService {
|
|||
boolean isCustomNumExist = true;
|
||||
try {
|
||||
isCustomNumExist = this.isCustomNumExist(newModel);
|
||||
}catch (Exception e){}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
insertFlag = !isCustomNumExist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(insertFlag){
|
||||
if (insertFlag) {
|
||||
apiScenarioMapper.insert(newModel);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -421,6 +421,30 @@ public class ApiScenarioReportService {
|
|||
detail.setProjectId(report.getProjectId());
|
||||
apiScenarioReportDetailMapper.insert(detail);
|
||||
}
|
||||
// 更新场景状态
|
||||
if (StringUtils.isNotEmpty(report.getScenarioId())) {
|
||||
List<String> strings = JSON.parseObject(report.getScenarioId(), List.class);
|
||||
ApiScenarioExample scenarioExample = new ApiScenarioExample();
|
||||
scenarioExample.createCriteria().andIdIn(strings);
|
||||
|
||||
List<ApiScenario> scenarios = apiScenarioMapper.selectByExample(scenarioExample);
|
||||
if (CollectionUtils.isNotEmpty(scenarios)) {
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
ApiScenarioMapper scenarioReportMapper = sqlSession.getMapper(ApiScenarioMapper.class);
|
||||
scenarios.forEach(scenario -> {
|
||||
if (testResult.getError() > 0) {
|
||||
scenario.setLastResult("Fail");
|
||||
} else {
|
||||
scenario.setLastResult("Success");
|
||||
}
|
||||
String passRate = new DecimalFormat("0%").format((float) testResult.getSuccess() / (testResult.getSuccess() + testResult.getError()));
|
||||
scenario.setPassRate(passRate);
|
||||
scenario.setReportId(report.getId());
|
||||
scenarioReportMapper.updateByPrimaryKey(scenario);
|
||||
});
|
||||
sqlSession.flushStatements();
|
||||
}
|
||||
}
|
||||
// 清理其他报告保留一份合并后的报告
|
||||
this.deleteByIds(reportIds);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
SELECT tt.* FROM (
|
||||
(select t.id,if(t.scenario_id like "[\"%\"]", t.name,t.scenario_name) as name ,'SCENARIO' as executionModule, ifnull(t2.name,'LOCAL') as actuator, t1.`name` as executor,t.create_time as executionTime, t.trigger_mode as triggerMode ,t.status as executionStatus
|
||||
from api_scenario_report t left join `user` t1 ON t.user_id = t1.id left join test_resource_pool t2 on t.actuator = t2.id
|
||||
where to_days(FROM_UNIXTIME(t.create_time/1000))= to_days(now()) and t.execute_type !='Debug' and t.project_id= #{request.projectId}
|
||||
where to_days(FROM_UNIXTIME(t.create_time/1000))= to_days(now()) and t.execute_type !='Debug' and t.execute_type !='Marge' and t.project_id= #{request.projectId}
|
||||
<if test="request.triggerMode != null and request.triggerMode != ''">
|
||||
and t.trigger_mode = #{request.triggerMode}
|
||||
</if>
|
||||
|
|
|
@ -190,6 +190,11 @@
|
|||
<!-- 执行结果 -->
|
||||
<el-drawer :visible.sync="runVisible" :destroy-on-close="true" direction="ltr" :withHeader="true" :modal="false"
|
||||
size="90%">
|
||||
<sysn-api-report-detail @refresh="search" :infoDb="infoDb" :report-id="reportId" :currentProjectId="projectId"/>
|
||||
</el-drawer>
|
||||
<!-- 执行结果 -->
|
||||
<el-drawer :visible.sync="showReportVisible" :destroy-on-close="true" direction="ltr" :withHeader="true" :modal="false"
|
||||
size="90%">
|
||||
<ms-api-report-detail @refresh="search" :infoDb="infoDb" :report-id="reportId" :currentProjectId="projectId"/>
|
||||
</el-drawer>
|
||||
<!--测试计划-->
|
||||
|
@ -215,7 +220,8 @@ import MsTablePagination from "@/business/components/common/pagination/TablePagi
|
|||
import ShowMoreBtn from "@/business/components/track/case/components/ShowMoreBtn";
|
||||
import MsTag from "../../../common/components/MsTag";
|
||||
import {downloadFile, getCurrentProjectID, getUUID, objToStrMap, strMapToObj} from "@/common/js/utils";
|
||||
import MsApiReportDetail from "../report/SysnApiReportDetail";
|
||||
import SysnApiReportDetail from "../report/SysnApiReportDetail";
|
||||
import MsApiReportDetail from "../report/ApiReportDetail";
|
||||
import MsTableMoreBtn from "./TableMoreBtn";
|
||||
import MsScenarioExtendButtons from "@/business/components/api/automation/scenario/ScenarioExtendBtns";
|
||||
import MsTestPlanList from "./testplan/TestPlanList";
|
||||
|
@ -259,6 +265,7 @@ export default {
|
|||
MsTableHeader,
|
||||
MsTag,
|
||||
MsApiReportDetail,
|
||||
SysnApiReportDetail,
|
||||
MsScenarioExtendButtons,
|
||||
MsTestPlanList,
|
||||
MsTableOperatorButton,
|
||||
|
@ -332,6 +339,7 @@ export default {
|
|||
content: {},
|
||||
infoDb: false,
|
||||
runVisible: false,
|
||||
showReportVisible: false,
|
||||
planVisible: false,
|
||||
runData: [],
|
||||
report: {},
|
||||
|
@ -469,16 +477,16 @@ export default {
|
|||
}
|
||||
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
|
||||
|
||||
if(this.trashEnable){
|
||||
if (this.trashEnable) {
|
||||
this.condition.filters = {status: ["Trash"]};
|
||||
this.condition.moduleIds = [];
|
||||
this.operators = this.trashOperators;
|
||||
this.buttons = this.trashButtons;
|
||||
}else {
|
||||
} else {
|
||||
if (!this.isReferenceTable) {
|
||||
this.operators = this.unTrashOperators;
|
||||
this.buttons = this.unTrashButtons;
|
||||
}else {
|
||||
} else {
|
||||
this.operators = this.unTrashOperators;
|
||||
this.buttons = this.unTrashButtons;
|
||||
}
|
||||
|
@ -812,7 +820,7 @@ export default {
|
|||
this.$emit('edit', rowParam);
|
||||
},
|
||||
showReport(row) {
|
||||
this.runVisible = true;
|
||||
this.showReportVisible = true;
|
||||
this.infoDb = true;
|
||||
this.reportId = row.reportId;
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue