Merge branch 'master' of https://github.com/metersphere/metersphere
This commit is contained in:
commit
c482bdc985
|
@ -418,6 +418,19 @@ public class PerformanceTestService {
|
||||||
if (forceStop) {
|
if (forceStop) {
|
||||||
reportService.deleteReport(reportId);
|
reportService.deleteReport(reportId);
|
||||||
} else {
|
} else {
|
||||||
|
stopEngine(reportId);
|
||||||
|
// 停止测试之后设置报告的状态
|
||||||
|
reportService.updateStatus(reportId, PerformanceTestStatus.Completed.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopErrorTest(String reportId) {
|
||||||
|
stopEngine(reportId);
|
||||||
|
// 停止测试之后设置报告的状态
|
||||||
|
reportService.updateStatus(reportId, PerformanceTestStatus.Error.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopEngine(String reportId) {
|
||||||
LoadTestReport loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId);
|
LoadTestReport loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId);
|
||||||
LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(loadTestReport.getTestId());
|
LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(loadTestReport.getTestId());
|
||||||
final Engine engine = EngineFactory.createEngine(loadTest);
|
final Engine engine = EngineFactory.createEngine(loadTest);
|
||||||
|
@ -425,9 +438,6 @@ public class PerformanceTestService {
|
||||||
MSException.throwException(String.format("Stop report fail. create engine fail,report ID:%s", reportId));
|
MSException.throwException(String.format("Stop report fail. create engine fail,report ID:%s", reportId));
|
||||||
}
|
}
|
||||||
reportService.stopEngine(loadTest, engine);
|
reportService.stopEngine(loadTest, engine);
|
||||||
// 停止测试之后设置报告的状态
|
|
||||||
reportService.updateStatus(reportId, PerformanceTestStatus.Completed.name());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ScheduleDao> listSchedule(QueryScheduleRequest request) {
|
public List<ScheduleDao> listSchedule(QueryScheduleRequest request) {
|
||||||
|
|
|
@ -241,7 +241,7 @@ public class ReportService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoadTestReport getReport(String reportId) {
|
public LoadTestReportWithBLOBs getReport(String reportId) {
|
||||||
return loadTestReportMapper.selectByPrimaryKey(reportId);
|
return loadTestReportMapper.selectByPrimaryKey(reportId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package io.metersphere.websocket;
|
package io.metersphere.websocket;
|
||||||
|
|
||||||
import io.metersphere.base.domain.LoadTestReport;
|
import io.metersphere.base.domain.LoadTestReportWithBLOBs;
|
||||||
import io.metersphere.commons.constants.PerformanceTestStatus;
|
import io.metersphere.commons.constants.PerformanceTestStatus;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
|
import io.metersphere.performance.service.PerformanceTestService;
|
||||||
import io.metersphere.performance.service.ReportService;
|
import io.metersphere.performance.service.ReportService;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -18,12 +19,18 @@ import java.io.IOException;
|
||||||
public class ReportWebSocket {
|
public class ReportWebSocket {
|
||||||
|
|
||||||
private static ReportService reportService;
|
private static ReportService reportService;
|
||||||
|
private static PerformanceTestService performanceTestService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
public void setReportService(ReportService reportService) {
|
public void setReportService(ReportService reportService) {
|
||||||
ReportWebSocket.reportService = reportService;
|
ReportWebSocket.reportService = reportService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
public void setPerformanceTestService(PerformanceTestService performanceTestService) {
|
||||||
|
ReportWebSocket.performanceTestService = performanceTestService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开启连接的操作
|
* 开启连接的操作
|
||||||
*/
|
*/
|
||||||
|
@ -78,12 +85,19 @@ public class ReportWebSocket {
|
||||||
public void run() {
|
public void run() {
|
||||||
while (stopMe) {
|
while (stopMe) {
|
||||||
try {
|
try {
|
||||||
LoadTestReport report = reportService.getReport(reportId);
|
LoadTestReportWithBLOBs report = reportService.getReport(reportId);
|
||||||
if (report == null || StringUtils.equalsAny(report.getStatus(), PerformanceTestStatus.Completed.name(), PerformanceTestStatus.Error.name())) {
|
if (report == null || StringUtils.equalsAny(report.getStatus(), PerformanceTestStatus.Completed.name())) {
|
||||||
this.stopMe();
|
this.stopMe();
|
||||||
session.close();
|
session.close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (StringUtils.equals(report.getStatus(), PerformanceTestStatus.Error.name())) {
|
||||||
|
this.stopMe();
|
||||||
|
session.getBasicRemote().sendText("Error: " + report.getDescription());
|
||||||
|
performanceTestService.stopErrorTest(reportId);
|
||||||
|
session.close();
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (!session.isOpen()) {
|
if (!session.isOpen()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,8 @@
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ms-performance-report-export :title="reportName" id="performanceReportExport" v-show="reportExportVisible" :report="report"/>
|
<ms-performance-report-export :title="reportName" id="performanceReportExport" v-show="reportExportVisible"
|
||||||
|
:report="report"/>
|
||||||
|
|
||||||
</el-card>
|
</el-card>
|
||||||
<el-dialog :title="$t('report.test_stop_now_confirm')" :visible.sync="dialogFormVisible" width="30%">
|
<el-dialog :title="$t('report.test_stop_now_confirm')" :visible.sync="dialogFormVisible" width="30%">
|
||||||
|
@ -91,8 +92,7 @@ import MsPerformancePressureConfig from "./components/PerformancePressureConfig"
|
||||||
import MsContainer from "../../common/components/MsContainer";
|
import MsContainer from "../../common/components/MsContainer";
|
||||||
import MsMainContainer from "../../common/components/MsMainContainer";
|
import MsMainContainer from "../../common/components/MsMainContainer";
|
||||||
|
|
||||||
import {checkoutTestManagerOrTestUser} from "@/common/js/utils";
|
import {checkoutTestManagerOrTestUser, exportPdf} from "@/common/js/utils";
|
||||||
import {exportPdf} from "../../../../common/js/utils";
|
|
||||||
import html2canvas from 'html2canvas';
|
import html2canvas from 'html2canvas';
|
||||||
import MsPerformanceReportExport from "./PerformanceReportExport";
|
import MsPerformanceReportExport from "./PerformanceReportExport";
|
||||||
|
|
||||||
|
@ -188,7 +188,8 @@ export default {
|
||||||
checkReportStatus(status) {
|
checkReportStatus(status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 'Error':
|
case 'Error':
|
||||||
this.$warning(this.$t('report.generation_error'));
|
// this.$warning(this.$t('report.generation_error'));
|
||||||
|
this.active = '4';
|
||||||
break;
|
break;
|
||||||
case 'Starting':
|
case 'Starting':
|
||||||
this.$alert(this.$t('report.start_status'));
|
this.$alert(this.$t('report.start_status'));
|
||||||
|
@ -240,6 +241,11 @@ export default {
|
||||||
},
|
},
|
||||||
onMessage(e) {
|
onMessage(e) {
|
||||||
this.$set(this.report, "refresh", e.data); // 触发刷新
|
this.$set(this.report, "refresh", e.data); // 触发刷新
|
||||||
|
if (e.data.startsWith('Error')) {
|
||||||
|
this.$set(this.report, "status", 'Error');
|
||||||
|
this.$warning(e.data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.$set(this.report, "status", 'Running');
|
this.$set(this.report, "status", 'Running');
|
||||||
this.status = 'Running';
|
this.status = 'Running';
|
||||||
this.initReportTimeInfo();
|
this.initReportTimeInfo();
|
||||||
|
|
|
@ -180,10 +180,7 @@ export default {
|
||||||
this.multipleSelection = val;
|
this.multipleSelection = val;
|
||||||
},
|
},
|
||||||
handleEdit(report) {
|
handleEdit(report) {
|
||||||
if (report.status === "Error") {
|
if (report.status === "Starting") {
|
||||||
this.$warning(this.$t('report.generation_error'));
|
|
||||||
return false
|
|
||||||
} else if (report.status === "Starting") {
|
|
||||||
this.$info(this.$t('report.being_generated'))
|
this.$info(this.$t('report.being_generated'))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ export default {
|
||||||
this.avgResponseTime = '0';
|
this.avgResponseTime = '0';
|
||||||
this.responseTime90 = '0';
|
this.responseTime90 = '0';
|
||||||
this.avgBandwidth = '0';
|
this.avgBandwidth = '0';
|
||||||
this.$warning(this.$t('report.generation_error'));
|
// this.$warning(this.$t('report.generation_error'));
|
||||||
})
|
})
|
||||||
this.getLoadChart();
|
this.getLoadChart();
|
||||||
this.getResChart();
|
this.getResChart();
|
||||||
|
|
|
@ -145,7 +145,7 @@
|
||||||
}
|
}
|
||||||
switch (this.report.status) {
|
switch (this.report.status) {
|
||||||
case 'Error':
|
case 'Error':
|
||||||
this.$warning(this.$t('report.generation_error'));
|
// this.$warning(this.$t('report.generation_error'));
|
||||||
break;
|
break;
|
||||||
case 'Starting':
|
case 'Starting':
|
||||||
this.$warning(this.$t('report.start_status'));
|
this.$warning(this.$t('report.start_status'));
|
||||||
|
|
|
@ -348,7 +348,7 @@ export default {
|
||||||
test_execute_again: 'Test Execute Again',
|
test_execute_again: 'Test Execute Again',
|
||||||
export: 'Export',
|
export: 'Export',
|
||||||
compare: 'Compare',
|
compare: 'Compare',
|
||||||
generation_error: 'Report generation error, cannot be viewed!',
|
generation_error: 'Report generation error, unable to view, please check log details!',
|
||||||
being_generated: 'Report is being generated...',
|
being_generated: 'Report is being generated...',
|
||||||
delete_confirm: 'Confirm delete: ',
|
delete_confirm: 'Confirm delete: ',
|
||||||
start_status: 'The test is in the beginning state, we will automatically display it on the page after we generate the report!',
|
start_status: 'The test is in the beginning state, we will automatically display it on the page after we generate the report!',
|
||||||
|
|
|
@ -347,7 +347,7 @@ export default {
|
||||||
test_execute_again: '再次执行',
|
test_execute_again: '再次执行',
|
||||||
export: '导出',
|
export: '导出',
|
||||||
compare: '比较',
|
compare: '比较',
|
||||||
generation_error: '报告生成错误,无法查看!',
|
generation_error: '报告生成错误, 无法查看, 请检查日志详情!',
|
||||||
being_generated: '报告正在生成中...',
|
being_generated: '报告正在生成中...',
|
||||||
delete_confirm: '确认删除报告: ',
|
delete_confirm: '确认删除报告: ',
|
||||||
start_status: '测试处于开始状态, 我们生成报告后会自动展示到页面上!',
|
start_status: '测试处于开始状态, 我们生成报告后会自动展示到页面上!',
|
||||||
|
|
|
@ -349,7 +349,7 @@ export default {
|
||||||
test_execute_again: '再次執行',
|
test_execute_again: '再次執行',
|
||||||
export: '導出',
|
export: '導出',
|
||||||
compare: '比較',
|
compare: '比較',
|
||||||
generation_error: '報告生成錯誤,無法查看!',
|
generation_error: '報告生成錯誤, 無法查看, 請檢查日誌詳情!',
|
||||||
being_generated: '報告正在生成中...',
|
being_generated: '報告正在生成中...',
|
||||||
delete_confirm: '確認刪除報告: ',
|
delete_confirm: '確認刪除報告: ',
|
||||||
start_status: '測試處於開始狀態, 我們生成報告後會自動展示到頁面上!',
|
start_status: '測試處於開始狀態, 我們生成報告後會自動展示到頁面上!',
|
||||||
|
|
Loading…
Reference in New Issue