refactor(任务中心) 重构任务中心,增加按照人员统计,增加等待状态。

This commit is contained in:
fit2-zhao 2021-07-20 15:18:54 +08:00 committed by fit2-zhao
parent 317fcb5819
commit 2fb2a77481
14 changed files with 192 additions and 81 deletions

View File

@ -1,5 +1,6 @@
package io.metersphere.api.dto;
import io.metersphere.api.dto.automation.APIScenarioReportResult;
import lombok.Getter;
import lombok.Setter;
import org.apache.jorphan.collections.HashTree;
@ -11,15 +12,28 @@ public class RunModeDataDTO {
private HashTree hashTree;
// 测试场景/测试用例
private String testId;
// 报告id
private String reportId;
public RunModeDataDTO(String testId,String reportId) {
// 初始化报告
private APIScenarioReportResult report;
//
private String apiCaseId;
public RunModeDataDTO(String testId, String apiCaseId) {
this.testId = testId;
this.reportId = reportId;
this.apiCaseId = apiCaseId;
}
public RunModeDataDTO(HashTree hashTree,String reportId) {
public RunModeDataDTO(HashTree hashTree, String apiCaseId) {
this.hashTree = hashTree;
this.reportId = reportId;
this.apiCaseId = apiCaseId;
}
public RunModeDataDTO(String testId, APIScenarioReportResult report) {
this.testId = testId;
this.report = report;
}
public RunModeDataDTO(HashTree hashTree, APIScenarioReportResult report) {
this.hashTree = hashTree;
this.report = report;
}
}

View File

@ -958,7 +958,7 @@ public class ApiAutomationService {
request.setTriggerMode(ReportTriggerMode.MANUAL.name());
}
String reportId = request.getId();
Map<APIScenarioReportResult, RunModeDataDTO> map = new LinkedHashMap<>();
Map<String, RunModeDataDTO> executeQueue = new LinkedHashMap<>();
List<String> scenarioIds = new ArrayList<>();
StringBuilder scenarioNames = new StringBuilder();
// 按照场景执行
@ -994,11 +994,11 @@ public class ApiAutomationService {
}
try {
if (request.getConfig() != null && StringUtils.isNotBlank(request.getConfig().getResourcePoolId())) {
map.put(report, new RunModeDataDTO(item.getId(), report.getId()));
executeQueue.put(report.getId(), new RunModeDataDTO(item.getId(), report));
} else {
// 生成报告和HashTree
HashTree hashTree = generateHashTree(item, reportId, planEnvMap);
map.put(report, new RunModeDataDTO(hashTree, report.getId()));
executeQueue.put(report.getId(), new RunModeDataDTO(hashTree, report));
}
scenarioIds.add(item.getId());
scenarioNames.append(item.getName()).append(",");
@ -1021,9 +1021,9 @@ public class ApiAutomationService {
apiScenarioReportMapper.insert(report);
// 增加并行集合报告
if (request.getConfig() != null && request.getConfig().getMode().equals(RunModeConstants.PARALLEL.toString())) {
List<String> reportIds = map.keySet().stream()
.collect(Collectors.toList()).stream()
.map(ApiScenarioReport::getId).collect(Collectors.toList());
List<String> reportIds = executeQueue.entrySet().stream()
.map(reports -> reports.getKey())
.collect(Collectors.toList());
ReportCounter counter = new ReportCounter();
counter.setNumber(0);
counter.setReportIds(reportIds);
@ -1031,57 +1031,84 @@ public class ApiAutomationService {
}
}
// 开始执行
this.run(map, request, serialReportId);
this.run(executeQueue, request, serialReportId);
return request.getId();
}
private void run(Map<APIScenarioReportResult, RunModeDataDTO> map, RunScenarioRequest request, String serialReportId) {
private void run(Map<String, RunModeDataDTO> executeQueue, RunScenarioRequest request, String serialReportId) {
// 开始选择执行模式
if (map != null && map.size() > 0) {
ExecutorService executorService = Executors.newFixedThreadPool(map.size());
if (executeQueue != null && executeQueue.size() > 0) {
ExecutorService executorService = Executors.newFixedThreadPool(executeQueue.size());
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
ApiScenarioReportMapper batchMapper = sqlSession.getMapper(ApiScenarioReportMapper.class);
if (request.getConfig() != null && request.getConfig().getMode().equals(RunModeConstants.SERIAL.toString())) {
// 非集合报告先生成执行队列
if (StringUtils.isEmpty(serialReportId)) {
for (String reportId : executeQueue.keySet()) {
APIScenarioReportResult report = executeQueue.get(reportId).getReport();
report.setStatus(APITestStatus.Waiting.name());
batchMapper.insert(report);
}
sqlSession.flushStatements();
}
// 开始串行执行
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
List<String> reportIds = new LinkedList<>();
for (APIScenarioReportResult key : map.keySet()) {
for (String key : executeQueue.keySet()) {
reportIds.add(key);
APIScenarioReportResult report = executeQueue.get(key).getReport();
if (StringUtils.isNotEmpty(serialReportId)) {
key.setExecuteType(ExecuteType.Marge.name());
report.setExecuteType(ExecuteType.Marge.name());
apiScenarioReportMapper.insert(report);
} else {
report.setStatus(APITestStatus.Running.name());
report.setCreateTime(System.currentTimeMillis());
report.setUpdateTime(System.currentTimeMillis());
apiScenarioReportMapper.updateByPrimaryKey(report);
}
apiScenarioReportMapper.insert(key);
reportIds.add(key.getId());
try {
Future<ApiScenarioReport> future = executorService.submit(new SerialScenarioExecTask(jMeterService, apiScenarioReportMapper, map.get(key), request));
ApiScenarioReport report = future.get();
Future<ApiScenarioReport> future = executorService.submit(new SerialScenarioExecTask(jMeterService, apiScenarioReportMapper, executeQueue.get(key), request));
ApiScenarioReport scenarioReport = future.get();
// 如果开启失败结束执行则判断返回结果状态
if (request.getConfig().isOnSampleError()) {
if (report == null || !report.getStatus().equals("Success")) {
if (scenarioReport == null || !scenarioReport.getStatus().equals("Success")) {
reportIds.remove(key);
break;
}
}
} catch (Exception e) {
reportIds.remove(key);
LogUtil.error("执行终止:" + e.getMessage());
break;
}
}
// 清理未执行的队列
if (reportIds.size() < executeQueue.size()) {
List<String> removeList = executeQueue.entrySet().stream()
.filter(map -> !reportIds.contains(map.getKey()))
.map(map -> map.getKey()).collect(Collectors.toList());
ApiScenarioReportExample example = new ApiScenarioReportExample();
example.createCriteria().andIdIn(removeList);
apiScenarioReportMapper.deleteByExample(example);
}
// 更新集成报告
if (StringUtils.isNotEmpty(serialReportId)) {
apiScenarioReportService.margeReport(serialReportId, reportIds);
map.clear();
executeQueue.clear();
}
}
});
thread.start();
} else {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
ApiScenarioReportMapper batchMapper = sqlSession.getMapper(ApiScenarioReportMapper.class);
// 开始并发执行
for (APIScenarioReportResult report : map.keySet()) {
for (String reportId : executeQueue.keySet()) {
//存储报告
APIScenarioReportResult report = executeQueue.get(reportId).getReport();
batchMapper.insert(report);
executorService.submit(new ParallelScenarioExecTask(jMeterService, map.get(report), request));
executorService.submit(new ParallelScenarioExecTask(jMeterService, executeQueue.get(report), request));
}
sqlSession.flushStatements();
}
@ -2238,9 +2265,9 @@ public class ApiAutomationService {
}
}
public void checkApiScenarioReferenceId(){
public void checkApiScenarioReferenceId() {
List<ApiScenarioWithBLOBs> scenarioNoRefs = extApiScenarioMapper.selectByNoReferenceId();
for (ApiScenarioWithBLOBs model :scenarioNoRefs) {
for (ApiScenarioWithBLOBs model : scenarioNoRefs) {
apiScenarioReferenceIdService.saveByApiScenario(model);
}
}
@ -2325,38 +2352,38 @@ public class ApiAutomationService {
DeleteCheckResult result = new DeleteCheckResult();
List<String> checkMsgList = new ArrayList<>();
if(CollectionUtils.isNotEmpty(deleteIds)){
List<ApiScenarioReferenceId> apiScenarioReferenceIdList = apiScenarioReferenceIdService.findByReferenceIdsAndRefType(deleteIds,MsTestElementConstants.REF.name());
if(CollectionUtils.isNotEmpty(apiScenarioReferenceIdList)){
Map<String,List<String>> scenarioDic = new HashMap<>();
apiScenarioReferenceIdList.forEach( item ->{
if (CollectionUtils.isNotEmpty(deleteIds)) {
List<ApiScenarioReferenceId> apiScenarioReferenceIdList = apiScenarioReferenceIdService.findByReferenceIdsAndRefType(deleteIds, MsTestElementConstants.REF.name());
if (CollectionUtils.isNotEmpty(apiScenarioReferenceIdList)) {
Map<String, List<String>> scenarioDic = new HashMap<>();
apiScenarioReferenceIdList.forEach(item -> {
String refreceID = item.getReferenceId();
String scenarioId = item.getApiScenarioId();
if(scenarioDic.containsKey(refreceID)){
if (scenarioDic.containsKey(refreceID)) {
scenarioDic.get(refreceID).add(scenarioId);
}else {
} else {
List<String> list = new ArrayList<>();
list.add(scenarioId);
scenarioDic.put(refreceID,list);
scenarioDic.put(refreceID, list);
}
});
for (Map.Entry<String,List<String>> entry : scenarioDic.entrySet()){
for (Map.Entry<String, List<String>> entry : scenarioDic.entrySet()) {
String refreceId = entry.getKey();
List<String> scenarioIdList = entry.getValue();
if(CollectionUtils.isNotEmpty(scenarioIdList)){
String deleteScenarioName= extApiScenarioMapper.selectNameById(refreceId);
if (CollectionUtils.isNotEmpty(scenarioIdList)) {
String deleteScenarioName = extApiScenarioMapper.selectNameById(refreceId);
List<String> scenarioNames = extApiScenarioMapper.selectNameByIdIn(scenarioIdList);
if(StringUtils.isNotEmpty(deleteScenarioName) && CollectionUtils.isNotEmpty(scenarioNames)){
if (StringUtils.isNotEmpty(deleteScenarioName) && CollectionUtils.isNotEmpty(scenarioNames)) {
String nameListStr = "";
for (String name : scenarioNames) {
nameListStr+= name +",";
nameListStr += name + ",";
}
if(nameListStr.length() > 1){
nameListStr = nameListStr.substring(0,nameListStr.length()-1) + "";
if (nameListStr.length() > 1) {
nameListStr = nameListStr.substring(0, nameListStr.length() - 1) + "";
}
String msg = deleteScenarioName+" "+Translator.get("delete_check_reference_by")+": "+nameListStr+" ";
String msg = deleteScenarioName + " " + Translator.get("delete_check_reference_by") + ": " + nameListStr + " ";
checkMsgList.add(msg);
}
}

View File

@ -27,9 +27,9 @@ public class ParallelScenarioExecTask<T> implements Callable<T> {
public T call() {
try {
if (request.getConfig() != null && StringUtils.isNotBlank(request.getConfig().getResourcePoolId())) {
jMeterService.runTest(runModeDataDTO.getTestId(), runModeDataDTO.getReportId(), request.getRunMode(), request.getPlanScenarioId(), request.getConfig());
jMeterService.runTest(runModeDataDTO.getTestId(), runModeDataDTO.getReport().getId(), request.getRunMode(), request.getPlanScenarioId(), request.getConfig());
} else {
jMeterService.runLocal(runModeDataDTO.getReportId(), runModeDataDTO.getHashTree(), request.getReportId(), request.getRunMode());
jMeterService.runLocal(runModeDataDTO.getReport().getId(), runModeDataDTO.getHashTree(), request.getReportId(), request.getRunMode());
}
return null;
} catch (Exception ex) {

View File

@ -33,16 +33,16 @@ public class SerialScenarioExecTask<T> implements Callable<T> {
public T call() {
try {
if (request.getConfig() != null && StringUtils.isNotBlank(request.getConfig().getResourcePoolId())) {
jMeterService.runTest(runModeDataDTO.getTestId(), runModeDataDTO.getReportId(), request.getRunMode(), request.getPlanScenarioId(), request.getConfig());
jMeterService.runTest(runModeDataDTO.getTestId(), runModeDataDTO.getReport().getId(), request.getRunMode(), request.getPlanScenarioId(), request.getConfig());
} else {
jMeterService.runLocal(runModeDataDTO.getReportId(), runModeDataDTO.getHashTree(), request.getReportId(), request.getRunMode());
jMeterService.runLocal(runModeDataDTO.getReport().getId(), runModeDataDTO.getHashTree(), request.getReportId(), request.getRunMode());
}
// 轮询查看报告状态最多200次防止死循环
int index = 1;
while (index < 200) {
Thread.sleep(3000);
index++;
report = apiScenarioReportMapper.selectByPrimaryKey(runModeDataDTO.getReportId());
report = apiScenarioReportMapper.selectByPrimaryKey(runModeDataDTO.getReport().getId());
if (report != null && !report.getStatus().equals(APITestStatus.Running.name())) {
break;
}

View File

@ -13,6 +13,9 @@
<if test="request.executionStatus != null and request.executionStatus != ''">
and t.status = #{request.executionStatus}
</if>
<if test="request.executor != null and request.executor != ''">
and t.user_id = #{request.executor}
</if>
)
UNION ALL
(select t.id,t.name,'API' as executionModule, ifnull(t2.name,'LOCAL') as actuator, t1.`name` as executor,t.create_time as executionTime, ifnull(t.trigger_mode,'MANUAL') as triggerMode ,ifnull(t.status,'Saved') as executionStatus
@ -27,7 +30,10 @@
<if test="request.executionStatus != null and request.executionStatus != ''">
and t.status = #{request.executionStatus}
</if>
)
<if test="request.executor != null and request.executor != ''">
and t.user_id = #{request.executor}
</if>
)
UNION ALL
(select t.id,t.name,'PERFORMANCE' 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 load_test_report t left join `user` t1 ON t.user_id = t1.id left join test_resource_pool t2 on t.test_resource_pool_id = t2.id
@ -38,8 +44,14 @@
<if test="request.executionStatus != null and request.executionStatus != ''">
and t.status = #{request.executionStatus}
</if>
<if test="request.executor != null and request.executor != ''">
and t1.name = #{request.executor}
</if>
<if test="request.executor != null and request.executor != ''">
and t.user_id = #{request.executor}
</if>
)
)tt ORDER BY tt.executionTime DESC;
)tt ORDER BY FIELD(tt.executionStatus, 'Running', 'Waiting', 'Error', 'Success'),tt.executionTime DESC;
</select>
@ -47,7 +59,7 @@
SELECT tt.* FROM (
(select t.id,t.create_time as executionTime
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} and t.status not in ("saved","completed","success","error")
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} and t.status not in ("saved","completed","success","error")
)
UNION ALL
(select t.id,t.create_time as executionTime

View File

@ -1,5 +1,5 @@
package io.metersphere.commons.constants;
public enum APITestStatus {
Saved, Starting, Running, Reporting, Completed, Debug, Error, Success,Underway
Saved, Starting, Running, Reporting, Completed, Debug, Error, Success,Underway,Waiting
}

View File

@ -14,5 +14,8 @@ public class TaskCenterRequest {
* 执行状态
*/
private String executionStatus;
/**
* 执行人
*/
private String executor;
}

View File

@ -42,6 +42,9 @@ import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest;
import io.metersphere.track.service.task.ParallelApiExecTask;
import io.metersphere.track.service.task.SerialApiExecTask;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.jorphan.collections.HashTree;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -78,6 +81,8 @@ public class TestPlanApiCaseService {
private JMeterService jMeterService;
@Resource
private ApiDefinitionExecResultMapper mapper;
@Resource
SqlSessionFactory sqlSessionFactory;
public TestPlanApiCase getInfo(String caseId, String testPlanId) {
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
@ -344,7 +349,7 @@ public class TestPlanApiCaseService {
return null;
}
private String addResult(BatchRunDefinitionRequest request, TestPlanApiCase key) {
private ApiDefinitionExecResult addResult(BatchRunDefinitionRequest request, TestPlanApiCase key, String status, ApiDefinitionExecResultMapper batchMapper) {
ApiDefinitionExecResult apiResult = new ApiDefinitionExecResult();
apiResult.setId(UUID.randomUUID().toString());
apiResult.setCreateTime(System.currentTimeMillis());
@ -363,10 +368,9 @@ public class TestPlanApiCaseService {
apiResult.setResourceId(key.getApiCaseId());
apiResult.setStartTime(System.currentTimeMillis());
apiResult.setType(ApiRunMode.API_PLAN.name());
apiResult.setStatus(APITestStatus.Running.name());
mapper.insert(apiResult);
return apiResult.getId();
apiResult.setStatus(status);
batchMapper.insert(apiResult);
return apiResult;
}
public String modeRun(BatchRunDefinitionRequest request) {
@ -374,38 +378,62 @@ public class TestPlanApiCaseService {
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
example.createCriteria().andIdIn(ids);
List<TestPlanApiCase> planApiCases = testPlanApiCaseMapper.selectByExample(example);
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
ApiDefinitionExecResultMapper batchMapper = sqlSession.getMapper(ApiDefinitionExecResultMapper.class);
// 开始选择执行模式
ExecutorService executorService = Executors.newFixedThreadPool(planApiCases.size());
if (request.getConfig() != null && request.getConfig().getMode().equals(RunModeConstants.SERIAL.toString())) {
Map<TestPlanApiCase, ApiDefinitionExecResult> executeQueue = new HashMap<>();
planApiCases.forEach(testPlanApiCase -> {
ApiDefinitionExecResult report = addResult(request, testPlanApiCase, APITestStatus.Waiting.name(), batchMapper);
executeQueue.put(testPlanApiCase, report);
});
sqlSession.flushStatements();
List<String> reportIds = new LinkedList<>();
// 开始串行执行
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
for (TestPlanApiCase key : planApiCases) {
for (TestPlanApiCase testPlanApiCase : executeQueue.keySet()) {
try {
ApiDefinitionExecResult execResult = executeQueue.get(testPlanApiCase);
execResult.setId(executeQueue.get(testPlanApiCase).getId());
execResult.setStatus(APITestStatus.Running.name());
mapper.updateByPrimaryKey(execResult);
reportIds.add(execResult.getId());
RunModeDataDTO modeDataDTO;
if (request.getConfig()!= null && StringUtils.isNotBlank(request.getConfig().getResourcePoolId())) {
modeDataDTO = new RunModeDataDTO(key.getId(), UUID.randomUUID().toString());
if (request.getConfig() != null && StringUtils.isNotBlank(request.getConfig().getResourcePoolId())) {
modeDataDTO = new RunModeDataDTO(testPlanApiCase.getId(), UUID.randomUUID().toString());
} else {
// 生成报告和HashTree
HashTree hashTree = generateHashTree(key.getId());
HashTree hashTree = generateHashTree(testPlanApiCase.getId());
modeDataDTO = new RunModeDataDTO(hashTree, UUID.randomUUID().toString());
}
String reportId = addResult(request, key);
modeDataDTO.setReportId(reportId);
modeDataDTO.setApiCaseId(execResult.getId());
Future<ApiDefinitionExecResult> future = executorService.submit(new SerialApiExecTask(jMeterService, mapper, modeDataDTO, request.getConfig(), ApiRunMode.API_PLAN.name()));
ApiDefinitionExecResult report = future.get();
// 如果开启失败结束执行则判断返回结果状态
if (request.getConfig().isOnSampleError()) {
if (report == null || !report.getStatus().equals("Success")) {
reportIds.remove(execResult.getId());
break;
}
}
} catch (Exception e) {
reportIds.remove(executeQueue.get(testPlanApiCase).getId());
LogUtil.error("执行终止:" + e.getMessage());
break;
}
}
// 清理未执行的队列
if (reportIds.size() < executeQueue.size()) {
List<String> removeList = executeQueue.entrySet().stream()
.filter(map -> !reportIds.contains(map.getValue().getId()))
.map(map -> map.getValue().getId()).collect(Collectors.toList());
ApiDefinitionExecResultExample example = new ApiDefinitionExecResultExample();
example.createCriteria().andIdIn(removeList);
mapper.deleteByExample(example);
}
}
});
thread.start();
@ -420,10 +448,11 @@ public class TestPlanApiCaseService {
HashTree hashTree = generateHashTree(key.getId());
modeDataDTO = new RunModeDataDTO(hashTree, UUID.randomUUID().toString());
}
String reportId = addResult(request, key);
modeDataDTO.setReportId(reportId);
ApiDefinitionExecResult report = addResult(request, key, APITestStatus.Running.name(), batchMapper);
modeDataDTO.setApiCaseId(report.getId());
executorService.submit(new ParallelApiExecTask(jMeterService, mapper, modeDataDTO, request.getConfig(), ApiRunMode.API_PLAN.name()));
}
sqlSession.flushStatements();
}
return request.getId();
}
@ -446,10 +475,8 @@ public class TestPlanApiCaseService {
if (request.getPlanIds().size() > count) {
MSException.throwException("并发数量过大,请重新选择!");
}
return this.modeRun(request);
} else {
return this.modeRun(request);
}
return this.modeRun(request);
}
return request.getId();
}

View File

@ -32,9 +32,9 @@ public class ParallelApiExecTask<T> implements Callable<T> {
public T call() {
try {
if (config != null && StringUtils.isNotBlank(config.getResourcePoolId())) {
jMeterService.runTest(runModeDataDTO.getTestId(), runModeDataDTO.getReportId(), runMode, null, config);
jMeterService.runTest(runModeDataDTO.getTestId(), runModeDataDTO.getApiCaseId(), runMode, null, config);
} else {
jMeterService.runLocal(runModeDataDTO.getReportId(), runModeDataDTO.getHashTree(), null, runMode);
jMeterService.runLocal(runModeDataDTO.getApiCaseId(), runModeDataDTO.getHashTree(), null, runMode);
}
return null;
} catch (Exception ex) {

View File

@ -34,9 +34,9 @@ public class SerialApiExecTask<T> implements Callable<T> {
public T call() {
try {
if (config != null && StringUtils.isNotBlank(config.getResourcePoolId())) {
jMeterService.runTest(runModeDataDTO.getTestId(), runModeDataDTO.getReportId(), runMode, null, config);
jMeterService.runTest(runModeDataDTO.getTestId(), runModeDataDTO.getApiCaseId(), runMode, null, config);
} else {
jMeterService.runLocal(runModeDataDTO.getReportId(), runModeDataDTO.getHashTree(), null, runMode);
jMeterService.runLocal(runModeDataDTO.getApiCaseId(), runModeDataDTO.getHashTree(), null, runMode);
}
// 轮询查看报告状态最多200次防止死循环
ApiDefinitionExecResult report = null;
@ -44,7 +44,7 @@ public class SerialApiExecTask<T> implements Callable<T> {
while (index < 200) {
Thread.sleep(3000);
index++;
report = mapper.selectByPrimaryKey(runModeDataDTO.getReportId());
report = mapper.selectByPrimaryKey(runModeDataDTO.getApiCaseId());
if (report != null && !report.getStatus().equals(APITestStatus.Running.name())) {
break;
}

View File

@ -27,25 +27,38 @@
<div style="color: #2B415C;margin: 0px 20px 0px">
<el-form label-width="68px">
<el-row>
<el-col :span="12">
<el-col :span="8">
<el-form-item :label="$t('test_track.report.list.trigger_mode')" prop="runMode">
<el-select size="small" style="margin-right: 10px" v-model="condition.triggerMode" @change="init">
<el-option v-for="item in runMode" :key="item.id" :value="item.id" :label="item.label"/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-col :span="8">
<el-form-item :label="$t('commons.status')" prop="status">
<el-select size="small" style="margin-right: 10px" v-model="condition.executionStatus" @change="init">
<el-option v-for="item in runStatus" :key="item.id" :value="item.id" :label="item.label"/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item :label="$t('commons.executor')" prop="status">
<el-select v-model="condition.executor" :placeholder="$t('commons.executor')" filterable size="small"
style="margin-right: 10px" @change="init">
<el-option
v-for="item in maintainerOptions"
:key="item.id"
:label="item.id + ' (' + item.name + ')'"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
<div class="report-container" v-loading="result.loading">
<div class="report-container">
<div v-for="item in taskData" :key="item.id" style="margin-bottom: 5px">
<el-card class="ms-card-task" @click.native="showReport(item,$event)">
<span>{{ item.name }} </span><br/>
@ -84,7 +97,7 @@
<script>
import MsDrawer from "../common/components/MsDrawer";
import {getCurrentProjectID, hasPermissions} from "@/common/js/utils";
import {getCurrentProjectID, getCurrentUser, hasPermissions} from "@/common/js/utils";
import MsRequestResultTail from "../../components/api/definition/components/response/RequestResultTail";
export default {
@ -123,6 +136,7 @@ export default {
{id: 'success', label: 'Success'}
],
condition: {triggerMode: "", executionStatus: ""},
maintainerOptions: [],
};
},
props: {
@ -131,12 +145,19 @@ export default {
created() {
if (hasPermissions('PROJECT_API_SCENARIO:READ')) {
this.getTaskRunning();
this.condition.executor = getCurrentUser().id;
}
},
methods: {
format(item) {
return '';
},
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.maintainerOptions = response.data;
this.condition.executor = getCurrentUser().id;
});
},
initWebSocket() {
let protocol = "ws://";
if (window.location.protocol === 'https:') {
@ -172,6 +193,7 @@ export default {
},
showTaskCenter() {
this.getTaskRunning();
this.getMaintainerOptions();
this.init();
this.taskVisible = true;
},
@ -186,6 +208,9 @@ export default {
getPercentage(status) {
if (status) {
status = status.toLowerCase();
if (status === "waiting") {
return 0;
}
if (status === 'saved' || status === 'completed' || status === 'success' || status === 'error') {
return 100;
}

View File

@ -167,6 +167,7 @@ export default {
all_module_title: "All module",
create_user: 'Creator',
run_message: "The task is being executed, please go to the task center to view the details",
executor: "Executor",
table: {
select_tip: "Item {0} data is selected"
},

View File

@ -168,6 +168,7 @@ export default {
all_module_title: "全部模块",
create_user: '创建人',
run_message: "任务执行中,请到任务中心查看详情",
executor: "执行人",
table: {
select_tip: "已选中 {0} 条数据"
},

View File

@ -168,6 +168,7 @@ export default {
all_module_title: "全部模塊",
create_user: "創建人",
run_message: "任務執行中,請到任務中心查看詳情",
executor: "執行人",
table: {
select_tip: "已選中 {0} 條數據"
},