parent
14abc1a82e
commit
3a1bfedf15
|
@ -0,0 +1,159 @@
|
|||
package io.metersphere.api.cache;
|
||||
|
||||
|
||||
import io.metersphere.commons.constants.TestPlanApiExecuteStatus;
|
||||
import io.metersphere.commons.constants.TestPlanResourceType;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author song.tianyang
|
||||
* @Date 2021/8/21 5:15 下午
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class TestPlanExecuteInfo {
|
||||
private String reportId;
|
||||
private Map<String, String> apiCaseExecInfo = new HashMap<>();
|
||||
private Map<String, String> apiScenarioCaseExecInfo = new HashMap<>();
|
||||
private Map<String, String> loadCaseExecInfo = new HashMap<>();
|
||||
private boolean reportDataInDataBase;
|
||||
|
||||
int lastUnFinishedNumCount = 0;
|
||||
long lastFinishedNumCountTime = 0;
|
||||
|
||||
private boolean isApiCaseAllExecuted;
|
||||
private boolean isScenarioAllExecuted;
|
||||
private boolean isLoadCaseAllExecuted;
|
||||
|
||||
public synchronized void updateExecuteInfo(Map<String, String> apiCaseExecInfo, Map<String, String> apiScenarioCaseExecInfo, Map<String, String> loadCaseExecInfo) {
|
||||
if (MapUtils.isNotEmpty(apiCaseExecInfo)) {
|
||||
this.apiCaseExecInfo.putAll(apiCaseExecInfo);
|
||||
}
|
||||
|
||||
if (MapUtils.isNotEmpty(apiScenarioCaseExecInfo)) {
|
||||
this.apiScenarioCaseExecInfo.putAll(apiScenarioCaseExecInfo);
|
||||
}
|
||||
|
||||
if (MapUtils.isNotEmpty(loadCaseExecInfo)) {
|
||||
this.loadCaseExecInfo.putAll(loadCaseExecInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized int countUnFinishedNum() {
|
||||
int unFinishedCount = 0;
|
||||
|
||||
this.isApiCaseAllExecuted = true;
|
||||
this.isScenarioAllExecuted = true;
|
||||
this.isLoadCaseAllExecuted = true;
|
||||
|
||||
for (String result : apiCaseExecInfo.values()) {
|
||||
if (StringUtils.equalsIgnoreCase(result, TestPlanApiExecuteStatus.RUNNING.name())) {
|
||||
unFinishedCount++;
|
||||
if (this.isApiCaseAllExecuted) {
|
||||
this.isApiCaseAllExecuted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String result : apiScenarioCaseExecInfo.values()) {
|
||||
if (StringUtils.equalsIgnoreCase(result, TestPlanApiExecuteStatus.RUNNING.name())) {
|
||||
unFinishedCount++;
|
||||
if (this.isScenarioAllExecuted) {
|
||||
isScenarioAllExecuted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String result : loadCaseExecInfo.values()) {
|
||||
if (StringUtils.equalsIgnoreCase(result, TestPlanApiExecuteStatus.RUNNING.name())) {
|
||||
unFinishedCount++;
|
||||
if (this.isLoadCaseAllExecuted) {
|
||||
isLoadCaseAllExecuted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lastUnFinishedNumCount != unFinishedCount) {
|
||||
lastUnFinishedNumCount = unFinishedCount;
|
||||
lastFinishedNumCountTime = System.currentTimeMillis();
|
||||
}
|
||||
return unFinishedCount;
|
||||
}
|
||||
|
||||
public Map<String, Map<String, String>> getExecutedResult() {
|
||||
Map<String, Map<String, String>> resourceTypeMap = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, String> entry : apiCaseExecInfo.entrySet()) {
|
||||
String resourceId = entry.getKey();
|
||||
String executeResult = entry.getValue();
|
||||
String resourceType = TestPlanResourceType.API_CASE.name();
|
||||
|
||||
if (resourceTypeMap.containsKey(resourceType)) {
|
||||
resourceTypeMap.get(resourceType).put(resourceId, executeResult);
|
||||
} else {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put(resourceId, executeResult);
|
||||
resourceTypeMap.put(resourceType, map);
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<String, String> entry : apiScenarioCaseExecInfo.entrySet()) {
|
||||
String resourceId = entry.getKey();
|
||||
String executeResult = entry.getValue();
|
||||
String resourceType = TestPlanResourceType.SCENARIO_CASE.name();
|
||||
|
||||
if (resourceTypeMap.containsKey(resourceType)) {
|
||||
resourceTypeMap.get(resourceType).put(resourceId, executeResult);
|
||||
} else {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put(resourceId, executeResult);
|
||||
resourceTypeMap.put(resourceType, map);
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<String, String> entry : loadCaseExecInfo.entrySet()) {
|
||||
String resourceId = entry.getKey();
|
||||
String executeResult = entry.getValue();
|
||||
String resourceType = TestPlanResourceType.PERFORMANCE_CASE.name();
|
||||
|
||||
if (resourceTypeMap.containsKey(resourceType)) {
|
||||
resourceTypeMap.get(resourceType).put(resourceId, executeResult);
|
||||
} else {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put(resourceId, executeResult);
|
||||
resourceTypeMap.put(resourceType, map);
|
||||
}
|
||||
}
|
||||
|
||||
return resourceTypeMap;
|
||||
}
|
||||
|
||||
public void finishAllTask() {
|
||||
for (Map.Entry<String, String> entry : apiCaseExecInfo.entrySet()) {
|
||||
String resourceId = entry.getKey();
|
||||
String executeResult = entry.getValue();
|
||||
if (StringUtils.equalsIgnoreCase(executeResult, TestPlanApiExecuteStatus.RUNNING.name())) {
|
||||
apiCaseExecInfo.put(resourceId, TestPlanApiExecuteStatus.FAILD.name());
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, String> entry : apiScenarioCaseExecInfo.entrySet()) {
|
||||
String resourceId = entry.getKey();
|
||||
String executeResult = entry.getValue();
|
||||
if (StringUtils.equalsIgnoreCase(executeResult, TestPlanApiExecuteStatus.RUNNING.name())) {
|
||||
apiScenarioCaseExecInfo.put(resourceId, TestPlanApiExecuteStatus.FAILD.name());
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, String> entry : loadCaseExecInfo.entrySet()) {
|
||||
String resourceId = entry.getKey();
|
||||
String executeResult = entry.getValue();
|
||||
if (StringUtils.equalsIgnoreCase(executeResult, TestPlanApiExecuteStatus.RUNNING.name())) {
|
||||
loadCaseExecInfo.put(resourceId, TestPlanApiExecuteStatus.FAILD.name());
|
||||
}
|
||||
}
|
||||
|
||||
this.countUnFinishedNum();
|
||||
}
|
||||
}
|
67
backend/src/main/java/io/metersphere/api/cache/TestPlanReportExecuteCatch.java
vendored
Normal file
67
backend/src/main/java/io/metersphere/api/cache/TestPlanReportExecuteCatch.java
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
package io.metersphere.api.cache;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author song.tianyang
|
||||
* @Date 2021/8/20 3:29 下午
|
||||
*/
|
||||
public class TestPlanReportExecuteCatch {
|
||||
private static Map<String, TestPlanExecuteInfo> testPlanReportMap = new HashMap<>();
|
||||
|
||||
private TestPlanReportExecuteCatch() {
|
||||
}
|
||||
|
||||
public synchronized static void addApiTestPlanExecuteInfo(String reportId,
|
||||
Map<String, String> apiCaseExecInfo, Map<String, String> apiScenarioCaseExecInfo, Map<String, String> loadCaseExecInfo) {
|
||||
if(testPlanReportMap == null){
|
||||
testPlanReportMap = new HashMap<>();
|
||||
}
|
||||
if(apiCaseExecInfo == null){
|
||||
apiCaseExecInfo = new HashMap<>();
|
||||
}
|
||||
if(apiScenarioCaseExecInfo == null){
|
||||
apiScenarioCaseExecInfo = new HashMap<>();
|
||||
}
|
||||
if(loadCaseExecInfo == null){
|
||||
loadCaseExecInfo = new HashMap<>();
|
||||
}
|
||||
|
||||
TestPlanExecuteInfo executeInfo = new TestPlanExecuteInfo();
|
||||
executeInfo.setReportId(reportId);
|
||||
executeInfo.setApiCaseExecInfo(apiCaseExecInfo);
|
||||
executeInfo.setApiScenarioCaseExecInfo(apiScenarioCaseExecInfo);
|
||||
executeInfo.setLoadCaseExecInfo(loadCaseExecInfo);
|
||||
testPlanReportMap.put(reportId,executeInfo);
|
||||
}
|
||||
|
||||
public synchronized static void updateApiTestPlanExecuteInfo(String reportId,
|
||||
Map<String, String> apiCaseExecInfo, Map<String, String> apiScenarioCaseExecInfo, Map<String, String> loadCaseExecInfo) {
|
||||
if(testPlanReportMap != null && testPlanReportMap.containsKey(reportId)){
|
||||
testPlanReportMap.get(reportId).updateExecuteInfo(apiCaseExecInfo,apiScenarioCaseExecInfo,loadCaseExecInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public static TestPlanExecuteInfo getTestPlanExecuteInfo(String reportId){
|
||||
return testPlanReportMap.get(reportId);
|
||||
}
|
||||
|
||||
public static synchronized void setReportDataCheckResult(String reportId, boolean result) {
|
||||
if(testPlanReportMap.containsKey(reportId)){
|
||||
testPlanReportMap.get(reportId).setReportDataInDataBase(result);
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void remove(String reportId){
|
||||
if(testPlanReportMap.containsKey(reportId)){
|
||||
testPlanReportMap.remove(reportId);
|
||||
}
|
||||
}
|
||||
|
||||
public static void finishAllTask(String planReportId) {
|
||||
if(testPlanReportMap.containsKey(planReportId)){
|
||||
testPlanReportMap.get(planReportId).finishAllTask();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package io.metersphere.api.service;
|
|||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.metersphere.api.cache.TestPlanReportExecuteCatch;
|
||||
import io.metersphere.api.dto.datacount.ExecutedCaseInfoResult;
|
||||
import io.metersphere.api.jmeter.TestResult;
|
||||
import io.metersphere.base.domain.*;
|
||||
|
@ -11,14 +12,12 @@ import io.metersphere.base.mapper.ApiTestCaseMapper;
|
|||
import io.metersphere.base.mapper.TestCaseReviewApiCaseMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
|
||||
import io.metersphere.commons.constants.*;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.DateUtils;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.track.dto.TestPlanDTO;
|
||||
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
||||
import io.metersphere.track.service.TestCaseReviewApiCaseService;
|
||||
import io.metersphere.track.service.TestPlanApiCaseService;
|
||||
import io.metersphere.track.service.TestPlanReportService;
|
||||
import io.metersphere.track.service.TestPlanService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -251,8 +250,9 @@ public class ApiDefinitionExecResultService {
|
|||
});
|
||||
}
|
||||
testPlanLog.info("TestPlanReportId[" + testPlanReportId + "] APICASE OVER. API CASE STATUS:" + JSONObject.toJSONString(apiIdResultMap));
|
||||
TestPlanReportService testPlanReportService = CommonBeanFactory.getBean(TestPlanReportService.class);
|
||||
testPlanReportService.updateExecuteApis(testPlanReportId, apiIdResultMap, null, null);
|
||||
TestPlanReportExecuteCatch.updateApiTestPlanExecuteInfo(testPlanReportId,apiIdResultMap,null,null);
|
||||
// TestPlanReportService testPlanReportService = CommonBeanFactory.getBean(TestPlanReportService.class);
|
||||
// testPlanReportService.updateExecuteApis(testPlanReportId, apiIdResultMap, null, null);
|
||||
}
|
||||
|
||||
public void deleteByResourceId(String resourceId) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.metersphere.api.cache.TestPlanReportExecuteCatch;
|
||||
import io.metersphere.api.dto.APIReportBatchRequest;
|
||||
import io.metersphere.api.dto.DeleteAPIReportRequest;
|
||||
import io.metersphere.api.dto.QueryAPIReportRequest;
|
||||
|
@ -378,8 +379,9 @@ public class ApiScenarioReportService {
|
|||
|
||||
testPlanLog.info("TestPlanReportId" + JSONArray.toJSONString(testPlanReportIdList) + " EXECUTE OVER. SCENARIO STATUS : " + JSONObject.toJSONString(scenarioAndErrorMap));
|
||||
|
||||
for (String planId : testPlanReportIdList) {
|
||||
testPlanReportService.updateExecuteApis(planId, null, scenarioAndErrorMap, null);
|
||||
for (String reportId : testPlanReportIdList) {
|
||||
// testPlanReportService.updateExecuteApis(planId, null, scenarioAndErrorMap, null);
|
||||
TestPlanReportExecuteCatch.updateApiTestPlanExecuteInfo(reportId,null,scenarioAndErrorMap,null);
|
||||
}
|
||||
|
||||
return lastReport;
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TestPlanReportResource implements Serializable {
|
||||
private String id;
|
||||
|
||||
private String testPlanReportId;
|
||||
|
||||
private String resourceId;
|
||||
|
||||
private String resourceType;
|
||||
|
||||
private String executeResult;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -1,550 +0,0 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TestPlanReportResourceExample {
|
||||
protected String orderByClause;
|
||||
|
||||
protected boolean distinct;
|
||||
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
public TestPlanReportResourceExample() {
|
||||
oredCriteria = new ArrayList<Criteria>();
|
||||
}
|
||||
|
||||
public void setOrderByClause(String orderByClause) {
|
||||
this.orderByClause = orderByClause;
|
||||
}
|
||||
|
||||
public String getOrderByClause() {
|
||||
return orderByClause;
|
||||
}
|
||||
|
||||
public void setDistinct(boolean distinct) {
|
||||
this.distinct = distinct;
|
||||
}
|
||||
|
||||
public boolean isDistinct() {
|
||||
return distinct;
|
||||
}
|
||||
|
||||
public List<Criteria> getOredCriteria() {
|
||||
return oredCriteria;
|
||||
}
|
||||
|
||||
public void or(Criteria criteria) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
|
||||
public Criteria or() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
oredCriteria.add(criteria);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public Criteria createCriteria() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
if (oredCriteria.size() == 0) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected Criteria createCriteriaInternal() {
|
||||
Criteria criteria = new Criteria();
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
oredCriteria.clear();
|
||||
orderByClause = null;
|
||||
distinct = false;
|
||||
}
|
||||
|
||||
protected abstract static class GeneratedCriteria {
|
||||
protected List<Criterion> criteria;
|
||||
|
||||
protected GeneratedCriteria() {
|
||||
super();
|
||||
criteria = new ArrayList<Criterion>();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return criteria.size() > 0;
|
||||
}
|
||||
|
||||
public List<Criterion> getAllCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public List<Criterion> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition) {
|
||||
if (condition == null) {
|
||||
throw new RuntimeException("Value for condition cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value, String property) {
|
||||
if (value == null) {
|
||||
throw new RuntimeException("Value for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value1, Object value2, String property) {
|
||||
if (value1 == null || value2 == null) {
|
||||
throw new RuntimeException("Between values for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value1, value2));
|
||||
}
|
||||
|
||||
public Criteria andIdIsNull() {
|
||||
addCriterion("id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIsNotNull() {
|
||||
addCriterion("id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdEqualTo(String value) {
|
||||
addCriterion("id =", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotEqualTo(String value) {
|
||||
addCriterion("id <>", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThan(String value) {
|
||||
addCriterion("id >", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("id >=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThan(String value) {
|
||||
addCriterion("id <", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("id <=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLike(String value) {
|
||||
addCriterion("id like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotLike(String value) {
|
||||
addCriterion("id not like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIn(List<String> values) {
|
||||
addCriterion("id in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotIn(List<String> values) {
|
||||
addCriterion("id not in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdBetween(String value1, String value2) {
|
||||
addCriterion("id between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotBetween(String value1, String value2) {
|
||||
addCriterion("id not between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestPlanReportIdIsNull() {
|
||||
addCriterion("test_plan_report_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestPlanReportIdIsNotNull() {
|
||||
addCriterion("test_plan_report_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestPlanReportIdEqualTo(String value) {
|
||||
addCriterion("test_plan_report_id =", value, "testPlanReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestPlanReportIdNotEqualTo(String value) {
|
||||
addCriterion("test_plan_report_id <>", value, "testPlanReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestPlanReportIdGreaterThan(String value) {
|
||||
addCriterion("test_plan_report_id >", value, "testPlanReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestPlanReportIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("test_plan_report_id >=", value, "testPlanReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestPlanReportIdLessThan(String value) {
|
||||
addCriterion("test_plan_report_id <", value, "testPlanReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestPlanReportIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("test_plan_report_id <=", value, "testPlanReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestPlanReportIdLike(String value) {
|
||||
addCriterion("test_plan_report_id like", value, "testPlanReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestPlanReportIdNotLike(String value) {
|
||||
addCriterion("test_plan_report_id not like", value, "testPlanReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestPlanReportIdIn(List<String> values) {
|
||||
addCriterion("test_plan_report_id in", values, "testPlanReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestPlanReportIdNotIn(List<String> values) {
|
||||
addCriterion("test_plan_report_id not in", values, "testPlanReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestPlanReportIdBetween(String value1, String value2) {
|
||||
addCriterion("test_plan_report_id between", value1, value2, "testPlanReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestPlanReportIdNotBetween(String value1, String value2) {
|
||||
addCriterion("test_plan_report_id not between", value1, value2, "testPlanReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdIsNull() {
|
||||
addCriterion("resource_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdIsNotNull() {
|
||||
addCriterion("resource_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdEqualTo(String value) {
|
||||
addCriterion("resource_id =", value, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdNotEqualTo(String value) {
|
||||
addCriterion("resource_id <>", value, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdGreaterThan(String value) {
|
||||
addCriterion("resource_id >", value, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("resource_id >=", value, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdLessThan(String value) {
|
||||
addCriterion("resource_id <", value, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("resource_id <=", value, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdLike(String value) {
|
||||
addCriterion("resource_id like", value, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdNotLike(String value) {
|
||||
addCriterion("resource_id not like", value, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdIn(List<String> values) {
|
||||
addCriterion("resource_id in", values, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdNotIn(List<String> values) {
|
||||
addCriterion("resource_id not in", values, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdBetween(String value1, String value2) {
|
||||
addCriterion("resource_id between", value1, value2, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdNotBetween(String value1, String value2) {
|
||||
addCriterion("resource_id not between", value1, value2, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceTypeIsNull() {
|
||||
addCriterion("resource_type is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceTypeIsNotNull() {
|
||||
addCriterion("resource_type is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceTypeEqualTo(String value) {
|
||||
addCriterion("resource_type =", value, "resourceType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceTypeNotEqualTo(String value) {
|
||||
addCriterion("resource_type <>", value, "resourceType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceTypeGreaterThan(String value) {
|
||||
addCriterion("resource_type >", value, "resourceType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceTypeGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("resource_type >=", value, "resourceType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceTypeLessThan(String value) {
|
||||
addCriterion("resource_type <", value, "resourceType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceTypeLessThanOrEqualTo(String value) {
|
||||
addCriterion("resource_type <=", value, "resourceType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceTypeLike(String value) {
|
||||
addCriterion("resource_type like", value, "resourceType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceTypeNotLike(String value) {
|
||||
addCriterion("resource_type not like", value, "resourceType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceTypeIn(List<String> values) {
|
||||
addCriterion("resource_type in", values, "resourceType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceTypeNotIn(List<String> values) {
|
||||
addCriterion("resource_type not in", values, "resourceType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceTypeBetween(String value1, String value2) {
|
||||
addCriterion("resource_type between", value1, value2, "resourceType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceTypeNotBetween(String value1, String value2) {
|
||||
addCriterion("resource_type not between", value1, value2, "resourceType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andExecuteResultIsNull() {
|
||||
addCriterion("execute_result is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andExecuteResultIsNotNull() {
|
||||
addCriterion("execute_result is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andExecuteResultEqualTo(String value) {
|
||||
addCriterion("execute_result =", value, "executeResult");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andExecuteResultNotEqualTo(String value) {
|
||||
addCriterion("execute_result <>", value, "executeResult");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andExecuteResultGreaterThan(String value) {
|
||||
addCriterion("execute_result >", value, "executeResult");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andExecuteResultGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("execute_result >=", value, "executeResult");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andExecuteResultLessThan(String value) {
|
||||
addCriterion("execute_result <", value, "executeResult");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andExecuteResultLessThanOrEqualTo(String value) {
|
||||
addCriterion("execute_result <=", value, "executeResult");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andExecuteResultLike(String value) {
|
||||
addCriterion("execute_result like", value, "executeResult");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andExecuteResultNotLike(String value) {
|
||||
addCriterion("execute_result not like", value, "executeResult");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andExecuteResultIn(List<String> values) {
|
||||
addCriterion("execute_result in", values, "executeResult");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andExecuteResultNotIn(List<String> values) {
|
||||
addCriterion("execute_result not in", values, "executeResult");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andExecuteResultBetween(String value1, String value2) {
|
||||
addCriterion("execute_result between", value1, value2, "executeResult");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andExecuteResultNotBetween(String value1, String value2) {
|
||||
addCriterion("execute_result not between", value1, value2, "executeResult");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
||||
protected Criteria() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criterion {
|
||||
private String condition;
|
||||
|
||||
private Object value;
|
||||
|
||||
private Object secondValue;
|
||||
|
||||
private boolean noValue;
|
||||
|
||||
private boolean singleValue;
|
||||
|
||||
private boolean betweenValue;
|
||||
|
||||
private boolean listValue;
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.typeHandler = null;
|
||||
this.noValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.typeHandler = typeHandler;
|
||||
if (value instanceof List<?>) {
|
||||
this.listValue = true;
|
||||
} else {
|
||||
this.singleValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value) {
|
||||
this(condition, value, null);
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.secondValue = secondValue;
|
||||
this.typeHandler = typeHandler;
|
||||
this.betweenValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package io.metersphere.base.mapper;
|
||||
|
||||
import io.metersphere.base.domain.TestPlanReportResource;
|
||||
import io.metersphere.base.domain.TestPlanReportResourceExample;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface TestPlanReportResourceMapper {
|
||||
long countByExample(TestPlanReportResourceExample example);
|
||||
|
||||
int deleteByExample(TestPlanReportResourceExample example);
|
||||
|
||||
int deleteByPrimaryKey(String id);
|
||||
|
||||
int insert(TestPlanReportResource record);
|
||||
|
||||
int insertSelective(TestPlanReportResource record);
|
||||
|
||||
List<TestPlanReportResource> selectByExample(TestPlanReportResourceExample example);
|
||||
|
||||
TestPlanReportResource selectByPrimaryKey(String id);
|
||||
|
||||
int updateByExampleSelective(@Param("record") TestPlanReportResource record, @Param("example") TestPlanReportResourceExample example);
|
||||
|
||||
int updateByExample(@Param("record") TestPlanReportResource record, @Param("example") TestPlanReportResourceExample example);
|
||||
|
||||
int updateByPrimaryKeySelective(TestPlanReportResource record);
|
||||
|
||||
int updateByPrimaryKey(TestPlanReportResource record);
|
||||
}
|
|
@ -1,211 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.metersphere.base.mapper.TestPlanReportResourceMapper">
|
||||
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.TestPlanReportResource">
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="test_plan_report_id" jdbcType="VARCHAR" property="testPlanReportId" />
|
||||
<result column="resource_id" jdbcType="VARCHAR" property="resourceId" />
|
||||
<result column="resource_type" jdbcType="VARCHAR" property="resourceType" />
|
||||
<result column="execute_result" jdbcType="VARCHAR" property="executeResult" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Update_By_Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="example.oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, test_plan_report_id, resource_id, resource_type, execute_result
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.metersphere.base.domain.TestPlanReportResourceExample" resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from test_plan_report_resource
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from test_plan_report_resource
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||
delete from test_plan_report_resource
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.TestPlanReportResourceExample">
|
||||
delete from test_plan_report_resource
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.metersphere.base.domain.TestPlanReportResource">
|
||||
insert into test_plan_report_resource (id, test_plan_report_id, resource_id,
|
||||
resource_type, execute_result)
|
||||
values (#{id,jdbcType=VARCHAR}, #{testPlanReportId,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR},
|
||||
#{resourceType,jdbcType=VARCHAR}, #{executeResult,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlanReportResource">
|
||||
insert into test_plan_report_resource
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="testPlanReportId != null">
|
||||
test_plan_report_id,
|
||||
</if>
|
||||
<if test="resourceId != null">
|
||||
resource_id,
|
||||
</if>
|
||||
<if test="resourceType != null">
|
||||
resource_type,
|
||||
</if>
|
||||
<if test="executeResult != null">
|
||||
execute_result,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="testPlanReportId != null">
|
||||
#{testPlanReportId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="resourceId != null">
|
||||
#{resourceId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="resourceType != null">
|
||||
#{resourceType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="executeResult != null">
|
||||
#{executeResult,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.metersphere.base.domain.TestPlanReportResourceExample" resultType="java.lang.Long">
|
||||
select count(*) from test_plan_report_resource
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update test_plan_report_resource
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
id = #{record.id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.testPlanReportId != null">
|
||||
test_plan_report_id = #{record.testPlanReportId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.resourceId != null">
|
||||
resource_id = #{record.resourceId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.resourceType != null">
|
||||
resource_type = #{record.resourceType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.executeResult != null">
|
||||
execute_result = #{record.executeResult,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update test_plan_report_resource
|
||||
set id = #{record.id,jdbcType=VARCHAR},
|
||||
test_plan_report_id = #{record.testPlanReportId,jdbcType=VARCHAR},
|
||||
resource_id = #{record.resourceId,jdbcType=VARCHAR},
|
||||
resource_type = #{record.resourceType,jdbcType=VARCHAR},
|
||||
execute_result = #{record.executeResult,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.TestPlanReportResource">
|
||||
update test_plan_report_resource
|
||||
<set>
|
||||
<if test="testPlanReportId != null">
|
||||
test_plan_report_id = #{testPlanReportId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="resourceId != null">
|
||||
resource_id = #{resourceId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="resourceType != null">
|
||||
resource_type = #{resourceType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="executeResult != null">
|
||||
execute_result = #{executeResult,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.TestPlanReportResource">
|
||||
update test_plan_report_resource
|
||||
set test_plan_report_id = #{testPlanReportId,jdbcType=VARCHAR},
|
||||
resource_id = #{resourceId,jdbcType=VARCHAR},
|
||||
resource_type = #{resourceType,jdbcType=VARCHAR},
|
||||
execute_result = #{executeResult,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
</mapper>
|
|
@ -1,9 +0,0 @@
|
|||
package io.metersphere.base.mapper.ext;
|
||||
|
||||
import io.metersphere.base.domain.TestPlanReportResource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ExtTestPlanReportResourceMapper {
|
||||
List<TestPlanReportResource> selectResourceIdAndResourceTypeAndExecuteResultByTestPlanReportId(String testPlanReportId);
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.metersphere.base.mapper.ext.ExtTestPlanReportResourceMapper">
|
||||
|
||||
|
||||
<select id="selectResourceIdAndResourceTypeAndExecuteResultByTestPlanReportId" resultType="io.metersphere.base.domain.TestPlanReportResource">
|
||||
select resource_id,resource_type,execute_result from test_plan_report_resource
|
||||
where test_plan_report_id = #{0}
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.track.dto;
|
||||
|
||||
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||
import io.metersphere.base.domain.TestPlanReport;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -16,6 +17,6 @@ import java.util.Map;
|
|||
public class TestPlanScheduleReportInfoDTO {
|
||||
private TestPlanReport testPlanReport;
|
||||
private Map<String, String> planScenarioIdMap = new LinkedHashMap<>();
|
||||
private Map<String, String> apiTestCaseIdMap = new LinkedHashMap<>();
|
||||
private Map<ApiTestCaseWithBLOBs, String> apiTestCaseDataMap = new LinkedHashMap<>();
|
||||
private Map<String, String> performanceIdMap = new LinkedHashMap<>();
|
||||
}
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
package io.metersphere.track.service;
|
||||
|
||||
import io.metersphere.base.domain.TestPlanReportResource;
|
||||
import io.metersphere.base.domain.TestPlanReportResourceExample;
|
||||
import io.metersphere.base.mapper.TestPlanReportResourceMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtTestPlanReportResourceMapper;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author song.tianyang
|
||||
* @Date 2021/8/2 1:57 下午
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class TestPlanReportResourceService {
|
||||
@Resource
|
||||
private TestPlanReportResourceMapper testPlanReportResourceMapper;
|
||||
@Resource
|
||||
private ExtTestPlanReportResourceMapper extTestPlanReportResourceMapper;
|
||||
|
||||
public int updateExecuteResultByReportIdAndResourceIds(String executeResult, String planReportId, List<String> ids) {
|
||||
if(CollectionUtils.isEmpty(ids)){
|
||||
return 0;
|
||||
}else {
|
||||
TestPlanReportResourceExample example = new TestPlanReportResourceExample();
|
||||
example.createCriteria().andTestPlanReportIdEqualTo(planReportId).andResourceIdIn(ids);
|
||||
|
||||
TestPlanReportResource updateModel = new TestPlanReportResource();
|
||||
updateModel.setExecuteResult(executeResult);
|
||||
return testPlanReportResourceMapper.updateByExampleSelective(updateModel,example);
|
||||
}
|
||||
}
|
||||
|
||||
public long countByReportIdAndResourceTypeAndExecuteResultNotEquals(String planReportId, String resourceType, String executeResult) {
|
||||
TestPlanReportResourceExample example = new TestPlanReportResourceExample();
|
||||
example.createCriteria().andTestPlanReportIdEqualTo(planReportId).andResourceTypeEqualTo(resourceType).andExecuteResultNotEqualTo(executeResult);
|
||||
return this.testPlanReportResourceMapper.countByExample(example);
|
||||
}
|
||||
|
||||
public long countByReportIdAndResourceTypeAndExecuteResultEquals(String planReportId, String resourceType, String executeResult) {
|
||||
TestPlanReportResourceExample example = new TestPlanReportResourceExample();
|
||||
example.createCriteria().andTestPlanReportIdEqualTo(planReportId).andResourceTypeEqualTo(resourceType).andExecuteResultEqualTo(executeResult);
|
||||
return this.testPlanReportResourceMapper.countByExample(example);
|
||||
}
|
||||
|
||||
public Map<String, Map<String, String>> selectExecuteResultByTestPlanReportId(String testPlanReportId) {
|
||||
Map<String,Map<String,String>> resourceTypeMap = new HashMap<>();
|
||||
List<TestPlanReportResource> testPlanReportResourceList = extTestPlanReportResourceMapper.selectResourceIdAndResourceTypeAndExecuteResultByTestPlanReportId(testPlanReportId);
|
||||
for (TestPlanReportResource model : testPlanReportResourceList) {
|
||||
String resourceType = model.getResourceType();
|
||||
String resourceId = model.getResourceId();
|
||||
String executeResult = model.getExecuteResult();
|
||||
|
||||
if(resourceTypeMap.containsKey(resourceType)){
|
||||
resourceTypeMap.get(resourceType).put(resourceId,executeResult);
|
||||
}else {
|
||||
Map<String ,String> map = new HashMap<>();
|
||||
map.put(resourceId,executeResult);
|
||||
resourceTypeMap.put(resourceType,map);
|
||||
}
|
||||
}
|
||||
return resourceTypeMap;
|
||||
}
|
||||
|
||||
public void deleteByExample(TestPlanReportResourceExample resourceExample) {
|
||||
testPlanReportResourceMapper.deleteByExample(resourceExample);
|
||||
}
|
||||
}
|
|
@ -3,6 +3,8 @@ package io.metersphere.track.service;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.metersphere.api.cache.TestPlanExecuteInfo;
|
||||
import io.metersphere.api.cache.TestPlanReportExecuteCatch;
|
||||
import io.metersphere.api.dto.automation.ApiScenarioDTO;
|
||||
import io.metersphere.api.dto.automation.TestPlanScenarioRequest;
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
|
||||
|
@ -74,11 +76,7 @@ public class TestPlanReportService {
|
|||
@Resource
|
||||
ExtTestPlanApiCaseMapper extTestPlanApiCaseMapper;
|
||||
@Resource
|
||||
TestPlanReportResourceService testPlanReportResourceService;
|
||||
// @Resource
|
||||
// TestPlanLoadCaseService testPlanLoadCaseService;
|
||||
// @Resource
|
||||
// TestPlanService testPlanService;
|
||||
ApiTestCaseMapper apiTestCaseMapper;
|
||||
@Resource
|
||||
LoadTestReportMapper loadTestReportMapper;
|
||||
|
||||
|
@ -110,13 +108,10 @@ public class TestPlanReportService {
|
|||
// }
|
||||
// }
|
||||
|
||||
private TestPlanReport updateTestPlanReportById(String id) {
|
||||
return this.updateExecuteApis(id, null, null, null);
|
||||
}
|
||||
|
||||
public TestPlanScheduleReportInfoDTO genTestPlanReportBySchedule(String projectID, String planId, String userId, String triggerMode) {
|
||||
Map<String, String> planScenarioIdMap = new LinkedHashMap<>();
|
||||
Map<String, String> apiTestCaseIdMap = new LinkedHashMap<>();
|
||||
Map<ApiTestCaseWithBLOBs, String> apiTestCaseDataMap = new LinkedHashMap<>();
|
||||
Map<String, String> performanceIdMap = new LinkedHashMap<>();
|
||||
|
||||
List<TestPlanApiScenario> testPlanApiScenarioList = extTestPlanScenarioCaseMapper.selectLegalDataByTestPlanId(planId);
|
||||
|
@ -140,8 +135,21 @@ public class TestPlanReportService {
|
|||
String planReportId = UUID.randomUUID().toString();
|
||||
|
||||
Map<String, String> apiCaseInfoMap = new HashMap<>();
|
||||
for (String id : apiTestCaseIdMap.keySet()) {
|
||||
if(!apiTestCaseIdMap.isEmpty()){
|
||||
ApiTestCaseExample apiTestCaseExample = new ApiTestCaseExample();
|
||||
apiTestCaseExample.createCriteria().andIdIn(new ArrayList<>(apiTestCaseIdMap.keySet()));
|
||||
List<ApiTestCaseWithBLOBs> apiCaseList = apiTestCaseMapper.selectByExampleWithBLOBs(apiTestCaseExample);
|
||||
Map<String,ApiTestCaseWithBLOBs> apiCaseDataMap = new HashMap<>();
|
||||
if(!apiCaseList.isEmpty()){
|
||||
apiCaseDataMap = apiCaseList.stream().collect(Collectors.toMap(ApiTestCaseWithBLOBs::getId, k -> k));
|
||||
for (String id : apiCaseDataMap.keySet()) {
|
||||
apiCaseInfoMap.put(id,TestPlanApiExecuteStatus.PREPARE.name());
|
||||
String testPlanApiCaseId = apiTestCaseIdMap.get(id);
|
||||
if(StringUtils.isNotEmpty(testPlanApiCaseId)){
|
||||
apiTestCaseDataMap.put(apiCaseDataMap.get(id),testPlanApiCaseId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, String> scenarioInfoMap = new HashMap<>();
|
||||
for (String id : planScenarioIdMap.keySet()) {
|
||||
|
@ -159,7 +167,7 @@ public class TestPlanReportService {
|
|||
TestPlanScheduleReportInfoDTO returnDTO = new TestPlanScheduleReportInfoDTO();
|
||||
returnDTO.setTestPlanReport(report);
|
||||
returnDTO.setPlanScenarioIdMap(planScenarioIdMap);
|
||||
returnDTO.setApiTestCaseIdMap(apiTestCaseIdMap);
|
||||
returnDTO.setApiTestCaseDataMap(apiTestCaseDataMap);
|
||||
returnDTO.setPerformanceIdMap(performanceIdMap);
|
||||
return returnDTO;
|
||||
}
|
||||
|
@ -234,56 +242,11 @@ public class TestPlanReportService {
|
|||
performanceInfoMap = saveRequest.getPerformanceIdMap();
|
||||
}
|
||||
|
||||
List<TestPlanReportResource> resourceList = new ArrayList<>();
|
||||
if (MapUtils.isNotEmpty(apiCaseInfoMap)) {
|
||||
for (Map.Entry<String, String> entry : apiCaseInfoMap.entrySet()) {
|
||||
String id = entry.getKey();
|
||||
String status = entry.getValue();
|
||||
String type = TestPlanResourceType.API_CASE.name();
|
||||
|
||||
TestPlanReportResource apiCaseResource = new TestPlanReportResource();
|
||||
apiCaseResource.setResourceId(id);
|
||||
apiCaseResource.setTestPlanReportId(testPlanReportID);
|
||||
apiCaseResource.setResourceType(type);
|
||||
apiCaseResource.setExecuteResult(status);
|
||||
apiCaseResource.setId(UUID.randomUUID().toString());
|
||||
resourceList.add(apiCaseResource);
|
||||
}
|
||||
}
|
||||
if (MapUtils.isNotEmpty(scenarioInfoMap)) {
|
||||
for (Map.Entry<String, String> entry : scenarioInfoMap.entrySet()) {
|
||||
String id = entry.getKey();
|
||||
String status = entry.getValue();
|
||||
String type = TestPlanResourceType.SCENARIO_CASE.name();
|
||||
|
||||
TestPlanReportResource scenarioResource = new TestPlanReportResource();
|
||||
scenarioResource.setResourceId(id);
|
||||
scenarioResource.setTestPlanReportId(testPlanReportID);
|
||||
scenarioResource.setResourceType(type);
|
||||
scenarioResource.setExecuteResult(status);
|
||||
scenarioResource.setId(UUID.randomUUID().toString());
|
||||
resourceList.add(scenarioResource);
|
||||
}
|
||||
}
|
||||
if (MapUtils.isNotEmpty(performanceInfoMap)) {
|
||||
for (Map.Entry<String, String> entry : performanceInfoMap.entrySet()) {
|
||||
String id = entry.getKey();
|
||||
String status = entry.getValue();
|
||||
String type = TestPlanResourceType.PERFORMANCE_CASE.name();
|
||||
|
||||
TestPlanReportResource performanceResource = new TestPlanReportResource();
|
||||
performanceResource.setResourceId(id);
|
||||
performanceResource.setTestPlanReportId(testPlanReportID);
|
||||
performanceResource.setResourceType(type);
|
||||
performanceResource.setExecuteResult(status);
|
||||
performanceResource.setId(UUID.randomUUID().toString());
|
||||
resourceList.add(performanceResource);
|
||||
}
|
||||
}
|
||||
TestPlanReportExecuteCatch.addApiTestPlanExecuteInfo(testPlanReportID,apiCaseInfoMap,scenarioInfoMap,performanceInfoMap);
|
||||
|
||||
testPlanReport.setPrincipal(testPlan.getPrincipal());
|
||||
if (testPlanReport.getIsScenarioExecuting() || testPlanReport.getIsApiCaseExecuting() || testPlanReport.getIsPerformanceExecuting()) {
|
||||
testPlanReport.setStatus(APITestStatus.Starting.name());
|
||||
testPlanReport.setStatus(APITestStatus.Running.name());
|
||||
} else {
|
||||
testPlanReport.setStatus(APITestStatus.Completed.name());
|
||||
}
|
||||
|
@ -291,12 +254,8 @@ public class TestPlanReportService {
|
|||
SqlSession sqlSession = sqlSessionFactory.openSession(false);
|
||||
TestPlanReportMapper insertReportMapper = sqlSession.getMapper(TestPlanReportMapper.class);
|
||||
TestPlanReportDataMapper insertReportDataMapper = sqlSession.getMapper(TestPlanReportDataMapper.class);
|
||||
TestPlanReportResourceMapper insertResourceMapper = sqlSession.getMapper(TestPlanReportResourceMapper.class);
|
||||
insertReportMapper.insert(testPlanReport);
|
||||
insertReportDataMapper.insert(testPlanReportData);
|
||||
for (TestPlanReportResource resource : resourceList) {
|
||||
insertResourceMapper.insert(resource);
|
||||
}
|
||||
sqlSession.commit();
|
||||
sqlSession.flushStatements();
|
||||
|
||||
|
@ -310,9 +269,9 @@ public class TestPlanReportService {
|
|||
TestPlanReportDTO returnDTO = new TestPlanReportDTO();
|
||||
TestPlanReport report = testPlanReportMapper.selectByPrimaryKey(reportId);
|
||||
if (report != null) {
|
||||
if (StringUtils.equalsIgnoreCase(report.getStatus(), TestPlanApiExecuteStatus.RUNNING.name())) {
|
||||
report = this.updateExecuteApis(reportId, null, null, null);
|
||||
}
|
||||
// if (StringUtils.equalsIgnoreCase(report.getStatus(), TestPlanApiExecuteStatus.RUNNING.name())) {
|
||||
// report = this.updateExecuteApis(reportId);
|
||||
// }
|
||||
TestPlanReportDataExample example = new TestPlanReportDataExample();
|
||||
example.createCriteria().andTestPlanReportIdEqualTo(reportId);
|
||||
List<TestPlanReportDataWithBLOBs> reportDataList = testPlanReportDataMapper.selectByExampleWithBLOBs(example);
|
||||
|
@ -510,113 +469,6 @@ public class TestPlanReportService {
|
|||
loadResult.add(dto);
|
||||
}
|
||||
}
|
||||
// for (int i = 0; i < apiCaseExecuteArr.size(); i++) {
|
||||
// JSONObject jsonObj = apiCaseExecuteArr.getJSONObject(i);
|
||||
//
|
||||
// Map<String, Integer> countMap = new HashMap<>();
|
||||
// if (jsonObj.containsKey("status")) {
|
||||
// String status = jsonObj.getString("status");
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// for (int i = 0; i < scenarioExecuteArr.size(); i++) {
|
||||
// JSONObject jsonObj = scenarioExecuteArr.getJSONObject(i);
|
||||
// Map<String, Integer> countMap = new HashMap<>();
|
||||
// if (jsonObj.containsKey("status")) {
|
||||
// String status = jsonObj.getString("status");
|
||||
// if (StringUtils.equalsAnyIgnoreCase(status, TestPlanApiExecuteStatus.SUCCESS.name())) {
|
||||
// if (countMap.containsKey("Pass")) {
|
||||
// countMap.put("Pass", countMap.get("Pass") + 1);
|
||||
// } else {
|
||||
// countMap.put("Pass", 1);
|
||||
// }
|
||||
// } else if (StringUtils.equalsAnyIgnoreCase(status, TestPlanApiExecuteStatus.FAILD.name())) {
|
||||
// if (jsonObj.containsKey("id")) {
|
||||
// faliureScenarioCaseIdList.add(jsonObj.getString("id"));
|
||||
// }
|
||||
// if (countMap.containsKey("Failure")) {
|
||||
// countMap.put("Failure", countMap.get("Failure") + 1);
|
||||
// } else {
|
||||
// countMap.put("Failure", 1);
|
||||
// }
|
||||
// } else if (StringUtils.equalsAnyIgnoreCase(status, TestPlanApiExecuteStatus.PREPARE.name())) {
|
||||
// if (jsonObj.containsKey("id")) {
|
||||
// faliureScenarioCaseIdList.add(jsonObj.getString("id"));
|
||||
// }
|
||||
// if (countMap.containsKey("Skip")) {
|
||||
// countMap.put("Skip", countMap.get("Skip") + 1);
|
||||
// } else {
|
||||
// countMap.put("Skip", 1);
|
||||
// }
|
||||
// } else {
|
||||
// if (countMap.containsKey("Underway")) {
|
||||
// countMap.put("Underway", countMap.get("Underway") + 1);
|
||||
// } else {
|
||||
// countMap.put("Underway", 1);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (Map.Entry<String, Integer> entry : countMap.entrySet()) {
|
||||
// String status = entry.getKey();
|
||||
// Integer value = entry.getValue();
|
||||
// TestCaseReportStatusResultDTO dto = new TestCaseReportStatusResultDTO();
|
||||
// dto.setStatus(status);
|
||||
// dto.setCount(value);
|
||||
// scenarioResult.add(dto);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (int i = 0; i < loadExecuteArr.size(); i++) {
|
||||
// JSONObject jsonObj = loadExecuteArr.getJSONObject(i);
|
||||
// Map<String, Integer> countMap = new HashMap<>();
|
||||
// if (jsonObj.containsKey("status")) {
|
||||
// String status = jsonObj.getString("status");
|
||||
// if (StringUtils.equalsAnyIgnoreCase(status, TestPlanApiExecuteStatus.SUCCESS.name())) {
|
||||
// if (countMap.containsKey("Pass")) {
|
||||
// countMap.put("Pass", countMap.get("Pass") + 1);
|
||||
// } else {
|
||||
// countMap.put("Pass", 1);
|
||||
// }
|
||||
// } else if (StringUtils.equalsAnyIgnoreCase(status, TestPlanApiExecuteStatus.FAILD.name())) {
|
||||
// if (jsonObj.containsKey("id")) {
|
||||
// faliureLoadCaseIdList.add(jsonObj.getString("id"));
|
||||
// }
|
||||
// if (countMap.containsKey("Failure")) {
|
||||
// countMap.put("Failure", countMap.get("Failure") + 1);
|
||||
// } else {
|
||||
// countMap.put("Failure", 1);
|
||||
// }
|
||||
// } else if (StringUtils.equalsAnyIgnoreCase(status, TestPlanApiExecuteStatus.PREPARE.name())) {
|
||||
// if (jsonObj.containsKey("id")) {
|
||||
// faliureLoadCaseIdList.add(jsonObj.getString("id"));
|
||||
// }
|
||||
// if (countMap.containsKey("Skip")) {
|
||||
// countMap.put("Skip", countMap.get("Skip") + 1);
|
||||
// } else {
|
||||
// countMap.put("Skip", 1);
|
||||
// }
|
||||
// } else {
|
||||
// if (countMap.containsKey("Underway")) {
|
||||
// countMap.put("Underway", countMap.get("Underway") + 1);
|
||||
// } else {
|
||||
// countMap.put("Underway", 1);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (Map.Entry<String, Integer> entry : countMap.entrySet()) {
|
||||
// String status = entry.getKey();
|
||||
// Integer value = entry.getValue();
|
||||
// TestCaseReportStatusResultDTO dto = new TestCaseReportStatusResultDTO();
|
||||
// dto.setStatus(status);
|
||||
// dto.setCount(value);
|
||||
// loadResult.add(dto);
|
||||
// }
|
||||
// }
|
||||
|
||||
statusDTO.setApiResult(apiResult);
|
||||
statusDTO.setScenarioResult(scenarioResult);
|
||||
statusDTO.setLoadResult(loadResult);
|
||||
|
@ -662,7 +514,7 @@ public class TestPlanReportService {
|
|||
return returnDTO;
|
||||
}
|
||||
|
||||
public TestPlanReport updateReport(TestPlanReportDataWithBLOBs testPlanReportData, boolean apiCaseIsOk, boolean scenarioIsOk, boolean performanceIsOk, boolean updateTime) {
|
||||
public TestPlanReport updateReport(TestPlanReportDataWithBLOBs testPlanReportData,boolean updateTime,TestPlanExecuteInfo executeInfo) {
|
||||
TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(testPlanReportData.getTestPlanReportId());
|
||||
if (testPlanReport == null) {
|
||||
return null;
|
||||
|
@ -673,6 +525,13 @@ public class TestPlanReportService {
|
|||
testPlanReport.setUpdateTime(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
boolean apiCaseIsOk = executeInfo.isApiCaseAllExecuted();
|
||||
boolean scenarioIsOk = executeInfo.isScenarioAllExecuted();
|
||||
boolean performanceIsOk = executeInfo.isLoadCaseAllExecuted();
|
||||
|
||||
testPlanLog.info("ReportId[" + testPlanReportData.getTestPlanReportId() + "] count over. Testplan Execute Result: Api is over ->" + apiCaseIsOk + "; scenario is over ->" + scenarioIsOk + "; performance is over ->" + performanceIsOk);
|
||||
|
||||
|
||||
if (apiCaseIsOk) {
|
||||
testPlanReport.setIsApiCaseExecuting(false);
|
||||
}
|
||||
|
@ -683,6 +542,10 @@ public class TestPlanReportService {
|
|||
testPlanReport.setIsPerformanceExecuting(false);
|
||||
}
|
||||
|
||||
if(apiCaseIsOk && scenarioIsOk && performanceIsOk){
|
||||
TestPlanReportExecuteCatch.remove(testPlanReportData.getTestPlanReportId());
|
||||
}
|
||||
|
||||
int[] componentIndexArr = new int[]{1, 3, 4};
|
||||
testPlanReport.setComponents(JSONArray.toJSONString(componentIndexArr));
|
||||
|
||||
|
@ -699,7 +562,7 @@ public class TestPlanReportService {
|
|||
testPlanService.buildScenarioCaseReport(testPlanReport.getTestPlanId(), components);
|
||||
testPlanService.buildLoadCaseReport(testPlanReport.getTestPlanId(), components);
|
||||
|
||||
Map<String, Map<String, String>> testPlanExecuteResult = testPlanReportResourceService.selectExecuteResultByTestPlanReportId(testPlanReportData.getTestPlanReportId());
|
||||
Map<String, Map<String, String>> testPlanExecuteResult = executeInfo.getExecutedResult();
|
||||
|
||||
testPlanLog.info("ReportId[" + testPlanReportData.getTestPlanReportId() + "] COUNT OVER. COUNT RESULT :" + JSONObject.toJSONString(testPlanExecuteResult));
|
||||
|
||||
|
@ -1063,7 +926,8 @@ public class TestPlanReportService {
|
|||
this.updatePerformanceTestStatus(eventDTO);
|
||||
}
|
||||
}
|
||||
this.updateExecuteApis(testPlanReport.getId(), null, null, finishLoadTestId);
|
||||
// this.updateExecuteApis(testPlanReport.getId(), null, null, finishLoadTestId);
|
||||
TestPlanReportExecuteCatch.updateApiTestPlanExecuteInfo(testPlanReport.getId(),null,null,finishLoadTestId);
|
||||
} else {
|
||||
try {
|
||||
//查询定时任务是否关闭
|
||||
|
@ -1091,9 +955,9 @@ public class TestPlanReportService {
|
|||
TestPlanReportDataExample example = new TestPlanReportDataExample();
|
||||
example.createCriteria().andTestPlanReportIdEqualTo(testPlanReportId);
|
||||
testPlanReportDataMapper.deleteByExample(example);
|
||||
TestPlanReportResourceExample resourceExample = new TestPlanReportResourceExample();
|
||||
resourceExample.createCriteria().andTestPlanReportIdEqualTo(testPlanReportId);
|
||||
testPlanReportResourceService.deleteByExample(resourceExample);
|
||||
// TestPlanReportResourceExample resourceExample = new TestPlanReportResourceExample();
|
||||
// resourceExample.createCriteria().andTestPlanReportIdEqualTo(testPlanReportId);
|
||||
// testPlanReportResourceService.deleteByExample(resourceExample);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1118,9 +982,9 @@ public class TestPlanReportService {
|
|||
example.createCriteria().andTestPlanReportIdIn(deleteReportIds);
|
||||
testPlanReportDataMapper.deleteByExample(example);
|
||||
|
||||
TestPlanReportResourceExample resourceExample = new TestPlanReportResourceExample();
|
||||
resourceExample.createCriteria().andTestPlanReportIdIn(deleteReportIds);
|
||||
testPlanReportResourceService.deleteByExample(resourceExample);
|
||||
// TestPlanReportResourceExample resourceExample = new TestPlanReportResourceExample();
|
||||
// resourceExample.createCriteria().andTestPlanReportIdIn(deleteReportIds);
|
||||
// testPlanReportResourceService.deleteByExample(resourceExample);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1151,9 +1015,13 @@ public class TestPlanReportService {
|
|||
return null;
|
||||
}
|
||||
|
||||
public synchronized TestPlanReport updateExecuteApis(String planReportId, Map<String, String> executeApiCaseIdMap, Map<String, String> executeScenarioCaseIdMap, Map<String, String> executePerformanceIdMap) {
|
||||
TestPlanReportDataExample example = new TestPlanReportDataExample();
|
||||
// List<String> resourceIdList = new ArrayList<>();
|
||||
public synchronized TestPlanReport updateExecuteApis(String planReportId) {
|
||||
|
||||
TestPlanExecuteInfo executeInfo = TestPlanReportExecuteCatch.getTestPlanExecuteInfo(planReportId);
|
||||
|
||||
Map<String,String> executeApiCaseIdMap = executeInfo.getApiCaseExecInfo();
|
||||
Map<String,String> executeScenarioCaseIdMap = executeInfo.getApiScenarioCaseExecInfo();
|
||||
Map<String,String> executePerformanceIdMap = executeInfo.getLoadCaseExecInfo();
|
||||
if (executeApiCaseIdMap == null) {
|
||||
executeApiCaseIdMap = new HashMap<>();
|
||||
}
|
||||
|
@ -1163,77 +1031,20 @@ public class TestPlanReportService {
|
|||
if (executePerformanceIdMap == null) {
|
||||
executePerformanceIdMap = new HashMap<>();
|
||||
}
|
||||
|
||||
boolean updateTime = MapUtils.isNotEmpty(executeApiCaseIdMap) || MapUtils.isNotEmpty(executeScenarioCaseIdMap) || MapUtils.isNotEmpty(executePerformanceIdMap);
|
||||
|
||||
testPlanLog.info("ReportId[" + planReportId + "] Executed. api :" + JSONObject.toJSONString(executeApiCaseIdMap) + "; scenario:" + JSONObject.toJSONString(executeScenarioCaseIdMap) + "; performance:" + JSONObject.toJSONString(executePerformanceIdMap));
|
||||
TestPlanReportDataExample example = new TestPlanReportDataExample();
|
||||
example.createCriteria().andTestPlanReportIdEqualTo(planReportId);
|
||||
List<TestPlanReportDataWithBLOBs> reportDataList = testPlanReportDataMapper.selectByExampleWithBLOBs(example);
|
||||
TestPlanReport report = null;
|
||||
if (!reportDataList.isEmpty()) {
|
||||
Map<String, List<String>> batchUpdateMap = new HashMap<>();
|
||||
for (Map.Entry<String, String> entry : executeApiCaseIdMap.entrySet()) {
|
||||
String id = entry.getKey();
|
||||
String result = entry.getValue();
|
||||
if (batchUpdateMap.containsKey(result)) {
|
||||
batchUpdateMap.get(result).add(id);
|
||||
} else {
|
||||
List<String> idList = new ArrayList<>();
|
||||
idList.add(id);
|
||||
batchUpdateMap.put(result, idList);
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, String> entry : executeScenarioCaseIdMap.entrySet()) {
|
||||
String id = entry.getKey();
|
||||
String result = entry.getValue();
|
||||
if (batchUpdateMap.containsKey(result)) {
|
||||
batchUpdateMap.get(result).add(id);
|
||||
} else {
|
||||
List<String> idList = new ArrayList<>();
|
||||
idList.add(id);
|
||||
batchUpdateMap.put(result, idList);
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, String> entry : executePerformanceIdMap.entrySet()) {
|
||||
String id = entry.getKey();
|
||||
String result = entry.getValue();
|
||||
if (batchUpdateMap.containsKey(result)) {
|
||||
batchUpdateMap.get(result).add(id);
|
||||
} else {
|
||||
List<String> idList = new ArrayList<>();
|
||||
idList.add(id);
|
||||
batchUpdateMap.put(result, idList);
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<String, List<String>> entry : batchUpdateMap.entrySet()) {
|
||||
String status = entry.getKey();
|
||||
List<String> ids = entry.getValue();
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
continue;
|
||||
}
|
||||
int updateCount = this.testPlanReportResourceService.updateExecuteResultByReportIdAndResourceIds(status, planReportId, ids);
|
||||
testPlanLog.info("ReportId[" + planReportId + "] Update Execute Result. Update datas count is :[" + updateCount + "]; Update Status:[" + status + "],Update ids :[" + JSONArray.toJSONString(ids) + "] ");
|
||||
}
|
||||
boolean apiCaseExecuteOk = testPlanReportResourceService.countByReportIdAndResourceTypeAndExecuteResultEquals(planReportId, TestPlanResourceType.API_CASE.name(), TestPlanApiExecuteStatus.RUNNING.name()) == 0;
|
||||
boolean scenarioExecuteOk = testPlanReportResourceService.countByReportIdAndResourceTypeAndExecuteResultEquals(planReportId, TestPlanResourceType.SCENARIO_CASE.name(), TestPlanApiExecuteStatus.RUNNING.name()) == 0;
|
||||
boolean performanceExecuteOk = testPlanReportResourceService.countByReportIdAndResourceTypeAndExecuteResultEquals(planReportId, TestPlanResourceType.PERFORMANCE_CASE.name(), TestPlanApiExecuteStatus.RUNNING.name()) == 0;
|
||||
;
|
||||
|
||||
testPlanLog.info("ReportId[" + planReportId + "] count over. Testplan Execute Result: Api is over ->" + apiCaseExecuteOk + "; scenario is over ->" + scenarioExecuteOk + "; performance is over ->" + performanceExecuteOk);
|
||||
|
||||
TestPlanReportExecuteCatch.setReportDataCheckResult(planReportId,true);
|
||||
TestPlanReportDataWithBLOBs reportData = reportDataList.get(0);
|
||||
|
||||
|
||||
// SqlSession sqlSession = sqlSessionFactory.openSession(false);
|
||||
// TestPlanReportDataMapper updateReportDataMapper = sqlSession.getMapper(TestPlanReportDataMapper.class);
|
||||
// updateReportDataMapper.updateByPrimaryKeySelective(reportData);
|
||||
// sqlSession.commit();
|
||||
// sqlSession.flushStatements();
|
||||
|
||||
|
||||
report = this.updateReport(reportData, apiCaseExecuteOk, scenarioExecuteOk, performanceExecuteOk, updateTime);
|
||||
report = this.updateReport(reportData,updateTime,executeInfo);
|
||||
} else {
|
||||
testPlanLog.info("ReportId[" + planReportId + "] CANNOT FIND REPORT! Execited result. api :" + JSONObject.toJSONString(executeApiCaseIdMap) + "; scenario:" + JSONObject.toJSONString(executeScenarioCaseIdMap) + "; performance:" + JSONObject.toJSONString(executePerformanceIdMap));
|
||||
TestPlanReportExecuteCatch.setReportDataCheckResult(planReportId,false);
|
||||
}
|
||||
|
||||
return report;
|
||||
|
@ -1249,4 +1060,18 @@ public class TestPlanReportService {
|
|||
}
|
||||
this.delete(testPlanReportIdList);
|
||||
}
|
||||
|
||||
public void countReport(String planReportId) {
|
||||
TestPlanExecuteInfo executeInfo = TestPlanReportExecuteCatch.getTestPlanExecuteInfo(planReportId);
|
||||
int unFinishNum = executeInfo.countUnFinishedNum();
|
||||
if(unFinishNum > 0){
|
||||
//如果间隔超过5分钟没有案例执行完成,则把执行结果变成false
|
||||
long lastCountTime = executeInfo.getLastFinishedNumCountTime();
|
||||
long nowTime = System.currentTimeMillis();
|
||||
if(nowTime - lastCountTime > 300000){
|
||||
TestPlanReportExecuteCatch.finishAllTask(planReportId);
|
||||
}
|
||||
}
|
||||
this.updateExecuteApis(planReportId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.metersphere.api.cache.TestPlanReportExecuteCatch;
|
||||
import io.metersphere.api.dto.APIReportResult;
|
||||
import io.metersphere.api.dto.automation.*;
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
|
||||
|
@ -62,6 +63,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
|
@ -75,6 +77,8 @@ import java.net.URLEncoder;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
@ -168,6 +172,8 @@ public class TestPlanService {
|
|||
@Resource
|
||||
private IssueTemplateService issueTemplateService;
|
||||
|
||||
private final ExecutorService executorService = Executors.newFixedThreadPool(20);
|
||||
|
||||
public synchronized TestPlan addTestPlan(AddTestPlanRequest testPlan) {
|
||||
if (getTestPlanByName(testPlan.getName()).size() > 0) {
|
||||
MSException.throwException(Translator.get("plan_name_already_exists"));
|
||||
|
@ -979,13 +985,14 @@ public class TestPlanService {
|
|||
return returnId;
|
||||
}
|
||||
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public String run(String testPlanID, String projectID, String userId, String triggerMode, String apiRunConfig) {
|
||||
//创建测试报告,然后返回的ID重新赋值为resourceID,作为后续的参数
|
||||
TestPlanScheduleReportInfoDTO reportInfoDTO = testPlanReportService.genTestPlanReportBySchedule(projectID, testPlanID, userId, triggerMode);
|
||||
|
||||
TestPlanReport testPlanReport = reportInfoDTO.getTestPlanReport();
|
||||
Map<String, String> planScenarioIdMap = reportInfoDTO.getPlanScenarioIdMap();
|
||||
Map<String, String> apiTestCaseIdMap = reportInfoDTO.getApiTestCaseIdMap();
|
||||
Map<ApiTestCaseWithBLOBs, String> apiTestCaseDataMap = reportInfoDTO.getApiTestCaseDataMap();
|
||||
Map<String, String> performanceIdMap = reportInfoDTO.getPerformanceIdMap();
|
||||
|
||||
String planReportId = testPlanReport.getId();
|
||||
|
@ -1042,32 +1049,64 @@ public class TestPlanService {
|
|||
|
||||
}
|
||||
|
||||
for (Map.Entry<String, String> entry : apiTestCaseIdMap.entrySet()) {
|
||||
String apiCaseID = entry.getKey();
|
||||
executeApiCaseIdMap.put(apiCaseID, TestPlanApiExecuteStatus.RUNNING.name());
|
||||
for (Map.Entry<ApiTestCaseWithBLOBs, String> entry : apiTestCaseDataMap.entrySet()) {
|
||||
ApiTestCaseWithBLOBs model = entry.getKey();
|
||||
executeApiCaseIdMap.put(model.getId(), TestPlanApiExecuteStatus.RUNNING.name());
|
||||
}
|
||||
for (String id : planScenarioIdMap.keySet()) {
|
||||
executeScenarioCaseIdMap.put(id, TestPlanApiExecuteStatus.RUNNING.name());
|
||||
}
|
||||
testPlanLog.info("ReportId[" + planReportId + "] start run. TestPlanID:[" + testPlanID + "]. Execute api :" + JSONObject.toJSONString(executeApiCaseIdMap) + "; Execute scenario:" + JSONObject.toJSONString(executeScenarioCaseIdMap) + "; Execute performance:" + JSONObject.toJSONString(executePerformanceIdMap));
|
||||
testPlanReportService.updateExecuteApis(planReportId, executeApiCaseIdMap, executeScenarioCaseIdMap, executePerformanceIdMap);
|
||||
|
||||
// testPlanReportService.updateExecuteApis(planReportId, executeApiCaseIdMap, executeScenarioCaseIdMap, executePerformanceIdMap);
|
||||
TestPlanReportExecuteCatch.updateApiTestPlanExecuteInfo(planReportId,executeApiCaseIdMap,executeScenarioCaseIdMap,executePerformanceIdMap);
|
||||
|
||||
//执行接口案例任务
|
||||
for (Map.Entry<String, String> entry : apiTestCaseIdMap.entrySet()) {
|
||||
String apiCaseID = entry.getKey();
|
||||
// String planCaseID = entry.getValue();
|
||||
ApiTestCaseWithBLOBs blobs = apiTestCaseService.get(apiCaseID);
|
||||
//需要更新这里来保证PlanCase的状态能正常更改
|
||||
if (StringUtils.equals(triggerMode, ReportTriggerMode.API.name())) {
|
||||
apiTestCaseService.run(blobs, UUID.randomUUID().toString(), planReportId, testPlanID, ApiRunMode.JENKINS_API_PLAN.name());
|
||||
} else {
|
||||
apiTestCaseService.run(blobs, UUID.randomUUID().toString(), planReportId, testPlanID, ApiRunMode.SCHEDULE_API_PLAN.name());
|
||||
}
|
||||
executeApiCaseIdMap.put(apiCaseID, TestPlanApiExecuteStatus.RUNNING.name());
|
||||
this.executeApiTestCase(triggerMode,planReportId,testPlanID,apiTestCaseDataMap);
|
||||
//执行场景执行任务
|
||||
this.executeScenarioCase(planReportId,testPlanID,projectID,apiRunConfig,triggerMode,userId,planScenarioIdMap);
|
||||
this.listenTaskExecuteStatus(planReportId);
|
||||
return testPlanReport.getId();
|
||||
}
|
||||
|
||||
//执行场景执行任务
|
||||
private void listenTaskExecuteStatus(String planReportId) {
|
||||
executorService.submit(()->{
|
||||
try {
|
||||
Thread.sleep(30000);
|
||||
while (TestPlanReportExecuteCatch.getTestPlanExecuteInfo(planReportId) != null){
|
||||
testPlanReportService.countReport(planReportId);
|
||||
Thread.sleep(30000);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void executeApiTestCase(String triggerMode, String planReportId,String testPlanId,Map<ApiTestCaseWithBLOBs, String> apiTestCaseDataMap) {
|
||||
executorService.submit(() -> {
|
||||
Map<String,String> executeErrorMap = new HashMap<>();
|
||||
for (Map.Entry<ApiTestCaseWithBLOBs, String> entry : apiTestCaseDataMap.entrySet()) {
|
||||
ApiTestCaseWithBLOBs blobs = entry.getKey();
|
||||
try{
|
||||
if (StringUtils.equals(triggerMode, ReportTriggerMode.API.name())) {
|
||||
apiTestCaseService.run(blobs, UUID.randomUUID().toString(), planReportId, testPlanId, ApiRunMode.JENKINS_API_PLAN.name());
|
||||
} else {
|
||||
apiTestCaseService.run(blobs, UUID.randomUUID().toString(), planReportId, testPlanId, ApiRunMode.SCHEDULE_API_PLAN.name());
|
||||
}
|
||||
}catch (Exception e){
|
||||
executeErrorMap.put(blobs.getId(),TestPlanApiExecuteStatus.FAILD.name());
|
||||
}
|
||||
}
|
||||
|
||||
if(!executeErrorMap.isEmpty()){
|
||||
TestPlanReportExecuteCatch.updateApiTestPlanExecuteInfo(planReportId,executeErrorMap,null,null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void executeScenarioCase(String planReportId,String testPlanID,String projectID, String apiRunConfig, String triggerMode, String userId, Map<String, String> planScenarioIdMap) {
|
||||
executorService.submit(()->{
|
||||
if (!planScenarioIdMap.isEmpty()) {
|
||||
SchedulePlanScenarioExecuteRequest scenarioRequest = new SchedulePlanScenarioExecuteRequest();
|
||||
String senarionReportID = UUID.randomUUID().toString();
|
||||
|
@ -1090,11 +1129,24 @@ public class TestPlanService {
|
|||
scenarioRequest.setTestPlanID(testPlanID);
|
||||
|
||||
scenarioRequest.setTestPlanReportId(planReportId);
|
||||
RunModeConfig runModeConfig = JSONObject.parseObject(apiRunConfig, RunModeConfig.class);
|
||||
scenarioRequest.setConfig(runModeConfig);
|
||||
String scenarioReportID = this.scenarioRunModeConfig(scenarioRequest);
|
||||
RunModeConfig runModeConfig = null;
|
||||
try {
|
||||
runModeConfig = JSONObject.parseObject(apiRunConfig, RunModeConfig.class);
|
||||
runModeConfig.setOnSampleError(false);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return testPlanReport.getId();
|
||||
if (runModeConfig == null){
|
||||
runModeConfig = new RunModeConfig();
|
||||
runModeConfig.setMode("serial");
|
||||
runModeConfig.setReportType("iddReport");
|
||||
runModeConfig.setOnSampleError(false);
|
||||
}
|
||||
|
||||
scenarioRequest.setConfig(runModeConfig);
|
||||
this.scenarioRunModeConfig(scenarioRequest);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String getLogDetails(String id) {
|
||||
|
|
|
@ -96,3 +96,6 @@ ALTER TABLE share_info change
|
|||
SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'Share Custom Data';
|
||||
|
||||
ALTER TABLE test_plan ADD report_config text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '测试计划报告配置';
|
||||
|
||||
-- 删除不用的记录表
|
||||
DROP TABLE test_plan_report_resource;
|
|
@ -25,7 +25,7 @@
|
|||
<p class="tip">{{ $t('test_track.plan_view.mock_info') }} </p>
|
||||
<div class="mock-info">
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-col :span="20">
|
||||
Mock地址:
|
||||
<el-link v-if="this.mockInfo !== '' " target="_blank" style="color: black"
|
||||
type="primary">{{ this.mockInfo }}
|
||||
|
@ -34,6 +34,9 @@
|
|||
type="primary">当前项目未开启Mock服务
|
||||
</el-link>
|
||||
</el-col>
|
||||
<el-col :span="4">
|
||||
<el-link @click="mockSetting" type="primary">Mock设置</el-link>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
<!-- 请求参数 -->
|
||||
|
@ -60,7 +63,7 @@
|
|||
import MsTcpBasicApi from "./TCPBasicApi";
|
||||
import MsTcpFormatParameters from "../request/tcp/TcpFormatParameters";
|
||||
import MsChangeHistory from "../../../../history/ChangeHistory";
|
||||
import {hasLicense,getCurrentProjectID} from "@/common/js/utils";
|
||||
import {hasLicense, getCurrentProjectID, getUUID} from "@/common/js/utils";
|
||||
|
||||
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
|
||||
const esbDefinition = (requireComponent!=null&&requireComponent.keys().length) > 0 ? requireComponent("./apidefinition/EsbDefinition.vue") : {};
|
||||
|
@ -214,6 +217,9 @@ export default {
|
|||
this.mockInfo = response.data;
|
||||
});
|
||||
},
|
||||
mockSetting() {
|
||||
this.$store.state.currentApiCase={mock : getUUID()};
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue