chore: 统一规范执行状态和结果状态
This commit is contained in:
parent
f0f3f69b7a
commit
a339c813f6
|
@ -1,7 +1,7 @@
|
||||||
package io.metersphere.sdk.constants;
|
package io.metersphere.sdk.constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报告执行状态
|
* 执行状态
|
||||||
*/
|
*/
|
||||||
public enum ExecStatus {
|
public enum ExecStatus {
|
||||||
/**
|
/**
|
||||||
|
@ -23,23 +23,5 @@ public enum ExecStatus {
|
||||||
/**
|
/**
|
||||||
* 完成
|
* 完成
|
||||||
*/
|
*/
|
||||||
COMPLETED,
|
COMPLETED
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过
|
|
||||||
*/
|
|
||||||
SUCCESS,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 失败
|
|
||||||
*/
|
|
||||||
ERROR,
|
|
||||||
/**
|
|
||||||
* 阻塞
|
|
||||||
*/
|
|
||||||
BLOCKED,
|
|
||||||
/**
|
|
||||||
* 误报
|
|
||||||
*/
|
|
||||||
FAKE_ERROR
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package io.metersphere.sdk.constants;
|
package io.metersphere.sdk.constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报告状态
|
* 结果状态
|
||||||
*/
|
*/
|
||||||
public enum ReportStatus {
|
public enum ResultStatus {
|
||||||
/**
|
/**
|
||||||
* 成功
|
* 成功
|
||||||
*/
|
*/
|
||||||
|
@ -17,5 +17,9 @@ public enum ReportStatus {
|
||||||
/**
|
/**
|
||||||
* 误报
|
* 误报
|
||||||
*/
|
*/
|
||||||
FAKE_ERROR
|
FAKE_ERROR,
|
||||||
|
/**
|
||||||
|
* 阻塞
|
||||||
|
*/
|
||||||
|
BLOCKED,
|
||||||
}
|
}
|
|
@ -49,7 +49,6 @@ public class MinioRepository implements FileRepository {
|
||||||
try {
|
try {
|
||||||
Object serverUrl = minioConfig.get(ENDPOINT).toString();
|
Object serverUrl = minioConfig.get(ENDPOINT).toString();
|
||||||
if (ObjectUtils.isNotEmpty(serverUrl)) {
|
if (ObjectUtils.isNotEmpty(serverUrl)) {
|
||||||
LogUtils.info("开始初始化MinIO插件");
|
|
||||||
// 创建 MinioClient 客户端
|
// 创建 MinioClient 客户端
|
||||||
client = MinioClient.builder()
|
client = MinioClient.builder()
|
||||||
.endpoint(minioConfig.get(ENDPOINT).toString())
|
.endpoint(minioConfig.get(ENDPOINT).toString())
|
||||||
|
@ -59,7 +58,6 @@ public class MinioRepository implements FileRepository {
|
||||||
if (!exist) {
|
if (!exist) {
|
||||||
client.makeBucket(MakeBucketArgs.builder().bucket(BUCKET).build());
|
client.makeBucket(MakeBucketArgs.builder().bucket(BUCKET).build());
|
||||||
}
|
}
|
||||||
LogUtils.info("初始化MinIO成功");
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtils.error("MinIOClient初始化失败!", e);
|
LogUtils.error("MinIOClient初始化失败!", e);
|
||||||
|
|
|
@ -28,8 +28,7 @@ public class DateUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDateString(long timeStamp) throws Exception {
|
public static String getDateString(long timeStamp) throws Exception {
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN);
|
return getDataStr(timeStamp);
|
||||||
return dateFormat.format(timeStamp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getTimeString(Date date) throws Exception {
|
public static String getTimeString(Date date) throws Exception {
|
||||||
|
|
|
@ -26,12 +26,10 @@ import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class GitRepositoryUtil {
|
public class GitRepositoryUtil {
|
||||||
private final String REF_SPACE = "+refs/heads/*:refs/heads/*";
|
|
||||||
private final String DEFAULT_GIT_USERNAME = "PRIVATE-TOKEN";
|
|
||||||
|
|
||||||
private String repositoryUrl;
|
private final String repositoryUrl;
|
||||||
private String userName;
|
private final String userName;
|
||||||
private String token;
|
private final String token;
|
||||||
|
|
||||||
private Git git;
|
private Git git;
|
||||||
|
|
||||||
|
@ -40,14 +38,11 @@ public class GitRepositoryUtil {
|
||||||
if (StringUtils.isNotBlank(userName)) {
|
if (StringUtils.isNotBlank(userName)) {
|
||||||
this.userName = StringUtils.trim(userName);
|
this.userName = StringUtils.trim(userName);
|
||||||
} else {
|
} else {
|
||||||
this.userName = this.DEFAULT_GIT_USERNAME;
|
this.userName = "PRIVATE-TOKEN";
|
||||||
}
|
}
|
||||||
this.token = StringUtils.trim(token);
|
this.token = StringUtils.trim(token);
|
||||||
LogUtils.info("初始化文件库完成. repositoryUrl:" + repositoryUrl + "; userName:" + userName + "; token:" + token);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//以下方法先注释掉,用到了再打开
|
|
||||||
|
|
||||||
public byte[] getFile(String filePath, String commitId) throws Exception {
|
public byte[] getFile(String filePath, String commitId) throws Exception {
|
||||||
LogUtils.info("准备获取文件. repositoryUrl:" + repositoryUrl + "; filePath:" + filePath + "; commitId:" + commitId);
|
LogUtils.info("准备获取文件. repositoryUrl:" + repositoryUrl + "; filePath:" + filePath + "; commitId:" + commitId);
|
||||||
|
|
||||||
|
@ -156,6 +151,7 @@ public class GitRepositoryUtil {
|
||||||
InMemoryRepository repo = new InMemoryRepository(repoDesc);
|
InMemoryRepository repo = new InMemoryRepository(repoDesc);
|
||||||
CredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider(userName, token);
|
CredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider(userName, token);
|
||||||
git = new Git(repo);
|
git = new Git(repo);
|
||||||
|
String REF_SPACE = "+refs/heads/*:refs/heads/*";
|
||||||
git.fetch().setRemote(repositoryUrl).setRefSpecs(new RefSpec(REF_SPACE)).setCredentialsProvider(credentialsProvider).call();
|
git.fetch().setRemote(repositoryUrl).setRefSpecs(new RefSpec(REF_SPACE)).setCredentialsProvider(credentialsProvider).call();
|
||||||
repo.getObjectDatabase();
|
repo.getObjectDatabase();
|
||||||
return repo;
|
return repo;
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class XMLUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Document stringToDocument(String xml) throws Exception {
|
public static Document stringToDocument(String xml) throws Exception {
|
||||||
return getDocument(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8.name())));
|
return getDocument(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Object> xmlStringToJson(String xml) {
|
public static Map<String, Object> xmlStringToJson(String xml) {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package io.metersphere.api.listener;
|
package io.metersphere.api.listener;
|
||||||
|
|
||||||
import io.metersphere.api.event.ApiEventSource;
|
|
||||||
import io.metersphere.api.invoker.ApiExecuteCallbackServiceInvoker;
|
import io.metersphere.api.invoker.ApiExecuteCallbackServiceInvoker;
|
||||||
import io.metersphere.api.mapper.ApiReportMapper;
|
import io.metersphere.api.mapper.ApiReportMapper;
|
||||||
import io.metersphere.api.mapper.ApiScenarioReportMapper;
|
import io.metersphere.api.mapper.ApiScenarioReportMapper;
|
||||||
|
@ -162,6 +161,6 @@ public class MessageListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isStopOnFailure(ApiNoticeDTO dto) {
|
private boolean isStopOnFailure(ApiNoticeDTO dto) {
|
||||||
return BooleanUtils.isTrue(dto.getRunModeConfig().getStopOnFailure()) && StringUtils.equals(dto.getReportStatus(), ReportStatus.ERROR.name());
|
return BooleanUtils.isTrue(dto.getRunModeConfig().getStopOnFailure()) && StringUtils.equals(dto.getReportStatus(), ResultStatus.ERROR.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import io.metersphere.api.mapper.*;
|
||||||
import io.metersphere.project.domain.Project;
|
import io.metersphere.project.domain.Project;
|
||||||
import io.metersphere.project.mapper.ProjectMapper;
|
import io.metersphere.project.mapper.ProjectMapper;
|
||||||
import io.metersphere.sdk.constants.ApiExecuteResourceType;
|
import io.metersphere.sdk.constants.ApiExecuteResourceType;
|
||||||
import io.metersphere.sdk.constants.ReportStatus;
|
import io.metersphere.sdk.constants.ResultStatus;
|
||||||
import io.metersphere.sdk.domain.Environment;
|
import io.metersphere.sdk.domain.Environment;
|
||||||
import io.metersphere.sdk.dto.api.notice.ApiNoticeDTO;
|
import io.metersphere.sdk.dto.api.notice.ApiNoticeDTO;
|
||||||
import io.metersphere.sdk.mapper.EnvironmentMapper;
|
import io.metersphere.sdk.mapper.EnvironmentMapper;
|
||||||
|
@ -97,11 +97,11 @@ public class ApiReportSendNoticeService {
|
||||||
noticeType = NoticeConstants.TaskType.API_SCENARIO_TASK;
|
noticeType = NoticeConstants.TaskType.API_SCENARIO_TASK;
|
||||||
report = apiScenarioReportMapper.selectByPrimaryKey(noticeDTO.getReportId());
|
report = apiScenarioReportMapper.selectByPrimaryKey(noticeDTO.getReportId());
|
||||||
reportUrl = String.format(reportUrl, project.getOrganizationId(), project.getId(), ApiExecuteResourceType.API_SCENARIO.name(), report.getId());
|
reportUrl = String.format(reportUrl, project.getOrganizationId(), project.getId(), ApiExecuteResourceType.API_SCENARIO.name(), report.getId());
|
||||||
if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ReportStatus.SUCCESS.name())) {
|
if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ResultStatus.SUCCESS.name())) {
|
||||||
event = NoticeConstants.Event.SCENARIO_EXECUTE_SUCCESSFUL;
|
event = NoticeConstants.Event.SCENARIO_EXECUTE_SUCCESSFUL;
|
||||||
} else if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ReportStatus.FAKE_ERROR.name())) {
|
} else if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ResultStatus.FAKE_ERROR.name())) {
|
||||||
event = NoticeConstants.Event.SCENARIO_EXECUTE_FAKE_ERROR;
|
event = NoticeConstants.Event.SCENARIO_EXECUTE_FAKE_ERROR;
|
||||||
} else if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ReportStatus.ERROR.name())) {
|
} else if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ResultStatus.ERROR.name())) {
|
||||||
event = NoticeConstants.Event.SCENARIO_EXECUTE_FAILED;
|
event = NoticeConstants.Event.SCENARIO_EXECUTE_FAILED;
|
||||||
}
|
}
|
||||||
shareUrl = String.format(shareUrl, "shareReportScenario");
|
shareUrl = String.format(shareUrl, "shareReportScenario");
|
||||||
|
@ -129,11 +129,11 @@ public class ApiReportSendNoticeService {
|
||||||
ApiReport apiReport = apiReportMapper.selectByPrimaryKey(noticeDTO.getReportId());
|
ApiReport apiReport = apiReportMapper.selectByPrimaryKey(noticeDTO.getReportId());
|
||||||
reportUrl = String.format(reportUrl, project.getOrganizationId(), project.getId(), ApiExecuteResourceType.API_CASE.name(), apiReport.getId());
|
reportUrl = String.format(reportUrl, project.getOrganizationId(), project.getId(), ApiExecuteResourceType.API_CASE.name(), apiReport.getId());
|
||||||
BeanUtils.copyBean(report, apiReport);
|
BeanUtils.copyBean(report, apiReport);
|
||||||
if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ReportStatus.SUCCESS.name())) {
|
if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ResultStatus.SUCCESS.name())) {
|
||||||
event = NoticeConstants.Event.CASE_EXECUTE_SUCCESSFUL;
|
event = NoticeConstants.Event.CASE_EXECUTE_SUCCESSFUL;
|
||||||
} else if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ReportStatus.FAKE_ERROR.name())) {
|
} else if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ResultStatus.FAKE_ERROR.name())) {
|
||||||
event = NoticeConstants.Event.CASE_EXECUTE_FAKE_ERROR;
|
event = NoticeConstants.Event.CASE_EXECUTE_FAKE_ERROR;
|
||||||
} else if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ReportStatus.ERROR.name())) {
|
} else if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ResultStatus.ERROR.name())) {
|
||||||
event = NoticeConstants.Event.CASE_EXECUTE_FAILED;
|
event = NoticeConstants.Event.CASE_EXECUTE_FAILED;
|
||||||
}
|
}
|
||||||
shareUrl = String.format(shareUrl, "shareReportCase");
|
shareUrl = String.format(shareUrl, "shareReportCase");
|
||||||
|
@ -161,9 +161,9 @@ public class ApiReportSendNoticeService {
|
||||||
|
|
||||||
|
|
||||||
String reportStatus = report.getStatus();
|
String reportStatus = report.getStatus();
|
||||||
if (StringUtils.endsWithIgnoreCase(reportStatus, ReportStatus.SUCCESS.name())) {
|
if (StringUtils.endsWithIgnoreCase(reportStatus, ResultStatus.SUCCESS.name())) {
|
||||||
reportStatus = Translator.get("report.status.success");
|
reportStatus = Translator.get("report.status.success");
|
||||||
} else if (StringUtils.endsWithIgnoreCase(reportStatus, ReportStatus.FAKE_ERROR.name())) {
|
} else if (StringUtils.endsWithIgnoreCase(reportStatus, ResultStatus.FAKE_ERROR.name())) {
|
||||||
reportStatus = Translator.get("report.status.fake_error");
|
reportStatus = Translator.get("report.status.fake_error");
|
||||||
} else {
|
} else {
|
||||||
reportStatus = Translator.get("report.status.error");
|
reportStatus = Translator.get("report.status.error");
|
||||||
|
|
|
@ -378,7 +378,7 @@ public class ApiTestCaseBatchRunService {
|
||||||
BeanUtils.copyBean(apiScenarioReport, report);
|
BeanUtils.copyBean(apiScenarioReport, report);
|
||||||
apiScenarioReport = apiBatchRunBaseService.computeRequestRate(apiScenarioReport, total);
|
apiScenarioReport = apiBatchRunBaseService.computeRequestRate(apiScenarioReport, total);
|
||||||
BeanUtils.copyBean(report, apiScenarioReport);
|
BeanUtils.copyBean(report, apiScenarioReport);
|
||||||
report.setStatus(ReportStatus.ERROR.name());
|
report.setStatus(ResultStatus.ERROR.name());
|
||||||
report.setExecStatus(ExecStatus.COMPLETED.name());
|
report.setExecStatus(ExecStatus.COMPLETED.name());
|
||||||
apiReportMapper.updateByPrimaryKeySelective(report);
|
apiReportMapper.updateByPrimaryKeySelective(report);
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,7 +383,7 @@ public class ApiScenarioBatchRunService {
|
||||||
// 计算各种通过率
|
// 计算各种通过率
|
||||||
long total = apiScenarioReportService.getRequestTotal(report);
|
long total = apiScenarioReportService.getRequestTotal(report);
|
||||||
report = apiBatchRunBaseService.computeRequestRate(report, total);
|
report = apiBatchRunBaseService.computeRequestRate(report, total);
|
||||||
report.setStatus(ReportStatus.ERROR.name());
|
report.setStatus(ResultStatus.ERROR.name());
|
||||||
report.setExecStatus(ExecStatus.COMPLETED.name());
|
report.setExecStatus(ExecStatus.COMPLETED.name());
|
||||||
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
|
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import io.metersphere.api.dto.scenario.ApiScenarioReportDetailDTO;
|
||||||
import io.metersphere.api.dto.scenario.ApiScenarioReportStepDTO;
|
import io.metersphere.api.dto.scenario.ApiScenarioReportStepDTO;
|
||||||
import io.metersphere.api.mapper.*;
|
import io.metersphere.api.mapper.*;
|
||||||
import io.metersphere.sdk.constants.ExecStatus;
|
import io.metersphere.sdk.constants.ExecStatus;
|
||||||
import io.metersphere.sdk.constants.ReportStatus;
|
import io.metersphere.sdk.constants.ResultStatus;
|
||||||
import io.metersphere.sdk.domain.Environment;
|
import io.metersphere.sdk.domain.Environment;
|
||||||
import io.metersphere.sdk.domain.EnvironmentGroup;
|
import io.metersphere.sdk.domain.EnvironmentGroup;
|
||||||
import io.metersphere.sdk.mapper.EnvironmentGroupMapper;
|
import io.metersphere.sdk.mapper.EnvironmentGroupMapper;
|
||||||
|
@ -210,10 +210,10 @@ public class ApiScenarioReportService {
|
||||||
scenarioReportDTO.setRequestTotal(getRequestTotal(scenarioReportDTO));
|
scenarioReportDTO.setRequestTotal(getRequestTotal(scenarioReportDTO));
|
||||||
scenarioReportDTO.setChildren(steps);
|
scenarioReportDTO.setChildren(steps);
|
||||||
|
|
||||||
scenarioReportDTO.setStepErrorCount(steps.stream().filter(step -> StringUtils.equals(ReportStatus.ERROR.name(), step.getStatus())).count());
|
scenarioReportDTO.setStepErrorCount(steps.stream().filter(step -> StringUtils.equals(ResultStatus.ERROR.name(), step.getStatus())).count());
|
||||||
scenarioReportDTO.setStepSuccessCount(steps.stream().filter(step -> StringUtils.equals(ReportStatus.SUCCESS.name(), step.getStatus())).count());
|
scenarioReportDTO.setStepSuccessCount(steps.stream().filter(step -> StringUtils.equals(ResultStatus.SUCCESS.name(), step.getStatus())).count());
|
||||||
scenarioReportDTO.setStepPendingCount(steps.stream().filter(step -> StringUtils.equals(ExecStatus.PENDING.name(), step.getStatus()) || StringUtils.isBlank(step.getStatus())).count());
|
scenarioReportDTO.setStepPendingCount(steps.stream().filter(step -> StringUtils.equals(ExecStatus.PENDING.name(), step.getStatus()) || StringUtils.isBlank(step.getStatus())).count());
|
||||||
scenarioReportDTO.setStepFakeErrorCount(steps.stream().filter(step -> StringUtils.equals(ReportStatus.FAKE_ERROR.name(), step.getStatus())).count());
|
scenarioReportDTO.setStepFakeErrorCount(steps.stream().filter(step -> StringUtils.equals(ResultStatus.FAKE_ERROR.name(), step.getStatus())).count());
|
||||||
//控制台信息 console
|
//控制台信息 console
|
||||||
ApiScenarioReportLogExample example = new ApiScenarioReportLogExample();
|
ApiScenarioReportLogExample example = new ApiScenarioReportLogExample();
|
||||||
example.createCriteria().andReportIdEqualTo(id);
|
example.createCriteria().andReportIdEqualTo(id);
|
||||||
|
@ -251,7 +251,7 @@ public class ApiScenarioReportService {
|
||||||
scenarioReportSteps.parallelStream().forEach(step -> {
|
scenarioReportSteps.parallelStream().forEach(step -> {
|
||||||
if (StringUtils.equals(ApiScenarioStepType.CONSTANT_TIMER.name(), step.getStepType())) {
|
if (StringUtils.equals(ApiScenarioStepType.CONSTANT_TIMER.name(), step.getStepType())) {
|
||||||
if (CollectionUtils.isNotEmpty(detailMap.get(step.getStepId()))) {
|
if (CollectionUtils.isNotEmpty(detailMap.get(step.getStepId()))) {
|
||||||
step.setStatus(ReportStatus.SUCCESS.name());
|
step.setStatus(ResultStatus.SUCCESS.name());
|
||||||
} else {
|
} else {
|
||||||
step.setStatus(ExecStatus.PENDING.name());
|
step.setStatus(ExecStatus.PENDING.name());
|
||||||
}
|
}
|
||||||
|
@ -273,13 +273,13 @@ public class ApiScenarioReportService {
|
||||||
step.setRequestTime(details.stream().mapToLong(ApiScenarioReportStepDTO::getRequestTime).sum());
|
step.setRequestTime(details.stream().mapToLong(ApiScenarioReportStepDTO::getRequestTime).sum());
|
||||||
step.setResponseSize(details.stream().mapToLong(ApiScenarioReportStepDTO::getResponseSize).sum());
|
step.setResponseSize(details.stream().mapToLong(ApiScenarioReportStepDTO::getResponseSize).sum());
|
||||||
List<String> requestStatus = details.stream().map(ApiScenarioReportStepDTO::getStatus).toList();
|
List<String> requestStatus = details.stream().map(ApiScenarioReportStepDTO::getStatus).toList();
|
||||||
List<String> successStatus = requestStatus.stream().filter(status -> StringUtils.equals(ReportStatus.SUCCESS.name(), status)).toList();
|
List<String> successStatus = requestStatus.stream().filter(status -> StringUtils.equals(ResultStatus.SUCCESS.name(), status)).toList();
|
||||||
if (requestStatus.contains(ReportStatus.ERROR.name())) {
|
if (requestStatus.contains(ResultStatus.ERROR.name())) {
|
||||||
step.setStatus(ReportStatus.ERROR.name());
|
step.setStatus(ResultStatus.ERROR.name());
|
||||||
} else if (requestStatus.contains(ReportStatus.FAKE_ERROR.name())) {
|
} else if (requestStatus.contains(ResultStatus.FAKE_ERROR.name())) {
|
||||||
step.setStatus(ReportStatus.FAKE_ERROR.name());
|
step.setStatus(ResultStatus.FAKE_ERROR.name());
|
||||||
} else if (successStatus.size() == details.size()) {
|
} else if (successStatus.size() == details.size()) {
|
||||||
step.setStatus(ReportStatus.SUCCESS.name());
|
step.setStatus(ResultStatus.SUCCESS.name());
|
||||||
} else {
|
} else {
|
||||||
step.setStatus(ExecStatus.PENDING.name());
|
step.setStatus(ExecStatus.PENDING.name());
|
||||||
}
|
}
|
||||||
|
@ -324,14 +324,14 @@ public class ApiScenarioReportService {
|
||||||
//获取为执行的状态
|
//获取为执行的状态
|
||||||
List<String> pendingStatus = requestStatus.stream().filter(status -> StringUtils.equals(ExecStatus.PENDING.name(), status) || StringUtils.isBlank(status)).toList();
|
List<String> pendingStatus = requestStatus.stream().filter(status -> StringUtils.equals(ExecStatus.PENDING.name(), status) || StringUtils.isBlank(status)).toList();
|
||||||
//过滤出来SUCCESS的状态
|
//过滤出来SUCCESS的状态
|
||||||
List<String> successStatus = requestStatus.stream().filter(status -> StringUtils.equals(ReportStatus.SUCCESS.name(), status)).toList();
|
List<String> successStatus = requestStatus.stream().filter(status -> StringUtils.equals(ResultStatus.SUCCESS.name(), status)).toList();
|
||||||
//只要包含ERROR 就是ERROR
|
//只要包含ERROR 就是ERROR
|
||||||
if (requestStatus.contains(ReportStatus.ERROR.name())) {
|
if (requestStatus.contains(ResultStatus.ERROR.name())) {
|
||||||
step.setStatus(ReportStatus.ERROR.name());
|
step.setStatus(ResultStatus.ERROR.name());
|
||||||
} else if (requestStatus.contains(ReportStatus.FAKE_ERROR.name())) {
|
} else if (requestStatus.contains(ResultStatus.FAKE_ERROR.name())) {
|
||||||
step.setStatus(ReportStatus.FAKE_ERROR.name());
|
step.setStatus(ResultStatus.FAKE_ERROR.name());
|
||||||
} else if (successStatus.size() + pendingStatus.size() == children.size() && !successStatus.isEmpty()) {
|
} else if (successStatus.size() + pendingStatus.size() == children.size() && !successStatus.isEmpty()) {
|
||||||
step.setStatus(ReportStatus.SUCCESS.name());
|
step.setStatus(ResultStatus.SUCCESS.name());
|
||||||
}
|
}
|
||||||
} else if (stepTypes.contains(step.getStepType())) {
|
} else if (stepTypes.contains(step.getStepType())) {
|
||||||
step.setStatus(ExecStatus.PENDING.name());
|
step.setStatus(ExecStatus.PENDING.name());
|
||||||
|
|
|
@ -100,9 +100,9 @@ public class ApiReportControllerTests extends BaseTest {
|
||||||
apiReport.setEnvironmentId("api-environment-id" + i);
|
apiReport.setEnvironmentId("api-environment-id" + i);
|
||||||
apiReport.setRunMode("api-run-mode" + i);
|
apiReport.setRunMode("api-run-mode" + i);
|
||||||
if (i % 50 == 0) {
|
if (i % 50 == 0) {
|
||||||
apiReport.setStatus(ReportStatus.SUCCESS.name());
|
apiReport.setStatus(ResultStatus.SUCCESS.name());
|
||||||
} else if (i % 39 == 0) {
|
} else if (i % 39 == 0) {
|
||||||
apiReport.setStatus(ReportStatus.ERROR.name());
|
apiReport.setStatus(ResultStatus.ERROR.name());
|
||||||
apiReport.setIntegrated(true);
|
apiReport.setIntegrated(true);
|
||||||
}
|
}
|
||||||
apiReport.setTriggerMode("api-trigger-mode" + i);
|
apiReport.setTriggerMode("api-trigger-mode" + i);
|
||||||
|
@ -166,7 +166,7 @@ public class ApiReportControllerTests extends BaseTest {
|
||||||
Assertions.assertTrue(((List<ApiScenarioDTO>) returnPager.getList()).size() <= request.getPageSize());
|
Assertions.assertTrue(((List<ApiScenarioDTO>) returnPager.getList()).size() <= request.getPageSize());
|
||||||
//过滤
|
//过滤
|
||||||
request.setFilter(new HashMap<>() {{
|
request.setFilter(new HashMap<>() {{
|
||||||
put("status", List.of(ReportStatus.SUCCESS.name(), ReportStatus.ERROR.name()));
|
put("status", List.of(ResultStatus.SUCCESS.name(), ResultStatus.ERROR.name()));
|
||||||
}});
|
}});
|
||||||
mvcResult = responsePost(PAGE, request);
|
mvcResult = responsePost(PAGE, request);
|
||||||
returnPager = parseObjectFromMvcResult(mvcResult, Pager.class);
|
returnPager = parseObjectFromMvcResult(mvcResult, Pager.class);
|
||||||
|
@ -175,7 +175,7 @@ public class ApiReportControllerTests extends BaseTest {
|
||||||
Assertions.assertTrue(((List<ApiReport>) returnPager.getList()).size() <= request.getPageSize());
|
Assertions.assertTrue(((List<ApiReport>) returnPager.getList()).size() <= request.getPageSize());
|
||||||
List<ApiReport> list = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ApiReport.class);
|
List<ApiReport> list = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ApiReport.class);
|
||||||
list.forEach(apiReport -> {
|
list.forEach(apiReport -> {
|
||||||
Assertions.assertTrue(apiReport.getStatus().equals(ReportStatus.SUCCESS.name()) || apiReport.getStatus().equals(ReportStatus.ERROR.name()));
|
Assertions.assertTrue(apiReport.getStatus().equals(ResultStatus.SUCCESS.name()) || apiReport.getStatus().equals(ResultStatus.ERROR.name()));
|
||||||
});
|
});
|
||||||
request.setFilter(new HashMap<>() {{
|
request.setFilter(new HashMap<>() {{
|
||||||
put("integrated", List.of("true"));
|
put("integrated", List.of("true"));
|
||||||
|
@ -267,7 +267,7 @@ public class ApiReportControllerTests extends BaseTest {
|
||||||
apiReport.setPoolId(testResourcePools.getFirst().getId());
|
apiReport.setPoolId(testResourcePools.getFirst().getId());
|
||||||
apiReport.setEnvironmentId(environments.getFirst().getId());
|
apiReport.setEnvironmentId(environments.getFirst().getId());
|
||||||
apiReport.setRunMode("api-run-mode");
|
apiReport.setRunMode("api-run-mode");
|
||||||
apiReport.setStatus(ReportStatus.SUCCESS.name());
|
apiReport.setStatus(ResultStatus.SUCCESS.name());
|
||||||
apiReport.setTriggerMode("api-trigger-mode");
|
apiReport.setTriggerMode("api-trigger-mode");
|
||||||
apiReport.setIntegrated(true);
|
apiReport.setIntegrated(true);
|
||||||
reports.add(apiReport);
|
reports.add(apiReport);
|
||||||
|
@ -334,7 +334,7 @@ public class ApiReportControllerTests extends BaseTest {
|
||||||
apiReport.setPoolId(testResourcePools.getFirst().getId());
|
apiReport.setPoolId(testResourcePools.getFirst().getId());
|
||||||
apiReport.setEnvironmentId(environments.getFirst().getId());
|
apiReport.setEnvironmentId(environments.getFirst().getId());
|
||||||
apiReport.setRunMode("api-run-mode");
|
apiReport.setRunMode("api-run-mode");
|
||||||
apiReport.setStatus(ReportStatus.SUCCESS.name());
|
apiReport.setStatus(ResultStatus.SUCCESS.name());
|
||||||
apiReport.setTriggerMode("api-trigger-mode");
|
apiReport.setTriggerMode("api-trigger-mode");
|
||||||
apiReport.setIntegrated(true);
|
apiReport.setIntegrated(true);
|
||||||
reports.add(apiReport);
|
reports.add(apiReport);
|
||||||
|
|
|
@ -7,7 +7,7 @@ import io.metersphere.api.service.ApiReportSendNoticeService;
|
||||||
import io.metersphere.api.service.definition.ApiReportService;
|
import io.metersphere.api.service.definition.ApiReportService;
|
||||||
import io.metersphere.api.service.scenario.ApiScenarioReportService;
|
import io.metersphere.api.service.scenario.ApiScenarioReportService;
|
||||||
import io.metersphere.sdk.constants.ApiExecuteResourceType;
|
import io.metersphere.sdk.constants.ApiExecuteResourceType;
|
||||||
import io.metersphere.sdk.constants.ReportStatus;
|
import io.metersphere.sdk.constants.ResultStatus;
|
||||||
import io.metersphere.sdk.domain.Environment;
|
import io.metersphere.sdk.domain.Environment;
|
||||||
import io.metersphere.sdk.dto.api.notice.ApiNoticeDTO;
|
import io.metersphere.sdk.dto.api.notice.ApiNoticeDTO;
|
||||||
import io.metersphere.sdk.mapper.EnvironmentMapper;
|
import io.metersphere.sdk.mapper.EnvironmentMapper;
|
||||||
|
@ -93,11 +93,11 @@ public class ApiReportSendNoticeTests extends BaseTest {
|
||||||
apiReport.setEnvironmentId("api-environment-id");
|
apiReport.setEnvironmentId("api-environment-id");
|
||||||
apiReport.setRunMode("api-run-mode");
|
apiReport.setRunMode("api-run-mode");
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
apiReport.setStatus(ReportStatus.SUCCESS.name());
|
apiReport.setStatus(ResultStatus.SUCCESS.name());
|
||||||
} else if (i == 1) {
|
} else if (i == 1) {
|
||||||
apiReport.setStatus(ReportStatus.ERROR.name());
|
apiReport.setStatus(ResultStatus.ERROR.name());
|
||||||
} else {
|
} else {
|
||||||
apiReport.setStatus(ReportStatus.FAKE_ERROR.name());
|
apiReport.setStatus(ResultStatus.FAKE_ERROR.name());
|
||||||
}
|
}
|
||||||
apiReport.setTriggerMode("api-trigger-mode" + i);
|
apiReport.setTriggerMode("api-trigger-mode" + i);
|
||||||
reports.add(apiReport);
|
reports.add(apiReport);
|
||||||
|
@ -109,7 +109,7 @@ public class ApiReportSendNoticeTests extends BaseTest {
|
||||||
apiReportService.insertApiReport(reports, records);
|
apiReportService.insertApiReport(reports, records);
|
||||||
ApiNoticeDTO noticeDTO = new ApiNoticeDTO();
|
ApiNoticeDTO noticeDTO = new ApiNoticeDTO();
|
||||||
noticeDTO.setReportId("send-api-case-report-id0");
|
noticeDTO.setReportId("send-api-case-report-id0");
|
||||||
noticeDTO.setReportStatus(ReportStatus.SUCCESS.name());
|
noticeDTO.setReportStatus(ResultStatus.SUCCESS.name());
|
||||||
noticeDTO.setResourceId("send-api-case-id");
|
noticeDTO.setResourceId("send-api-case-id");
|
||||||
noticeDTO.setResourceType("API_CASE");
|
noticeDTO.setResourceType("API_CASE");
|
||||||
noticeDTO.setUserId("admin");
|
noticeDTO.setUserId("admin");
|
||||||
|
@ -117,10 +117,10 @@ public class ApiReportSendNoticeTests extends BaseTest {
|
||||||
noticeDTO.getRunModeConfig().setEnvironmentId("api-environment-id");
|
noticeDTO.getRunModeConfig().setEnvironmentId("api-environment-id");
|
||||||
|
|
||||||
apiReportSendNoticeService.sendNotice(noticeDTO);
|
apiReportSendNoticeService.sendNotice(noticeDTO);
|
||||||
noticeDTO.setReportStatus(ReportStatus.ERROR.name());
|
noticeDTO.setReportStatus(ResultStatus.ERROR.name());
|
||||||
noticeDTO.setReportId("send-api-case-report-id1");
|
noticeDTO.setReportId("send-api-case-report-id1");
|
||||||
apiReportSendNoticeService.sendNotice(noticeDTO);
|
apiReportSendNoticeService.sendNotice(noticeDTO);
|
||||||
noticeDTO.setReportStatus(ReportStatus.FAKE_ERROR.name());
|
noticeDTO.setReportStatus(ResultStatus.FAKE_ERROR.name());
|
||||||
noticeDTO.setReportId("send-api-case-report-id2");
|
noticeDTO.setReportId("send-api-case-report-id2");
|
||||||
apiReportSendNoticeService.sendNotice(noticeDTO);
|
apiReportSendNoticeService.sendNotice(noticeDTO);
|
||||||
|
|
||||||
|
@ -161,11 +161,11 @@ public class ApiReportSendNoticeTests extends BaseTest {
|
||||||
scenarioReport.setCreateUser("admin");
|
scenarioReport.setCreateUser("admin");
|
||||||
scenarioReport.setUpdateUser("admin");
|
scenarioReport.setUpdateUser("admin");
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
scenarioReport.setStatus(ReportStatus.SUCCESS.name());
|
scenarioReport.setStatus(ResultStatus.SUCCESS.name());
|
||||||
} else if (i == 1) {
|
} else if (i == 1) {
|
||||||
scenarioReport.setStatus(ReportStatus.ERROR.name());
|
scenarioReport.setStatus(ResultStatus.ERROR.name());
|
||||||
} else {
|
} else {
|
||||||
scenarioReport.setStatus(ReportStatus.FAKE_ERROR.name());
|
scenarioReport.setStatus(ResultStatus.FAKE_ERROR.name());
|
||||||
}
|
}
|
||||||
scenarioReport.setUpdateTime(System.currentTimeMillis());
|
scenarioReport.setUpdateTime(System.currentTimeMillis());
|
||||||
scenarioReport.setPoolId("api-pool-id" + i);
|
scenarioReport.setPoolId("api-pool-id" + i);
|
||||||
|
@ -183,7 +183,7 @@ public class ApiReportSendNoticeTests extends BaseTest {
|
||||||
|
|
||||||
noticeDTO = new ApiNoticeDTO();
|
noticeDTO = new ApiNoticeDTO();
|
||||||
noticeDTO.setReportId("send-scenario-report-id0");
|
noticeDTO.setReportId("send-scenario-report-id0");
|
||||||
noticeDTO.setReportStatus(ReportStatus.SUCCESS.name());
|
noticeDTO.setReportStatus(ResultStatus.SUCCESS.name());
|
||||||
noticeDTO.setResourceId("send-api-case-id");
|
noticeDTO.setResourceId("send-api-case-id");
|
||||||
noticeDTO.setResourceType("API_SCENARIO");
|
noticeDTO.setResourceType("API_SCENARIO");
|
||||||
noticeDTO.setUserId("admin");
|
noticeDTO.setUserId("admin");
|
||||||
|
@ -191,10 +191,10 @@ public class ApiReportSendNoticeTests extends BaseTest {
|
||||||
noticeDTO.getRunModeConfig().setEnvironmentId("api-environment-id");
|
noticeDTO.getRunModeConfig().setEnvironmentId("api-environment-id");
|
||||||
|
|
||||||
apiReportSendNoticeService.sendNotice(noticeDTO);
|
apiReportSendNoticeService.sendNotice(noticeDTO);
|
||||||
noticeDTO.setReportStatus(ReportStatus.ERROR.name());
|
noticeDTO.setReportStatus(ResultStatus.ERROR.name());
|
||||||
noticeDTO.setReportId("send-scenario-report-id1");
|
noticeDTO.setReportId("send-scenario-report-id1");
|
||||||
apiReportSendNoticeService.sendNotice(noticeDTO);
|
apiReportSendNoticeService.sendNotice(noticeDTO);
|
||||||
noticeDTO.setReportStatus(ReportStatus.FAKE_ERROR.name());
|
noticeDTO.setReportStatus(ResultStatus.FAKE_ERROR.name());
|
||||||
noticeDTO.setReportId("send-scenario-report-id2");
|
noticeDTO.setReportId("send-scenario-report-id2");
|
||||||
apiReportSendNoticeService.sendNotice(noticeDTO);
|
apiReportSendNoticeService.sendNotice(noticeDTO);
|
||||||
|
|
||||||
|
|
|
@ -287,7 +287,7 @@ public class ApiScenarioControllerTests extends BaseTest {
|
||||||
scenarioReport.setStartTime(System.currentTimeMillis());
|
scenarioReport.setStartTime(System.currentTimeMillis());
|
||||||
scenarioReport.setCreateUser("admin");
|
scenarioReport.setCreateUser("admin");
|
||||||
scenarioReport.setUpdateUser("admin");
|
scenarioReport.setUpdateUser("admin");
|
||||||
scenarioReport.setStatus(ReportStatus.SUCCESS.name());
|
scenarioReport.setStatus(ResultStatus.SUCCESS.name());
|
||||||
scenarioReport.setUpdateTime(System.currentTimeMillis());
|
scenarioReport.setUpdateTime(System.currentTimeMillis());
|
||||||
scenarioReport.setPoolId("api-pool-id");
|
scenarioReport.setPoolId("api-pool-id");
|
||||||
scenarioReport.setEnvironmentId("api-environment-id");
|
scenarioReport.setEnvironmentId("api-environment-id");
|
||||||
|
@ -2662,7 +2662,7 @@ public class ApiScenarioControllerTests extends BaseTest {
|
||||||
testPlanApiScenario.setCreateTime(System.currentTimeMillis());
|
testPlanApiScenario.setCreateTime(System.currentTimeMillis());
|
||||||
testPlanApiScenario.setLastExecTime(System.currentTimeMillis());
|
testPlanApiScenario.setLastExecTime(System.currentTimeMillis());
|
||||||
testPlanApiScenario.setLastExecReportId(IDGenerator.nextStr());
|
testPlanApiScenario.setLastExecReportId(IDGenerator.nextStr());
|
||||||
testPlanApiScenario.setLastExecResult(ExecStatus.SUCCESS.name());
|
testPlanApiScenario.setLastExecResult(ResultStatus.SUCCESS.name());
|
||||||
testPlanApiScenario.setPos(1024l);
|
testPlanApiScenario.setPos(1024l);
|
||||||
testPlanApiScenario.setTestPlanCollectionId(planId);
|
testPlanApiScenario.setTestPlanCollectionId(planId);
|
||||||
testPlanApiScenarioMapper.insert(testPlanApiScenario);
|
testPlanApiScenarioMapper.insert(testPlanApiScenario);
|
||||||
|
@ -2679,10 +2679,10 @@ public class ApiScenarioControllerTests extends BaseTest {
|
||||||
apiReport.setEnvironmentId("api-environment-id" + i);
|
apiReport.setEnvironmentId("api-environment-id" + i);
|
||||||
apiReport.setRunMode("api-run-mode" + i);
|
apiReport.setRunMode("api-run-mode" + i);
|
||||||
if (i % 2 == 0) {
|
if (i % 2 == 0) {
|
||||||
apiReport.setStatus(ReportStatus.SUCCESS.name());
|
apiReport.setStatus(ResultStatus.SUCCESS.name());
|
||||||
} else {
|
} else {
|
||||||
apiReport.setTestPlanScenarioId(testPlanApiScenario.getId());
|
apiReport.setTestPlanScenarioId(testPlanApiScenario.getId());
|
||||||
apiReport.setStatus(ReportStatus.ERROR.name());
|
apiReport.setStatus(ResultStatus.ERROR.name());
|
||||||
}
|
}
|
||||||
apiReport.setTriggerMode("api-trigger-mode" + i);
|
apiReport.setTriggerMode("api-trigger-mode" + i);
|
||||||
reports.add(apiReport);
|
reports.add(apiReport);
|
||||||
|
@ -2701,7 +2701,7 @@ public class ApiScenarioControllerTests extends BaseTest {
|
||||||
//返回值不为空
|
//返回值不为空
|
||||||
Assertions.assertNotNull(returnPager);
|
Assertions.assertNotNull(returnPager);
|
||||||
request.setFilter(new HashMap<>() {{
|
request.setFilter(new HashMap<>() {{
|
||||||
put("status", List.of(ReportStatus.SUCCESS.name()));
|
put("status", List.of(ResultStatus.SUCCESS.name()));
|
||||||
}});
|
}});
|
||||||
request.setSort(new HashMap<>() {{
|
request.setSort(new HashMap<>() {{
|
||||||
put("startTime", "desc");
|
put("startTime", "desc");
|
||||||
|
@ -2713,7 +2713,7 @@ public class ApiScenarioControllerTests extends BaseTest {
|
||||||
Assertions.assertTrue(((List<ApiReport>) returnPager.getList()).size() <= request.getPageSize());
|
Assertions.assertTrue(((List<ApiReport>) returnPager.getList()).size() <= request.getPageSize());
|
||||||
List<ExecuteReportDTO> reportDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ExecuteReportDTO.class);
|
List<ExecuteReportDTO> reportDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ExecuteReportDTO.class);
|
||||||
reportDTOS.forEach(apiReport -> {
|
reportDTOS.forEach(apiReport -> {
|
||||||
Assertions.assertEquals(apiReport.getStatus(), ReportStatus.SUCCESS.name());
|
Assertions.assertEquals(apiReport.getStatus(), ResultStatus.SUCCESS.name());
|
||||||
});
|
});
|
||||||
request.setId("data-is-null");
|
request.setId("data-is-null");
|
||||||
responsePost(BASE_PATH + "execute/page", request);
|
responsePost(BASE_PATH + "execute/page", request);
|
||||||
|
|
|
@ -19,7 +19,7 @@ import io.metersphere.project.domain.ProjectApplication;
|
||||||
import io.metersphere.project.domain.ProjectApplicationExample;
|
import io.metersphere.project.domain.ProjectApplicationExample;
|
||||||
import io.metersphere.project.mapper.ProjectApplicationMapper;
|
import io.metersphere.project.mapper.ProjectApplicationMapper;
|
||||||
import io.metersphere.sdk.constants.PermissionConstants;
|
import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
import io.metersphere.sdk.constants.ReportStatus;
|
import io.metersphere.sdk.constants.ResultStatus;
|
||||||
import io.metersphere.sdk.constants.SessionConstants;
|
import io.metersphere.sdk.constants.SessionConstants;
|
||||||
import io.metersphere.sdk.constants.ShareInfoType;
|
import io.metersphere.sdk.constants.ShareInfoType;
|
||||||
import io.metersphere.sdk.domain.Environment;
|
import io.metersphere.sdk.domain.Environment;
|
||||||
|
@ -102,9 +102,9 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
||||||
scenarioReport.setCreateUser("admin");
|
scenarioReport.setCreateUser("admin");
|
||||||
scenarioReport.setUpdateUser("admin");
|
scenarioReport.setUpdateUser("admin");
|
||||||
if (i % 50 == 0) {
|
if (i % 50 == 0) {
|
||||||
scenarioReport.setStatus(ReportStatus.SUCCESS.name());
|
scenarioReport.setStatus(ResultStatus.SUCCESS.name());
|
||||||
} else if (i % 39 == 0) {
|
} else if (i % 39 == 0) {
|
||||||
scenarioReport.setStatus(ReportStatus.ERROR.name());
|
scenarioReport.setStatus(ResultStatus.ERROR.name());
|
||||||
}
|
}
|
||||||
scenarioReport.setUpdateTime(System.currentTimeMillis());
|
scenarioReport.setUpdateTime(System.currentTimeMillis());
|
||||||
scenarioReport.setPoolId("api-pool-id" + i);
|
scenarioReport.setPoolId("api-pool-id" + i);
|
||||||
|
@ -171,7 +171,7 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
||||||
Assertions.assertTrue(((List<ApiScenarioDTO>) returnPager.getList()).size() <= request.getPageSize());
|
Assertions.assertTrue(((List<ApiScenarioDTO>) returnPager.getList()).size() <= request.getPageSize());
|
||||||
//过滤
|
//过滤
|
||||||
request.setFilter(new HashMap<>() {{
|
request.setFilter(new HashMap<>() {{
|
||||||
put("status", List.of(ReportStatus.SUCCESS.name(), ReportStatus.ERROR.name()));
|
put("status", List.of(ResultStatus.SUCCESS.name(), ResultStatus.ERROR.name()));
|
||||||
}});
|
}});
|
||||||
mvcResult = responsePost(PAGE, request);
|
mvcResult = responsePost(PAGE, request);
|
||||||
returnPager = parseObjectFromMvcResult(mvcResult, Pager.class);
|
returnPager = parseObjectFromMvcResult(mvcResult, Pager.class);
|
||||||
|
@ -180,7 +180,7 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
||||||
Assertions.assertTrue(((List<ApiReport>) returnPager.getList()).size() <= request.getPageSize());
|
Assertions.assertTrue(((List<ApiReport>) returnPager.getList()).size() <= request.getPageSize());
|
||||||
List<ApiReport> list = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ApiReport.class);
|
List<ApiReport> list = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ApiReport.class);
|
||||||
list.forEach(apiReport -> {
|
list.forEach(apiReport -> {
|
||||||
Assertions.assertTrue(apiReport.getStatus().equals(ReportStatus.SUCCESS.name()) || apiReport.getStatus().equals(ReportStatus.ERROR.name()));
|
Assertions.assertTrue(apiReport.getStatus().equals(ResultStatus.SUCCESS.name()) || apiReport.getStatus().equals(ResultStatus.ERROR.name()));
|
||||||
});
|
});
|
||||||
|
|
||||||
//校验权限
|
//校验权限
|
||||||
|
@ -302,7 +302,7 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
||||||
apiReportDetail.setStepId("test-scenario-report-step-id" + i);
|
apiReportDetail.setStepId("test-scenario-report-step-id" + i);
|
||||||
apiReportDetail.setSort((long) i);
|
apiReportDetail.setSort((long) i);
|
||||||
if (i % 2 == 0) {
|
if (i % 2 == 0) {
|
||||||
apiReportDetail.setStatus(ReportStatus.SUCCESS.name());
|
apiReportDetail.setStatus(ResultStatus.SUCCESS.name());
|
||||||
apiReportDetail.setResponseSize(1L);
|
apiReportDetail.setResponseSize(1L);
|
||||||
apiReportDetail.setRequestTime(2L);
|
apiReportDetail.setRequestTime(2L);
|
||||||
} else if (i % 3 == 0) {
|
} else if (i % 3 == 0) {
|
||||||
|
@ -310,7 +310,7 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
||||||
apiReportDetail.setResponseSize(0L);
|
apiReportDetail.setResponseSize(0L);
|
||||||
apiReportDetail.setRequestTime(2L);
|
apiReportDetail.setRequestTime(2L);
|
||||||
} else {
|
} else {
|
||||||
apiReportDetail.setStatus(ReportStatus.FAKE_ERROR.name());
|
apiReportDetail.setStatus(ResultStatus.FAKE_ERROR.name());
|
||||||
apiReportDetail.setResponseSize(1L);
|
apiReportDetail.setResponseSize(1L);
|
||||||
apiReportDetail.setRequestTime(2L);
|
apiReportDetail.setRequestTime(2L);
|
||||||
}
|
}
|
||||||
|
|
|
@ -788,7 +788,7 @@ public class ApiTestCaseControllerTests extends BaseTest {
|
||||||
testPlanApiCase.setCreateTime(System.currentTimeMillis());
|
testPlanApiCase.setCreateTime(System.currentTimeMillis());
|
||||||
testPlanApiCase.setLastExecTime(System.currentTimeMillis());
|
testPlanApiCase.setLastExecTime(System.currentTimeMillis());
|
||||||
testPlanApiCase.setLastExecReportId(IDGenerator.nextStr());
|
testPlanApiCase.setLastExecReportId(IDGenerator.nextStr());
|
||||||
testPlanApiCase.setLastExecResult(ExecStatus.SUCCESS.name());
|
testPlanApiCase.setLastExecResult(ResultStatus.SUCCESS.name());
|
||||||
testPlanApiCase.setPos(1024l);
|
testPlanApiCase.setPos(1024l);
|
||||||
testPlanApiCase.setTestPlanCollectionId(planId);
|
testPlanApiCase.setTestPlanCollectionId(planId);
|
||||||
testPlanApiCaseMapper.insert(testPlanApiCase);
|
testPlanApiCaseMapper.insert(testPlanApiCase);
|
||||||
|
@ -806,10 +806,10 @@ public class ApiTestCaseControllerTests extends BaseTest {
|
||||||
apiReport.setEnvironmentId("api-environment-id" + i);
|
apiReport.setEnvironmentId("api-environment-id" + i);
|
||||||
apiReport.setRunMode("api-run-mode" + i);
|
apiReport.setRunMode("api-run-mode" + i);
|
||||||
if (i % 2 == 0) {
|
if (i % 2 == 0) {
|
||||||
apiReport.setStatus(ExecStatus.SUCCESS.name());
|
apiReport.setStatus(ResultStatus.SUCCESS.name());
|
||||||
} else {
|
} else {
|
||||||
apiReport.setTestPlanCaseId(testPlanApiCase.getId());
|
apiReport.setTestPlanCaseId(testPlanApiCase.getId());
|
||||||
apiReport.setStatus(ExecStatus.ERROR.name());
|
apiReport.setStatus(ResultStatus.ERROR.name());
|
||||||
}
|
}
|
||||||
apiReport.setTriggerMode("api-trigger-mode" + i);
|
apiReport.setTriggerMode("api-trigger-mode" + i);
|
||||||
reports.add(apiReport);
|
reports.add(apiReport);
|
||||||
|
@ -828,7 +828,7 @@ public class ApiTestCaseControllerTests extends BaseTest {
|
||||||
//返回值不为空
|
//返回值不为空
|
||||||
Assertions.assertNotNull(returnPager);
|
Assertions.assertNotNull(returnPager);
|
||||||
request.setFilter(new HashMap<>() {{
|
request.setFilter(new HashMap<>() {{
|
||||||
put("status", List.of(ReportStatus.SUCCESS.name()));
|
put("status", List.of(ResultStatus.SUCCESS.name()));
|
||||||
}});
|
}});
|
||||||
mvcResult = requestPostWithOkAndReturn(EXECUTE, request);
|
mvcResult = requestPostWithOkAndReturn(EXECUTE, request);
|
||||||
returnPager = parseObjectFromMvcResult(mvcResult, Pager.class);
|
returnPager = parseObjectFromMvcResult(mvcResult, Pager.class);
|
||||||
|
@ -837,7 +837,7 @@ public class ApiTestCaseControllerTests extends BaseTest {
|
||||||
Assertions.assertTrue(((List<ApiReport>) returnPager.getList()).size() <= request.getPageSize());
|
Assertions.assertTrue(((List<ApiReport>) returnPager.getList()).size() <= request.getPageSize());
|
||||||
List<ExecuteReportDTO> reportDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ExecuteReportDTO.class);
|
List<ExecuteReportDTO> reportDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ExecuteReportDTO.class);
|
||||||
reportDTOS.forEach(apiReport -> {
|
reportDTOS.forEach(apiReport -> {
|
||||||
Assertions.assertEquals(apiReport.getStatus(), ReportStatus.SUCCESS.name());
|
Assertions.assertEquals(apiReport.getStatus(), ResultStatus.SUCCESS.name());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import io.metersphere.api.service.scenario.ApiScenarioReportService;
|
||||||
import io.metersphere.api.service.schedule.SwaggerUrlImportJob;
|
import io.metersphere.api.service.schedule.SwaggerUrlImportJob;
|
||||||
import io.metersphere.sdk.constants.ApiExecuteResourceType;
|
import io.metersphere.sdk.constants.ApiExecuteResourceType;
|
||||||
import io.metersphere.sdk.constants.ProjectApplicationType;
|
import io.metersphere.sdk.constants.ProjectApplicationType;
|
||||||
import io.metersphere.sdk.constants.ReportStatus;
|
import io.metersphere.sdk.constants.ResultStatus;
|
||||||
import io.metersphere.sdk.constants.ScheduleType;
|
import io.metersphere.sdk.constants.ScheduleType;
|
||||||
import io.metersphere.system.domain.Schedule;
|
import io.metersphere.system.domain.Schedule;
|
||||||
import io.metersphere.system.invoker.ProjectServiceInvoker;
|
import io.metersphere.system.invoker.ProjectServiceInvoker;
|
||||||
|
@ -250,9 +250,9 @@ public class CleanupApiTests {
|
||||||
apiReport.setEnvironmentId("api-environment-id" + i);
|
apiReport.setEnvironmentId("api-environment-id" + i);
|
||||||
apiReport.setRunMode("api-run-mode" + i);
|
apiReport.setRunMode("api-run-mode" + i);
|
||||||
if (i % 50 == 0) {
|
if (i % 50 == 0) {
|
||||||
apiReport.setStatus(ReportStatus.SUCCESS.name());
|
apiReport.setStatus(ResultStatus.SUCCESS.name());
|
||||||
} else if (i % 39 == 0) {
|
} else if (i % 39 == 0) {
|
||||||
apiReport.setStatus(ReportStatus.ERROR.name());
|
apiReport.setStatus(ResultStatus.ERROR.name());
|
||||||
}
|
}
|
||||||
apiReport.setTriggerMode("api-trigger-mode" + i);
|
apiReport.setTriggerMode("api-trigger-mode" + i);
|
||||||
reports.add(apiReport);
|
reports.add(apiReport);
|
||||||
|
@ -284,9 +284,9 @@ public class CleanupApiTests {
|
||||||
scenarioReport.setCreateUser("admin");
|
scenarioReport.setCreateUser("admin");
|
||||||
scenarioReport.setUpdateUser("admin");
|
scenarioReport.setUpdateUser("admin");
|
||||||
if (i % 50 == 0) {
|
if (i % 50 == 0) {
|
||||||
scenarioReport.setStatus(ReportStatus.SUCCESS.name());
|
scenarioReport.setStatus(ResultStatus.SUCCESS.name());
|
||||||
} else if (i % 39 == 0) {
|
} else if (i % 39 == 0) {
|
||||||
scenarioReport.setStatus(ReportStatus.ERROR.name());
|
scenarioReport.setStatus(ResultStatus.ERROR.name());
|
||||||
}
|
}
|
||||||
scenarioReport.setUpdateTime(System.currentTimeMillis());
|
scenarioReport.setUpdateTime(System.currentTimeMillis());
|
||||||
scenarioReport.setPoolId("api-pool-id" + i);
|
scenarioReport.setPoolId("api-pool-id" + i);
|
||||||
|
|
|
@ -7,6 +7,7 @@ import io.metersphere.plan.mapper.TestPlanReportApiScenarioMapper;
|
||||||
import io.metersphere.plan.mapper.TestPlanReportMapper;
|
import io.metersphere.plan.mapper.TestPlanReportMapper;
|
||||||
import io.metersphere.sdk.constants.ApiBatchRunMode;
|
import io.metersphere.sdk.constants.ApiBatchRunMode;
|
||||||
import io.metersphere.sdk.constants.ExecStatus;
|
import io.metersphere.sdk.constants.ExecStatus;
|
||||||
|
import io.metersphere.sdk.constants.ResultStatus;
|
||||||
import io.metersphere.sdk.dto.queue.TestPlanExecutionQueue;
|
import io.metersphere.sdk.dto.queue.TestPlanExecutionQueue;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.sdk.util.LogUtils;
|
import io.metersphere.sdk.util.LogUtils;
|
||||||
|
@ -26,8 +27,6 @@ import java.util.concurrent.TimeUnit;
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class TestPlanExecuteSupportService {
|
public class TestPlanExecuteSupportService {
|
||||||
|
|
||||||
@Resource
|
|
||||||
private TestPlanService testPlanService;
|
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanReportService testPlanReportService;
|
private TestPlanReportService testPlanReportService;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -83,7 +82,7 @@ public class TestPlanExecuteSupportService {
|
||||||
LogUtils.error("测试计划报告汇总失败!reportId:" + reportId, e);
|
LogUtils.error("测试计划报告汇总失败!reportId:" + reportId, e);
|
||||||
TestPlanReport stopReport = testPlanReportService.selectById(reportId);
|
TestPlanReport stopReport = testPlanReportService.selectById(reportId);
|
||||||
stopReport.setId(reportId);
|
stopReport.setId(reportId);
|
||||||
stopReport.setExecStatus(ExecStatus.ERROR.name());
|
stopReport.setExecStatus(ResultStatus.ERROR.name());
|
||||||
stopReport.setEndTime(System.currentTimeMillis());
|
stopReport.setEndTime(System.currentTimeMillis());
|
||||||
testPlanReportMapper.updateByPrimaryKeySelective(stopReport);
|
testPlanReportMapper.updateByPrimaryKeySelective(stopReport);
|
||||||
}
|
}
|
||||||
|
|
|
@ -645,12 +645,12 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
|
||||||
testPlanSendNoticeService.sendNoticeCase(relatedUsers, userId, caseId, NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, NoticeConstants.Event.EXECUTE_AT, testPlanId);
|
testPlanSendNoticeService.sendNoticeCase(relatedUsers, userId, caseId, NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, NoticeConstants.Event.EXECUTE_AT, testPlanId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.equalsIgnoreCase(lastExecResult, ExecStatus.SUCCESS.name())) {
|
if (StringUtils.equalsIgnoreCase(lastExecResult, ResultStatus.SUCCESS.name())) {
|
||||||
//成功 发送通知
|
//成功 发送通知
|
||||||
testPlanSendNoticeService.sendNoticeCase(new ArrayList<>(), userId, caseId, NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, NoticeConstants.Event.EXECUTE_PASSED, testPlanId);
|
testPlanSendNoticeService.sendNoticeCase(new ArrayList<>(), userId, caseId, NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, NoticeConstants.Event.EXECUTE_PASSED, testPlanId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.equalsIgnoreCase(lastExecResult, ExecStatus.ERROR.name())) {
|
if (StringUtils.equalsIgnoreCase(lastExecResult, ResultStatus.ERROR.name())) {
|
||||||
//失败 发送通知
|
//失败 发送通知
|
||||||
testPlanSendNoticeService.sendNoticeCase(new ArrayList<>(), userId, caseId, NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, NoticeConstants.Event.EXECUTE_FAIL, testPlanId);
|
testPlanSendNoticeService.sendNoticeCase(new ArrayList<>(), userId, caseId, NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, NoticeConstants.Event.EXECUTE_FAIL, testPlanId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -479,11 +479,11 @@ public class TestPlanReportService {
|
||||||
if (planReport.getIntegrated()) {
|
if (planReport.getIntegrated()) {
|
||||||
// 计划组的(执行)结果状态: 子计划全部成功 ? 成功 : 失败
|
// 计划组的(执行)结果状态: 子计划全部成功 ? 成功 : 失败
|
||||||
TestPlanReportExample reportExample = new TestPlanReportExample();
|
TestPlanReportExample reportExample = new TestPlanReportExample();
|
||||||
reportExample.createCriteria().andParentIdEqualTo(postParam.getReportId()).andIntegratedEqualTo(false).andResultStatusNotEqualTo(ReportStatus.SUCCESS.name());
|
reportExample.createCriteria().andParentIdEqualTo(postParam.getReportId()).andIntegratedEqualTo(false).andResultStatusNotEqualTo(ResultStatus.SUCCESS.name());
|
||||||
planReport.setResultStatus(testPlanReportMapper.countByExample(reportExample) == 0 ? ReportStatus.SUCCESS.name() : ReportStatus.ERROR.name());
|
planReport.setResultStatus(testPlanReportMapper.countByExample(reportExample) == 0 ? ResultStatus.SUCCESS.name() : ResultStatus.ERROR.name());
|
||||||
} else {
|
} else {
|
||||||
// 计划的(执行)结果状态: 通过率 >= 阈值 ? 成功 : 失败
|
// 计划的(执行)结果状态: 通过率 >= 阈值 ? 成功 : 失败
|
||||||
planReport.setResultStatus(planReport.getPassRate() >= planReport.getPassThreshold() ? ReportStatus.SUCCESS.name() : ReportStatus.ERROR.name());
|
planReport.setResultStatus(planReport.getPassRate() >= planReport.getPassThreshold() ? ResultStatus.SUCCESS.name() : ResultStatus.ERROR.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
testPlanReportMapper.updateByPrimaryKeySelective(planReport);
|
testPlanReportMapper.updateByPrimaryKeySelective(planReport);
|
||||||
|
@ -532,7 +532,7 @@ public class TestPlanReportService {
|
||||||
TestPlanReportExample reportExample = new TestPlanReportExample();
|
TestPlanReportExample reportExample = new TestPlanReportExample();
|
||||||
reportExample.createCriteria().andParentIdEqualTo(reportId).andIntegratedEqualTo(false);
|
reportExample.createCriteria().andParentIdEqualTo(reportId).andIntegratedEqualTo(false);
|
||||||
List<TestPlanReport> testPlanReports = testPlanReportMapper.selectByExample(reportExample);
|
List<TestPlanReport> testPlanReports = testPlanReportMapper.selectByExample(reportExample);
|
||||||
long planPassCount = testPlanReports.stream().filter(report -> StringUtils.equals(ExecStatus.SUCCESS.name(), report.getResultStatus())).count();
|
long planPassCount = testPlanReports.stream().filter(report -> StringUtils.equals(ResultStatus.SUCCESS.name(), report.getResultStatus())).count();
|
||||||
planReportDetail.setPassCountOfPlan((int) planPassCount);
|
planReportDetail.setPassCountOfPlan((int) planPassCount);
|
||||||
planReportDetail.setFailCountOfPlan(planReportDetail.getPlanCount() - planReportDetail.getPassCountOfPlan());
|
planReportDetail.setFailCountOfPlan(planReportDetail.getPlanCount() - planReportDetail.getPassCountOfPlan());
|
||||||
}
|
}
|
||||||
|
@ -929,11 +929,11 @@ public class TestPlanReportService {
|
||||||
private CaseCount countMap(List<CaseStatusCountMap> resultMapList) {
|
private CaseCount countMap(List<CaseStatusCountMap> resultMapList) {
|
||||||
CaseCount caseCount = new CaseCount();
|
CaseCount caseCount = new CaseCount();
|
||||||
Map<String, Long> resultMap = resultMapList.stream().collect(Collectors.toMap(CaseStatusCountMap::getStatus, CaseStatusCountMap::getCount));
|
Map<String, Long> resultMap = resultMapList.stream().collect(Collectors.toMap(CaseStatusCountMap::getStatus, CaseStatusCountMap::getCount));
|
||||||
caseCount.setSuccess(resultMap.getOrDefault(ExecStatus.SUCCESS.name(), 0L).intValue());
|
caseCount.setSuccess(resultMap.getOrDefault(ResultStatus.SUCCESS.name(), 0L).intValue());
|
||||||
caseCount.setError(resultMap.getOrDefault(ExecStatus.ERROR.name(), 0L).intValue());
|
caseCount.setError(resultMap.getOrDefault(ResultStatus.ERROR.name(), 0L).intValue());
|
||||||
caseCount.setPending(resultMap.getOrDefault(ExecStatus.PENDING.name(), 0L).intValue() + resultMap.getOrDefault(ExecStatus.STOPPED.name(), 0L).intValue());
|
caseCount.setPending(resultMap.getOrDefault(ExecStatus.PENDING.name(), 0L).intValue() + resultMap.getOrDefault(ExecStatus.STOPPED.name(), 0L).intValue());
|
||||||
caseCount.setBlock(resultMap.getOrDefault(ExecStatus.BLOCKED.name(), 0L).intValue());
|
caseCount.setBlock(resultMap.getOrDefault(ResultStatus.BLOCKED.name(), 0L).intValue());
|
||||||
caseCount.setFakeError(resultMap.getOrDefault(ExecStatus.FAKE_ERROR.name(), 0L).intValue());
|
caseCount.setFakeError(resultMap.getOrDefault(ResultStatus.FAKE_ERROR.name(), 0L).intValue());
|
||||||
return caseCount;
|
return caseCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import io.metersphere.plan.dto.request.TestPlanUpdateRequest;
|
||||||
import io.metersphere.plan.mapper.TestPlanConfigMapper;
|
import io.metersphere.plan.mapper.TestPlanConfigMapper;
|
||||||
import io.metersphere.plan.mapper.TestPlanFollowerMapper;
|
import io.metersphere.plan.mapper.TestPlanFollowerMapper;
|
||||||
import io.metersphere.plan.mapper.TestPlanMapper;
|
import io.metersphere.plan.mapper.TestPlanMapper;
|
||||||
import io.metersphere.sdk.constants.ReportStatus;
|
import io.metersphere.sdk.constants.ResultStatus;
|
||||||
import io.metersphere.sdk.constants.TaskTriggerMode;
|
import io.metersphere.sdk.constants.TaskTriggerMode;
|
||||||
import io.metersphere.sdk.constants.TestPlanConstants;
|
import io.metersphere.sdk.constants.TestPlanConstants;
|
||||||
import io.metersphere.sdk.util.BeanUtils;
|
import io.metersphere.sdk.util.BeanUtils;
|
||||||
|
@ -185,10 +185,10 @@ public class TestPlanSendNoticeService {
|
||||||
User user = userMapper.selectByPrimaryKey(currentUser);
|
User user = userMapper.selectByPrimaryKey(currentUser);
|
||||||
setLanguage(user.getLanguage());
|
setLanguage(user.getLanguage());
|
||||||
Map<String, String> defaultTemplateMap = MessageTemplateUtils.getDefaultTemplateMap();
|
Map<String, String> defaultTemplateMap = MessageTemplateUtils.getDefaultTemplateMap();
|
||||||
String template = defaultTemplateMap.get(StringUtils.equals(executeResult, ReportStatus.SUCCESS.name()) ?
|
String template = defaultTemplateMap.get(StringUtils.equals(executeResult, ResultStatus.SUCCESS.name()) ?
|
||||||
NoticeConstants.TemplateText.TEST_PLAN_TASK_EXECUTE_SUCCESSFUL : NoticeConstants.TemplateText.TEST_PLAN_TASK_EXECUTE_FAILED);
|
NoticeConstants.TemplateText.TEST_PLAN_TASK_EXECUTE_SUCCESSFUL : NoticeConstants.TemplateText.TEST_PLAN_TASK_EXECUTE_FAILED);
|
||||||
Map<String, String> defaultSubjectMap = MessageTemplateUtils.getDefaultTemplateSubjectMap();
|
Map<String, String> defaultSubjectMap = MessageTemplateUtils.getDefaultTemplateSubjectMap();
|
||||||
String subject = defaultSubjectMap.get(StringUtils.equals(executeResult, ReportStatus.SUCCESS.name()) ?
|
String subject = defaultSubjectMap.get(StringUtils.equals(executeResult, ResultStatus.SUCCESS.name()) ?
|
||||||
NoticeConstants.TemplateText.TEST_PLAN_TASK_EXECUTE_SUCCESSFUL : NoticeConstants.TemplateText.TEST_PLAN_TASK_EXECUTE_FAILED);
|
NoticeConstants.TemplateText.TEST_PLAN_TASK_EXECUTE_SUCCESSFUL : NoticeConstants.TemplateText.TEST_PLAN_TASK_EXECUTE_FAILED);
|
||||||
Map<String, Object> paramMap = new HashMap<>(4);
|
Map<String, Object> paramMap = new HashMap<>(4);
|
||||||
paramMap.put(NoticeConstants.RelatedUser.OPERATOR, user.getName());
|
paramMap.put(NoticeConstants.RelatedUser.OPERATOR, user.getName());
|
||||||
|
@ -197,7 +197,7 @@ public class TestPlanSendNoticeService {
|
||||||
paramMap.put("id", planId);
|
paramMap.put("id", planId);
|
||||||
paramMap.put("Language", user.getLanguage());
|
paramMap.put("Language", user.getLanguage());
|
||||||
NoticeModel noticeModel = NoticeModel.builder().operator(currentUser).excludeSelf(false)
|
NoticeModel noticeModel = NoticeModel.builder().operator(currentUser).excludeSelf(false)
|
||||||
.context(template).subject(subject).paramMap(paramMap).event(StringUtils.equals(executeResult, ReportStatus.SUCCESS.name()) ?
|
.context(template).subject(subject).paramMap(paramMap).event(StringUtils.equals(executeResult, ResultStatus.SUCCESS.name()) ?
|
||||||
NoticeConstants.Event.EXECUTE_SUCCESSFUL : NoticeConstants.Event.EXECUTE_FAILED).build();
|
NoticeConstants.Event.EXECUTE_SUCCESSFUL : NoticeConstants.Event.EXECUTE_FAILED).build();
|
||||||
noticeSendService.send(StringUtils.equals(TaskTriggerMode.API.name(), triggerMode) ?
|
noticeSendService.send(StringUtils.equals(TaskTriggerMode.API.name(), triggerMode) ?
|
||||||
NoticeConstants.TaskType.JENKINS_TASK : NoticeConstants.TaskType.TEST_PLAN_TASK, noticeModel);
|
NoticeConstants.TaskType.JENKINS_TASK : NoticeConstants.TaskType.TEST_PLAN_TASK, noticeModel);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import io.metersphere.plan.dto.response.TestPlanStatisticsResponse;
|
||||||
import io.metersphere.plan.mapper.*;
|
import io.metersphere.plan.mapper.*;
|
||||||
import io.metersphere.plan.utils.RateCalculateUtils;
|
import io.metersphere.plan.utils.RateCalculateUtils;
|
||||||
import io.metersphere.sdk.constants.ExecStatus;
|
import io.metersphere.sdk.constants.ExecStatus;
|
||||||
|
import io.metersphere.sdk.constants.ResultStatus;
|
||||||
import io.metersphere.sdk.constants.ScheduleResourceType;
|
import io.metersphere.sdk.constants.ScheduleResourceType;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.system.domain.Schedule;
|
import io.metersphere.system.domain.Schedule;
|
||||||
|
@ -126,10 +127,10 @@ public class TestPlanStatisticsService {
|
||||||
Map<String, Long> apiScenarioResultCountMap = CollectionUtils.isEmpty(apiScenarios) ? new HashMap<>(16) : apiScenarios.stream().collect(
|
Map<String, Long> apiScenarioResultCountMap = CollectionUtils.isEmpty(apiScenarios) ? new HashMap<>(16) : apiScenarios.stream().collect(
|
||||||
Collectors.groupingBy(apiScenario -> Optional.ofNullable(apiScenario.getLastExecResult()).orElse(ExecStatus.PENDING.name()), Collectors.counting()));
|
Collectors.groupingBy(apiScenario -> Optional.ofNullable(apiScenario.getLastExecResult()).orElse(ExecStatus.PENDING.name()), Collectors.counting()));
|
||||||
// 用例数据汇总
|
// 用例数据汇总
|
||||||
statisticsResponse.setSuccessCount(countCaseMap(functionalCaseResultCountMap, apiCaseResultCountMap, apiScenarioResultCountMap, ExecStatus.SUCCESS.name()));
|
statisticsResponse.setSuccessCount(countCaseMap(functionalCaseResultCountMap, apiCaseResultCountMap, apiScenarioResultCountMap, ResultStatus.SUCCESS.name()));
|
||||||
statisticsResponse.setErrorCount(countCaseMap(functionalCaseResultCountMap, apiCaseResultCountMap, apiScenarioResultCountMap, ExecStatus.ERROR.name()));
|
statisticsResponse.setErrorCount(countCaseMap(functionalCaseResultCountMap, apiCaseResultCountMap, apiScenarioResultCountMap, ResultStatus.ERROR.name()));
|
||||||
statisticsResponse.setFakeErrorCount(countCaseMap(functionalCaseResultCountMap, apiCaseResultCountMap, apiScenarioResultCountMap, ExecStatus.FAKE_ERROR.name()));
|
statisticsResponse.setFakeErrorCount(countCaseMap(functionalCaseResultCountMap, apiCaseResultCountMap, apiScenarioResultCountMap, ResultStatus.FAKE_ERROR.name()));
|
||||||
statisticsResponse.setBlockCount(countCaseMap(functionalCaseResultCountMap, apiCaseResultCountMap, apiScenarioResultCountMap, ExecStatus.BLOCKED.name()));
|
statisticsResponse.setBlockCount(countCaseMap(functionalCaseResultCountMap, apiCaseResultCountMap, apiScenarioResultCountMap, ResultStatus.BLOCKED.name()));
|
||||||
statisticsResponse.setPendingCount(countCaseMap(functionalCaseResultCountMap, apiCaseResultCountMap, apiScenarioResultCountMap, ExecStatus.PENDING.name()));
|
statisticsResponse.setPendingCount(countCaseMap(functionalCaseResultCountMap, apiCaseResultCountMap, apiScenarioResultCountMap, ExecStatus.PENDING.name()));
|
||||||
statisticsResponse.setCaseTotal(statisticsResponse.getFunctionalCaseCount() + statisticsResponse.getApiCaseCount() + statisticsResponse.getApiScenarioCount());
|
statisticsResponse.setCaseTotal(statisticsResponse.getFunctionalCaseCount() + statisticsResponse.getApiCaseCount() + statisticsResponse.getApiScenarioCount());
|
||||||
// 通过率 {通过用例数/总用例数} && 执行进度 {非未执行的用例数/总用例数}
|
// 通过率 {通过用例数/总用例数} && 执行进度 {非未执行的用例数/总用例数}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import io.metersphere.project.mapper.ExtBaseProjectVersionMapper;
|
||||||
import io.metersphere.sdk.constants.ApiBatchRunMode;
|
import io.metersphere.sdk.constants.ApiBatchRunMode;
|
||||||
import io.metersphere.sdk.constants.ApiExecuteResourceType;
|
import io.metersphere.sdk.constants.ApiExecuteResourceType;
|
||||||
import io.metersphere.sdk.constants.PermissionConstants;
|
import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
import io.metersphere.sdk.constants.ReportStatus;
|
import io.metersphere.sdk.constants.ResultStatus;
|
||||||
import io.metersphere.sdk.dto.api.task.GetRunScriptRequest;
|
import io.metersphere.sdk.dto.api.task.GetRunScriptRequest;
|
||||||
import io.metersphere.sdk.dto.api.task.TaskItem;
|
import io.metersphere.sdk.dto.api.task.TaskItem;
|
||||||
import io.metersphere.sdk.util.CommonBeanFactory;
|
import io.metersphere.sdk.util.CommonBeanFactory;
|
||||||
|
@ -445,7 +445,7 @@ public class TestPlanApiCaseControllerTests extends BaseTest {
|
||||||
apiReport.setEnvironmentId("test-env");
|
apiReport.setEnvironmentId("test-env");
|
||||||
apiReport.setRunMode("api-run-mode");
|
apiReport.setRunMode("api-run-mode");
|
||||||
apiReport.setTestPlanCaseId("test-plan-case-id");
|
apiReport.setTestPlanCaseId("test-plan-case-id");
|
||||||
apiReport.setStatus(ReportStatus.SUCCESS.name());
|
apiReport.setStatus(ResultStatus.SUCCESS.name());
|
||||||
apiReport.setTriggerMode("api-trigger-mode");
|
apiReport.setTriggerMode("api-trigger-mode");
|
||||||
apiReport.setIntegrated(true);
|
apiReport.setIntegrated(true);
|
||||||
reports.add(apiReport);
|
reports.add(apiReport);
|
||||||
|
|
|
@ -32,7 +32,7 @@ import io.metersphere.project.mapper.ExtBaseProjectVersionMapper;
|
||||||
import io.metersphere.sdk.constants.ApiBatchRunMode;
|
import io.metersphere.sdk.constants.ApiBatchRunMode;
|
||||||
import io.metersphere.sdk.constants.MsAssertionCondition;
|
import io.metersphere.sdk.constants.MsAssertionCondition;
|
||||||
import io.metersphere.sdk.constants.PermissionConstants;
|
import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
import io.metersphere.sdk.constants.ReportStatus;
|
import io.metersphere.sdk.constants.ResultStatus;
|
||||||
import io.metersphere.sdk.dto.api.task.GetRunScriptRequest;
|
import io.metersphere.sdk.dto.api.task.GetRunScriptRequest;
|
||||||
import io.metersphere.sdk.dto.api.task.TaskItem;
|
import io.metersphere.sdk.dto.api.task.TaskItem;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
|
@ -493,7 +493,7 @@ public class TestPlanApiScenarioControllerTests extends BaseTest {
|
||||||
apiReportDetail.setStepId("plan-test-scenario-report-step-id" + i);
|
apiReportDetail.setStepId("plan-test-scenario-report-step-id" + i);
|
||||||
apiReportDetail.setSort((long) i);
|
apiReportDetail.setSort((long) i);
|
||||||
if (i % 2 == 0) {
|
if (i % 2 == 0) {
|
||||||
apiReportDetail.setStatus(ReportStatus.SUCCESS.name());
|
apiReportDetail.setStatus(ResultStatus.SUCCESS.name());
|
||||||
apiReportDetail.setResponseSize(1L);
|
apiReportDetail.setResponseSize(1L);
|
||||||
apiReportDetail.setRequestTime(2L);
|
apiReportDetail.setRequestTime(2L);
|
||||||
} else if (i % 3 == 0) {
|
} else if (i % 3 == 0) {
|
||||||
|
@ -501,7 +501,7 @@ public class TestPlanApiScenarioControllerTests extends BaseTest {
|
||||||
apiReportDetail.setResponseSize(0L);
|
apiReportDetail.setResponseSize(0L);
|
||||||
apiReportDetail.setRequestTime(2L);
|
apiReportDetail.setRequestTime(2L);
|
||||||
} else {
|
} else {
|
||||||
apiReportDetail.setStatus(ReportStatus.FAKE_ERROR.name());
|
apiReportDetail.setStatus(ResultStatus.FAKE_ERROR.name());
|
||||||
apiReportDetail.setResponseSize(1L);
|
apiReportDetail.setResponseSize(1L);
|
||||||
apiReportDetail.setRequestTime(2L);
|
apiReportDetail.setRequestTime(2L);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue