mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-12 13:05:13 +08:00
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) {
|
||||
reportService.deleteReport(reportId);
|
||||
} 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);
|
||||
LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(loadTestReport.getTestId());
|
||||
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));
|
||||
}
|
||||
reportService.stopEngine(loadTest, engine);
|
||||
// 停止测试之后设置报告的状态
|
||||
reportService.updateStatus(reportId, PerformanceTestStatus.Completed.name());
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
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.utils.LogUtil;
|
||||
import io.metersphere.performance.service.PerformanceTestService;
|
||||
import io.metersphere.performance.service.ReportService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -18,12 +19,18 @@ import java.io.IOException;
|
||||
public class ReportWebSocket {
|
||||
|
||||
private static ReportService reportService;
|
||||
private static PerformanceTestService performanceTestService;
|
||||
|
||||
@Resource
|
||||
public void setReportService(ReportService reportService) {
|
||||
ReportWebSocket.reportService = reportService;
|
||||
}
|
||||
|
||||
@Resource
|
||||
public void setPerformanceTestService(PerformanceTestService performanceTestService) {
|
||||
ReportWebSocket.performanceTestService = performanceTestService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启连接的操作
|
||||
*/
|
||||
@ -78,12 +85,19 @@ public class ReportWebSocket {
|
||||
public void run() {
|
||||
while (stopMe) {
|
||||
try {
|
||||
LoadTestReport report = reportService.getReport(reportId);
|
||||
if (report == null || StringUtils.equalsAny(report.getStatus(), PerformanceTestStatus.Completed.name(), PerformanceTestStatus.Error.name())) {
|
||||
LoadTestReportWithBLOBs report = reportService.getReport(reportId);
|
||||
if (report == null || StringUtils.equalsAny(report.getStatus(), PerformanceTestStatus.Completed.name())) {
|
||||
this.stopMe();
|
||||
session.close();
|
||||
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()) {
|
||||
return;
|
||||
}
|
||||
|
@ -65,7 +65,8 @@
|
||||
</el-tabs>
|
||||
</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-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 MsMainContainer from "../../common/components/MsMainContainer";
|
||||
|
||||
import {checkoutTestManagerOrTestUser} from "@/common/js/utils";
|
||||
import {exportPdf} from "../../../../common/js/utils";
|
||||
import {checkoutTestManagerOrTestUser, exportPdf} from "@/common/js/utils";
|
||||
import html2canvas from 'html2canvas';
|
||||
import MsPerformanceReportExport from "./PerformanceReportExport";
|
||||
|
||||
@ -188,7 +188,8 @@ export default {
|
||||
checkReportStatus(status) {
|
||||
switch (status) {
|
||||
case 'Error':
|
||||
this.$warning(this.$t('report.generation_error'));
|
||||
// this.$warning(this.$t('report.generation_error'));
|
||||
this.active = '4';
|
||||
break;
|
||||
case 'Starting':
|
||||
this.$alert(this.$t('report.start_status'));
|
||||
@ -240,6 +241,11 @@ export default {
|
||||
},
|
||||
onMessage(e) {
|
||||
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.status = 'Running';
|
||||
this.initReportTimeInfo();
|
||||
|
@ -180,10 +180,7 @@ export default {
|
||||
this.multipleSelection = val;
|
||||
},
|
||||
handleEdit(report) {
|
||||
if (report.status === "Error") {
|
||||
this.$warning(this.$t('report.generation_error'));
|
||||
return false
|
||||
} else if (report.status === "Starting") {
|
||||
if (report.status === "Starting") {
|
||||
this.$info(this.$t('report.being_generated'))
|
||||
return false
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ export default {
|
||||
this.avgResponseTime = '0';
|
||||
this.responseTime90 = '0';
|
||||
this.avgBandwidth = '0';
|
||||
this.$warning(this.$t('report.generation_error'));
|
||||
// this.$warning(this.$t('report.generation_error'));
|
||||
})
|
||||
this.getLoadChart();
|
||||
this.getResChart();
|
||||
|
@ -145,7 +145,7 @@
|
||||
}
|
||||
switch (this.report.status) {
|
||||
case 'Error':
|
||||
this.$warning(this.$t('report.generation_error'));
|
||||
// this.$warning(this.$t('report.generation_error'));
|
||||
break;
|
||||
case 'Starting':
|
||||
this.$warning(this.$t('report.start_status'));
|
||||
|
@ -348,7 +348,7 @@ export default {
|
||||
test_execute_again: 'Test Execute Again',
|
||||
export: 'Export',
|
||||
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...',
|
||||
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!',
|
||||
|
@ -347,7 +347,7 @@ export default {
|
||||
test_execute_again: '再次执行',
|
||||
export: '导出',
|
||||
compare: '比较',
|
||||
generation_error: '报告生成错误,无法查看!',
|
||||
generation_error: '报告生成错误, 无法查看, 请检查日志详情!',
|
||||
being_generated: '报告正在生成中...',
|
||||
delete_confirm: '确认删除报告: ',
|
||||
start_status: '测试处于开始状态, 我们生成报告后会自动展示到页面上!',
|
||||
|
@ -349,7 +349,7 @@ export default {
|
||||
test_execute_again: '再次執行',
|
||||
export: '導出',
|
||||
compare: '比較',
|
||||
generation_error: '報告生成錯誤,無法查看!',
|
||||
generation_error: '報告生成錯誤, 無法查看, 請檢查日誌詳情!',
|
||||
being_generated: '報告正在生成中...',
|
||||
delete_confirm: '確認刪除報告: ',
|
||||
start_status: '測試處於開始狀態, 我們生成報告後會自動展示到頁面上!',
|
||||
|
Loading…
Reference in New Issue
Block a user