This commit is contained in:
chenjianxing 2021-02-02 16:14:45 +08:00
commit f70995e175
7 changed files with 107 additions and 95 deletions

View File

@ -179,9 +179,8 @@ public class TestPlanService {
else if (res.getStatus().equals(TestPlanStatus.Completed.name())) {
res.setActualEndTime(null);
} // 已完成->进行中结束时间置空
}
else if (!res.getStatus().equals(TestPlanStatus.Prepare.name()) &&
testPlan.getStatus().equals(TestPlanStatus.Prepare.name())) {
} else if (!StringUtils.equals(res.getStatus(), TestPlanStatus.Prepare.name()) &&
StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Prepare.name())) {
res.setActualStartTime(null);
res.setActualEndTime(null);
} // 非未开始->未开始时间都置空
@ -190,7 +189,9 @@ public class TestPlanService {
//已完成写入实际完成时间
res.setActualEndTime(System.currentTimeMillis());
}
res.setStatus(testPlan.getStatus());
if(StringUtils.isNotEmpty(testPlan.getStatus())){
res.setStatus(testPlan.getStatus());
}
}
List<String> userIds = new ArrayList<>();
@ -339,7 +340,7 @@ public class TestPlanService {
testPlanScenarioCaseService.deleteByPlanId(planId);
//删除定时任务
scheduleService.deleteScheduleAndJobByResourceId(planId,ScheduleGroup.TEST_PLAN_TEST.name());
scheduleService.deleteScheduleAndJobByResourceId(planId, ScheduleGroup.TEST_PLAN_TEST.name());
int num = testPlanMapper.deleteByPrimaryKey(planId);
List<String> relatedUsers = new ArrayList<>();
@ -438,7 +439,7 @@ public class TestPlanService {
}
public List<TestPlanDTOWithMetric> listTestPlanByProject(QueryTestPlanRequest request) {
List<TestPlanDTOWithMetric> testPlans=extTestPlanMapper.list(request);
List<TestPlanDTOWithMetric> testPlans = extTestPlanMapper.list(request);
return testPlans;
}
@ -785,12 +786,13 @@ public class TestPlanService {
}
return issues;
}
public List<TestPlanDTO> selectTestPlanByRelevancy(QueryTestPlanRequest params){
return extTestPlanMapper.selectTestPlanByRelevancy(params);
public List<TestPlanDTO> selectTestPlanByRelevancy(QueryTestPlanRequest params) {
return extTestPlanMapper.selectTestPlanByRelevancy(params);
}
public String findTestProjectNameByTestPlanID(String testPlanId) {
return extTestPlanMapper.findTestProjectNameByTestPlanID(testPlanId);
return extTestPlanMapper.findTestProjectNameByTestPlanID(testPlanId);
}
public String findScheduleCreateUserById(String testPlanId) {
@ -878,23 +880,23 @@ public class TestPlanService {
return request.getId();
}
public void run(String testPlanID,String projectID,String userId,String triggerMode){
Map<String,String> planScenarioIdMap;
Map<String,String> apiTestCaseIdMap;
Map<String,String> performanceIdMap;
public void run(String testPlanID, String projectID, String userId, String triggerMode) {
Map<String, String> planScenarioIdMap;
Map<String, String> apiTestCaseIdMap;
Map<String, String> performanceIdMap;
planScenarioIdMap = new LinkedHashMap<>();
apiTestCaseIdMap = new LinkedHashMap<>();
performanceIdMap = new LinkedHashMap<>();
List<TestPlanApiScenario> testPlanApiScenarioList = testPlanScenarioCaseService.getCasesByPlanId(testPlanID);
for (TestPlanApiScenario model :testPlanApiScenarioList) {
planScenarioIdMap.put(model.getApiScenarioId(),model.getId());
for (TestPlanApiScenario model : testPlanApiScenarioList) {
planScenarioIdMap.put(model.getApiScenarioId(), model.getId());
}
List<TestPlanApiCase> testPlanApiCaseList = testPlanApiCaseService.getCasesByPlanId(testPlanID);
for (TestPlanApiCase model :
testPlanApiCaseList) {
apiTestCaseIdMap.put(model.getApiCaseId(),model.getId());
apiTestCaseIdMap.put(model.getApiCaseId(), model.getId());
}
LoadCaseRequest loadCaseRequest = new LoadCaseRequest();
@ -902,24 +904,24 @@ public class TestPlanService {
loadCaseRequest.setProjectId(projectID);
List<TestPlanLoadCaseDTO> testPlanLoadCaseDTOList = testPlanLoadCaseService.list(loadCaseRequest);
for (TestPlanLoadCaseDTO dto : testPlanLoadCaseDTOList) {
performanceIdMap.put(dto.getId(),dto.getLoadCaseId());
performanceIdMap.put(dto.getId(), dto.getLoadCaseId());
}
LogUtil.info("-------------- start testplan schedule ----------");
TestPlanReportService testPlanReportService = CommonBeanFactory.getBean(TestPlanReportService.class);
//首先创建testPlanReport然后返回的ID重新赋值为resourceID作为后续的参数
TestPlanReport testPlanReport = testPlanReportService.genTestPlanReport(testPlanID,userId,triggerMode);
TestPlanReport testPlanReport = testPlanReportService.genTestPlanReport(testPlanID, userId, triggerMode);
//执行接口案例任务
for (Map.Entry<String,String> entry: apiTestCaseIdMap.entrySet()) {
for (Map.Entry<String, String> entry : apiTestCaseIdMap.entrySet()) {
String apiCaseID = entry.getKey();
String planCaseID = entry.getValue();
ApiTestCaseWithBLOBs blobs = apiTestCaseService.get(apiCaseID);
//需要更新这里来保证PlanCase的状态能正常更改
apiTestCaseService.run(blobs,UUID.randomUUID().toString(),testPlanReport.getId(),testPlanID,ApiRunMode.SCHEDULE_API_PLAN.name());
apiTestCaseService.run(blobs, UUID.randomUUID().toString(), testPlanReport.getId(), testPlanID, ApiRunMode.SCHEDULE_API_PLAN.name());
}
//执行场景执行任务
if(!planScenarioIdMap.isEmpty()){
if (!planScenarioIdMap.isEmpty()) {
LogUtil.info("-------------- testplan schedule ---------- api case over -----------------");
SchedulePlanScenarioExecuteRequest scenarioRequest = new SchedulePlanScenarioExecuteRequest();
String senarionReportID = UUID.randomUUID().toString();
@ -928,7 +930,7 @@ public class TestPlanService {
scenarioRequest.setProjectId(projectID);
scenarioRequest.setTriggerMode(ReportTriggerMode.SCHEDULE.name());
scenarioRequest.setExecuteType(ExecuteType.Saved.name());
Map<String, Map<String,String>> testPlanScenarioIdMap = new HashMap<>();
Map<String, Map<String, String>> testPlanScenarioIdMap = new HashMap<>();
testPlanScenarioIdMap.put(testPlanID, planScenarioIdMap);
scenarioRequest.setTestPlanScenarioIDMap(testPlanScenarioIdMap);
scenarioRequest.setReportUserID(userId);
@ -940,7 +942,7 @@ public class TestPlanService {
}
//执行性能测试任务
List<String> performaneReportIDList = new ArrayList<>();
for (Map.Entry<String,String> entry: performanceIdMap.entrySet()) {
for (Map.Entry<String, String> entry : performanceIdMap.entrySet()) {
String id = entry.getKey();
String caseID = entry.getValue();
RunTestPlanRequest performanceRequest = new RunTestPlanRequest();
@ -950,7 +952,7 @@ public class TestPlanService {
String reportId = null;
try {
reportId = performanceTestService.run(performanceRequest);
if(reportId!=null){
if (reportId != null) {
performaneReportIDList.add(reportId);
TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase();
@ -958,7 +960,7 @@ public class TestPlanService {
testPlanLoadCase.setLoadReportId(reportId);
testPlanLoadCaseService.update(testPlanLoadCase);
}
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
//更新关联处的报告
@ -968,9 +970,9 @@ public class TestPlanService {
testPlanLoadCaseService.update(loadCase);
}
if(!performaneReportIDList.isEmpty()){
if (!performaneReportIDList.isEmpty()) {
//性能测试时保存性能测试报告ID在结果返回时用于捕捉并进行
testPlanReportService.updatePerformanceInfo(testPlanReport,performaneReportIDList,ReportTriggerMode.SCHEDULE.name());
testPlanReportService.updatePerformanceInfo(testPlanReport, performaneReportIDList, ReportTriggerMode.SCHEDULE.name());
}
}
}

View File

@ -10,6 +10,7 @@
@sort-change="sort"
@filter-change="filter"
@select-all="select" @select="select"
@header-dragend="headerDragend"
v-loading="loading">
<el-table-column type="selection" width="50"/>
@ -20,7 +21,7 @@
@selectPageAll="isSelectDataAll(false)"
@selectAll="isSelectDataAll(true)"/>
<el-table-column v-if="!referenced" width="30" min-width="30" :render-header="labelHead" :resizable="false" align="center">
<el-table-column v-if="!referenced" width="30" min-width="30" :resizable="false" align="center">
<template v-slot:default="scope">
<show-more-btn :is-show="isSelect(scope.row)" :buttons="buttons" :size="selectDataCounts"/>
</template>
@ -28,7 +29,7 @@
<el-table-column prop="num" label="ID"
sortable="custom"
min-width="120px" :render-header="labelHead"
min-width="120px"
show-overflow-tooltip>
<template slot-scope="scope">
<el-tooltip content="编辑">
@ -40,14 +41,13 @@
sortable="custom"
:label="$t('api_test.automation.scenario_name')"
show-overflow-tooltip
:render-header="labelHead"
min-width="120px"/>
<el-table-column prop="level"
sortable="custom"
column-key="level"
:filters="levelFilters"
min-width="120px"
:render-header="labelHead"
:label="$t('api_test.automation.case_level')"
show-overflow-tooltip>
<template v-slot:default="scope">
@ -58,14 +58,14 @@
sortable="custom"
column-key="status"
:filters="statusFilters"
:render-header="labelHead"
show-overflow-tooltip min-width="120px">
<template v-slot:default="scope">
<plan-status-table-item :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column prop="tags" min-width="120px"
:render-header="labelHead" :label="$t('api_test.automation.tag')">
:label="$t('api_test.automation.tag')">
<template v-slot:default="scope">
<div v-for="(itemName,index) in scope.row.tags" :key="index">
<ms-tag type="success" effect="plain" :content="itemName"/>
@ -73,22 +73,22 @@
</template>
</el-table-column>
<el-table-column prop="userId" min-width="120px"
:render-header="labelHead" :label="$t('api_test.automation.creator')"
:label="$t('api_test.automation.creator')"
:filters="userFilters"
column-key="user_id"
sortable="custom"
show-overflow-tooltip/>
<el-table-column prop="updateTime" :label="$t('api_test.automation.update_time')" sortable="custom" min-width="180px"
:render-header="labelHead">
>
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column prop="stepTotal" :label="$t('api_test.automation.step')" min-width="80px"
:render-header="labelHead" show-overflow-tooltip/>
show-overflow-tooltip/>
<el-table-column prop="lastResult" :label="$t('api_test.automation.last_result')"
:filters="resultFilters"
:render-header="labelHead"
sortable="custom" column-key="last_result" min-width="120px">
<template v-slot:default="{row}">
<el-link type="success" @click="showReport(row)" v-if="row.lastResult === 'Success'">
@ -101,7 +101,7 @@
</el-table-column>
<el-table-column prop="passRate" :label="$t('api_test.automation.passing_rate')"
min-width="120px"
:render-header="labelHead"
show-overflow-tooltip/>
<el-table-column fixed="right" :label="$t('commons.operating')" width="190px" v-if="!referenced">
<template v-slot:default="{row}">
@ -609,12 +609,13 @@
_filter(filters, this.condition);
this.search();
},
labelHead(h,{column,index}){
if(column.minWidth>column.realWidth){
column.realWidth = column.minWidth;
column.width = column.minWidth;
headerDragend(newWidth,oldWidth,column,event){
let finalWidth = newWidth;
if(column.minWidth>finalWidth){
finalWidth = column.minWidth;
}
return column.label;
column.width = finalWidth;
column.realWidth = finalWidth;
},
openScenario(item) {
this.$emit('openScenario', item)

View File

@ -203,8 +203,9 @@
confirm() {
if (this.selection.length==0) {
this.$warning(this.$t("api_test.definition.request.test_plan_select"));
}else{
this.$emit('addTestPlan', this.selection);
}
this.$emit('addTestPlan', this.selection);
},
cancel(){
this.$emit('cancel');

View File

@ -15,6 +15,7 @@
@select-all="handleSelectAll"
@filter-change="filter"
@sort-change="sort"
@header-dragend="headerDragend"
@select="handleSelect" :height="screenHeight">
<el-table-column type="selection" width="50"/>
@ -25,13 +26,13 @@
@selectPageAll="isSelectDataAll(false)"
@selectAll="isSelectDataAll(true)"/>
<el-table-column width="30" :resizable="false" min-width="30px" :render-header="labelHead" align="center">
<el-table-column width="30" :resizable="false" min-width="30px" align="center">
<template v-slot:default="scope">
<show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectDataCounts"/>
</template>
</el-table-column>
<el-table-column prop="num" label="ID" min-width="120px" :render-header="labelHead" show-overflow-tooltip>
<el-table-column prop="num" label="ID" min-width="120px" show-overflow-tooltip>
<template slot-scope="scope">
<el-tooltip content="编辑">
<a style="cursor:pointer" @click="handleTestCase(scope.row)"> {{ scope.row.num }} </a>
@ -39,14 +40,14 @@
</template>
</el-table-column>
<el-table-column prop="name" min-width="160px" :render-header="labelHead" :label="$t('test_track.case.name')" show-overflow-tooltip/>
<el-table-column prop="name" min-width="160px" :label="$t('test_track.case.name')" show-overflow-tooltip/>
<el-table-column
prop="priority"
:filters="priorityFilters"
column-key="priority"
min-width="120px"
:render-header="labelHead"
:label="$t('test_track.case.priority')"
show-overflow-tooltip>
<template v-slot:default="scope">
@ -59,10 +60,10 @@
prop="path"
min-width="180px"
:label="$t('api_test.definition.api_path')"
:render-header="labelHead"
show-overflow-tooltip/>
<el-table-column prop="tags" min-width="120px" :render-header="labelHead" :label="$t('commons.tag')">
<el-table-column prop="tags" min-width="120px" :label="$t('commons.tag')">
<template v-slot:default="scope">
<div v-for="(itemName,index) in scope.row.tags" :key="index">
<ms-tag type="success" effect="plain" :content="itemName"/>
@ -73,14 +74,14 @@
<el-table-column
prop="createUser"
:label="'创建人'"
:render-header="labelHead"
show-overflow-tooltip/>
<el-table-column
sortable="custom"
min-width="160"
:label="$t('api_test.definition.api_last_time')"
:render-header="labelHead"
prop="updateTime">
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
@ -507,12 +508,13 @@ export default {
this.clickRow = row;
this.$refs.setEnvironment.open(row);
},
labelHead(h,{column,index}){
if(column.minWidth>column.realWidth){
column.realWidth = column.minWidth;
column.width = column.minWidth;
headerDragend(newWidth,oldWidth,column,event){
let finalWidth = newWidth;
if(column.minWidth>finalWidth){
finalWidth = column.minWidth;
}
return column.label;
column.width = finalWidth;
column.realWidth = finalWidth;
},
createPerformance(row, environment) {
/**

View File

@ -17,6 +17,7 @@
@filter-change="filter"
:data="tableData" row-key="id" class="test-content adjust-table ms-select-all-fixed"
@select-all="handleSelectAll"
@header-dragend="headerDragend"
@select="handleSelect" :height="screenHeight">
<el-table-column width="50" type="selection"/>
@ -34,7 +35,7 @@
<el-table-column prop="num" label="ID" show-overflow-tooltip
min-width="80px"
:render-header="labelHead"
sortable="custom">
<template slot-scope="scope">
<el-tooltip content="编辑">
@ -44,14 +45,14 @@
</el-table-column>
<el-table-column prop="name" :label="$t('api_test.definition.api_name')"
show-overflow-tooltip
:render-header="labelHead"
sortable="custom" min-width="120px"/>
<el-table-column
prop="status"
column-key="status"
sortable="custom"
:filters="statusFilters"
:render-header="labelHead"
:label="$t('api_test.definition.api_status')" min-width="120px">
<template v-slot:default="scope">
<span class="el-dropdown-link">
@ -65,7 +66,7 @@
sortable="custom"
column-key="method"
:filters="methodFilters"
:render-header="labelHead"
:label="$t('api_test.definition.api_type')"
show-overflow-tooltip min-width="120px">
<template v-slot:default="scope" class="request-method">
@ -82,19 +83,19 @@
sortable="custom"
:filters="userFilters"
column-key="user_id"
:render-header="labelHead"
:label="$t('api_test.definition.api_principal')"
show-overflow-tooltip min-width="100px"/>
<el-table-column
prop="path"
min-width="120px"
:render-header="labelHead"
:label="$t('api_test.definition.api_path')"
show-overflow-tooltip/>
<el-table-column prop="tags" :label="$t('commons.tag')" min-width="80px"
:render-header="labelHead">
>
<template v-slot:default="scope">
<div v-for="(itemName,index) in scope.row.tags" :key="index">
<ms-tag type="success" effect="plain" :content="itemName"/>
@ -107,7 +108,7 @@
:label="$t('api_test.definition.api_last_time')"
sortable="custom"
min-width="160px"
:render-header="labelHead"
prop="updateTime">
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
@ -117,14 +118,14 @@
<el-table-column
prop="caseTotal"
min-width="80px"
:render-header="labelHead"
:label="$t('api_test.definition.api_case_number')"
show-overflow-tooltip/>
<el-table-column
prop="caseStatus"
min-width="80px"
:render-header="labelHead"
:label="$t('api_test.definition.api_case_status')"
show-overflow-tooltip/>
@ -132,7 +133,7 @@
prop="casePassingRate"
:width="100"
min-width="100px"
:render-header="labelHead"
:label="$t('api_test.definition.api_case_passing_rate')"
show-overflow-tooltip/>
@ -693,12 +694,13 @@ export default {
_filter(filters, this.condition);
this.initTable();
},
labelHead(h,{column,index}){
if(column.minWidth>column.realWidth){
column.realWidth = column.minWidth;
column.width = column.minWidth;
headerDragend(newWidth,oldWidth,column,event){
let finalWidth = newWidth;
if(column.minWidth>finalWidth){
finalWidth = column.minWidth;
}
return column.label;
column.width = finalWidth;
column.realWidth = finalWidth;
},
open() {
this.$refs.searchBar.open();

View File

@ -29,6 +29,7 @@
@filter-change="filter"
@select-all="handleSelectAll"
@select="handleSelect"
@header-dragend="headerDragend"
@cell-mouse-enter="showPopover"
row-key="id"
class="test-content adjust-table ms-select-all-fixed"
@ -562,12 +563,13 @@ export default {
this.selectDataCounts = this.selectRows.size;
}
},
labelHead(h,{column,index}){
if(column.minWidth>column.realWidth){
column.realWidth = column.minWidth;
column.width = column.minWidth;
headerDragend(newWidth,oldWidth,column,event){
let finalWidth = newWidth;
if(column.minWidth>finalWidth){
finalWidth = column.minWidth;
}
return column.label;
column.width = finalWidth;
column.realWidth = finalWidth;
},
moveSave(param) {
param.condition = this.condition;

View File

@ -35,6 +35,7 @@
@select="handleSelectionChange"
row-key="id"
@row-click="showDetail"
@header-dragend="headerDragend"
:data="tableData">
<el-table-column
@ -49,14 +50,14 @@
sortable="custom"
:label="$t('commons.id')"
min-width="120px"
:render-header="labelHead"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="name"
:label="$t('commons.name')"
min-width="120px"
:render-header="labelHead"
show-overflow-tooltip>
</el-table-column>
<el-table-column
@ -64,7 +65,7 @@
:filters="priorityFilters"
column-key="priority"
min-width="100px"
:render-header="labelHead"
:label="$t('test_track.case.priority')">
<template v-slot:default="scope">
<priority-table-item :value="scope.row.priority" ref="priority"/>
@ -77,7 +78,7 @@
column-key="type"
:label="$t('test_track.case.type')"
min-width="80px"
:render-header="labelHead"
show-overflow-tooltip>
<template v-slot:default="scope">
<type-table-item :value="scope.row.type"/>
@ -85,7 +86,7 @@
</el-table-column>
<el-table-column prop="tags" :label="$t('commons.tag')" min-width="120px"
:render-header="labelHead">
>
<template v-slot:default="scope">
<div v-for="(tag, index) in scope.row.showTags" :key="tag + '_' + index">
<ms-tag type="success" effect="plain" :content="tag"/>
@ -99,7 +100,7 @@
column-key="method"
:label="$t('test_track.case.method')"
min-width="100px"
:render-header="labelHead"
show-overflow-tooltip>
<template v-slot:default="scope">
<method-table-item :value="scope.row.method"/>
@ -110,7 +111,7 @@
prop="nodePath"
:label="$t('test_track.case.module')"
min-width="120px"
:render-header="labelHead"
show-overflow-tooltip>
</el-table-column>
@ -118,14 +119,14 @@
prop="projectName"
:label="$t('test_track.plan.plan_project')"
min-width="120px"
:render-header="labelHead"
show-overflow-tooltip>
</el-table-column>
<el-table-column
:label="$t('test_track.issue.issue')"
min-width="80px"
:render-header="labelHead"
show-overflow-tooltip>
<template v-slot:default="scope">
<el-popover
@ -159,7 +160,7 @@
prop="executorName"
:filters="executorFilters"
min-width="100px"
:render-header="labelHead"
column-key="executor"
:label="$t('test_track.plan_view.executor')">
</el-table-column>
@ -169,7 +170,7 @@
:filters="statusFilters"
column-key="status"
min-width="100px"
:render-header="labelHead"
:label="$t('test_track.plan_view.execute_result')">
<template v-slot:default="scope">
<span @click.stop="clickt = 'stop'">
@ -203,7 +204,7 @@
prop="updateTime"
:label="$t('commons.update_time')"
min-width="120px"
:render-header="labelHead"
show-overflow-tooltip>
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
@ -595,12 +596,13 @@ export default {
_sort(column, this.condition);
this.initTableData();
},
labelHead(h,{column,index}){
if(column.minWidth>column.realWidth){
column.realWidth = column.minWidth;
column.width = column.minWidth;
headerDragend(newWidth,oldWidth,column,event){
let finalWidth = newWidth;
if(column.minWidth>finalWidth){
finalWidth = column.minWidth;
}
return column.label;
column.width = finalWidth;
column.realWidth = finalWidth;
},
batchEdit(form) {
let param = {};