This commit is contained in:
chenjianxing 2020-06-28 20:43:58 +08:00
commit 1f39b8fe4a
9 changed files with 30 additions and 39 deletions

View File

@ -1,6 +1,6 @@
package io.metersphere.commons.constants; package io.metersphere.commons.constants;
public enum ReportKeys { public enum ReportKeys {
LoadChart, ResponseTimeChart, Errors, ErrorsTop5, RequestStatistics, Overview, TimeInfo LoadChart, ResponseTimeChart, Errors, ErrorsTop5, RequestStatistics, Overview, TimeInfo, ResultStatus
} }

View File

@ -5,10 +5,7 @@ import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtLoadTestMapper; import io.metersphere.base.mapper.ext.ExtLoadTestMapper;
import io.metersphere.base.mapper.ext.ExtLoadTestReportDetailMapper; import io.metersphere.base.mapper.ext.ExtLoadTestReportDetailMapper;
import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper; import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper;
import io.metersphere.commons.constants.APITestStatus; import io.metersphere.commons.constants.*;
import io.metersphere.commons.constants.PerformanceTestStatus;
import io.metersphere.commons.constants.ScheduleGroup;
import io.metersphere.commons.constants.ScheduleType;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.ServiceUtils; import io.metersphere.commons.utils.ServiceUtils;
@ -281,6 +278,13 @@ public class PerformanceTestService {
loadTestReportDetailMapper.insertSelective(reportDetail); loadTestReportDetailMapper.insertSelective(reportDetail);
// append \n // append \n
extLoadTestReportDetailMapper.appendLine(testReport.getId(), "\n"); extLoadTestReportDetailMapper.appendLine(testReport.getId(), "\n");
// 保存一个 reportStatus
LoadTestReportResult reportResult = new LoadTestReportResult();
reportResult.setId(UUID.randomUUID().toString());
reportResult.setReportId(testReport.getId());
reportResult.setReportKey(ReportKeys.ResultStatus.name());
reportResult.setReportValue("Ready"); // 初始化一个 result_status, 这个值用在data-streaming中
loadTestReportResultMapper.insertSelective(reportResult);
} catch (MSException e) { } catch (MSException e) {
LogUtil.error(e); LogUtil.error(e);
loadTest.setStatus(PerformanceTestStatus.Error.name()); loadTest.setStatus(PerformanceTestStatus.Error.name());

View File

@ -25,11 +25,10 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.annotation.Resource;
@Service @Service
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class ReportService { public class ReportService {
@ -154,11 +153,7 @@ public class ReportService {
public void checkReportStatus(String reportId) { public void checkReportStatus(String reportId) {
LoadTestReport loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId); LoadTestReport loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId);
String reportStatus = loadTestReport.getStatus(); String reportStatus = loadTestReport.getStatus();
if (StringUtils.equals(PerformanceTestStatus.Running.name(), reportStatus)) { if (StringUtils.equals(PerformanceTestStatus.Error.name(), reportStatus)) {
MSException.throwException("Reporting in progress...");
} else if (StringUtils.equals(PerformanceTestStatus.Reporting.name(), reportStatus)) {
MSException.throwException("Reporting in progress...");
} else if (StringUtils.equals(PerformanceTestStatus.Error.name(), reportStatus)) {
MSException.throwException("Report generation error!"); MSException.throwException("Report generation error!");
} }
} }

View File

@ -136,11 +136,7 @@
this.$warning(this.$t('report.start_status')); this.$warning(this.$t('report.start_status'));
break; break;
case 'Reporting': case 'Reporting':
this.$info(this.$t('report.being_generated'));
break;
case 'Running': case 'Running':
this.$warning(this.$t('report.run_status'));
break;
case 'Completed': case 'Completed':
default: default:
break; break;
@ -165,7 +161,7 @@
this.$set(this.report, "id", this.reportId); this.$set(this.report, "id", this.reportId);
this.$set(this.report, "status", data.status); this.$set(this.report, "status", data.status);
this.checkReportStatus(data.status); this.checkReportStatus(data.status);
if (this.status === "Completed") { if (this.status === "Completed" || this.status === "Running") {
this.initReportTimeInfo(); this.initReportTimeInfo();
} }
}) })

View File

@ -155,7 +155,7 @@
handler(val) { handler(val) {
let status = val.status; let status = val.status;
this.id = val.id; this.id = val.id;
if (status === "Completed") { if (status === "Completed" || status === "Running") {
this.initTableData(); this.initTableData();
} else { } else {
this.tableData = []; this.tableData = [];

View File

@ -81,7 +81,7 @@
handler(val) { handler(val) {
let status = val.status; let status = val.status;
this.id = val.id; this.id = val.id;
if (status === "Completed") { if (status === "Completed" || status === "Running") {
this.getResource(); this.getResource();
} else { } else {
this.resource = []; this.resource = [];

View File

@ -161,7 +161,7 @@
handler(val){ handler(val){
let status = val.status; let status = val.status;
this.id = val.id; this.id = val.id;
if (status === "Completed") { if (status === "Completed" || status === "Running") {
this.initTableData(); this.initTableData();
} else { } else {
this.tableData = []; this.tableData = [];

View File

@ -327,7 +327,7 @@
handler(val) { handler(val) {
let status = val.status; let status = val.status;
this.id = val.id; this.id = val.id;
if (status === "Completed") { if (status === "Completed" || status === "Running") {
this.initTableData(); this.initTableData();
} else { } else {
this.maxUsers = '0'; this.maxUsers = '0';

View File

@ -151,11 +151,7 @@
this.$warning(this.$t('report.start_status')); this.$warning(this.$t('report.start_status'));
break; break;
case 'Reporting': case 'Reporting':
this.$info(this.$t('report.being_generated'));
break;
case 'Running': case 'Running':
this.$warning(this.$t('report.run_status'));
break;
case 'Completed': case 'Completed':
default: default:
break; break;