refactor(性能测试): 报告中去除JTL下载

This commit is contained in:
CaptainB 2023-07-25 10:21:56 +08:00 committed by 刘瑞斌
parent a76fbc9297
commit aecce0d05f
4 changed files with 2 additions and 88 deletions

View File

@ -147,12 +147,6 @@ public class PerformanceReportController {
performanceReportService.deleteReportBatch(reportRequest);
}
@GetMapping("/jtl/download/{reportId}")
@RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_REPORT_READ)
public void downloadJtlZip(@PathVariable String reportId, HttpServletResponse response) {
performanceReportService.downloadJtlZip(reportId, response);
}
@GetMapping("get-jmx-content/{reportId}")
@RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_REPORT_READ)
public List<LoadTestExportJmx> getJmxContent(@PathVariable String reportId) {

View File

@ -477,46 +477,6 @@ public class PerformanceReportService {
return JSON.parseArray(content, ChartsData.class);
}
/**
* 流下载 jtl zip
*/
public void downloadJtlZip(String reportId, HttpServletResponse response) {
LoadTestReportWithBLOBs report = getReport(reportId);
if (StringUtils.isBlank(report.getFileId())) {
MSException.throwException(Translator.get("load_test_report_file_not_exist"));
}
response.setHeader("Content-Disposition", "attachment;fileName=" + reportId + ".zip");
FileMetadata metadata = fileMetadataService.getFileMetadataById(report.getFileId());
if (StringUtils.isEmpty(metadata.getStorage())) {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
ExtFileContentMapper mapper = sqlSession.getMapper(ExtFileContentMapper.class);
try (InputStream inputStream = mapper.selectZipBytes(report.getFileId())) {
ServletOutputStream outputStream = response.getOutputStream();
byte[] buffer = new byte[1024 * 4];
int read;
while ((read = inputStream.read(buffer)) > -1) {
outputStream.write(buffer, 0, read);
}
} catch (Exception e) {
LogUtil.error(e);
MSException.throwException(e);
}
}
} else {
try (InputStream inputStream = fileMetadataService.getFileAsStream(report.getFileId())) {
ServletOutputStream outputStream = response.getOutputStream();
byte[] buffer = new byte[1024 * 4];
int read;
while ((read = inputStream.read(buffer)) > -1) {
outputStream.write(buffer, 0, read);
}
} catch (Exception e) {
LogUtil.error(e);
MSException.throwException(e);
}
}
}
public String getPoolTypeByReportId(String reportId) {
LoadTestReportWithBLOBs report = getReport(reportId);

View File

@ -53,16 +53,6 @@ export function downloadLogFile(id, resourceId, isShare) {
return request(config)
}
export function downloadJtl(reportId) {
let config = {
url: "/performance/report/jtl/download/" + reportId,
method: 'get',
responseType: 'blob'
};
return request(config);
}
export function downloadZip(report) {
let testId = report.testId;
let reportId = report.id;

View File

@ -46,16 +46,11 @@
{{ $t('test_track.plan_view.share_report') }}
</el-button>
</el-popover>
<el-button :disabled="report.status !== 'Completed'" type="default" plain
<el-button :disabled="report.status !== 'Completed'" type="warning" plain
size="mini" v-permission="['PROJECT_PERFORMANCE_REPORT:READ+COMPARE']"
@click="compareReports()">
{{ $t('report.compare') }}
</el-button>
<el-button type="warning" plain size="mini"
:disabled="isReadOnly || report.status !== 'Completed' || testDeleted"
@click="downloadJtl()">
{{ $t('report.downloadJtl') }}
</el-button>
<el-button type="default" :disabled="testDeleted" plain size="mini" @click="downloadZipFile()">
{{ $t('report.downloadZipFile') }}
</el-button>
@ -157,13 +152,12 @@ import {hasPermission} from "metersphere-frontend/src/utils/permission";
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
import html2canvas from 'html2canvas';
import MsPerformanceReportExport from "./PerformanceReportExport";
import {Message} from "element-ui";
import SameTestReports from "./components/SameTestReports";
import MonitorCard from "./components/MonitorCard";
import MsTestConfiguration from "./components/TestConfiguration";
import {generateShareInfoWithExpired, getShareRedirectUrl} from "@/api/share";
import ProjectEnvironmentDialog from "./components/ProjectEnvironmentDialog";
import {downloadJtl, downloadZip, getProjectApplication, getReport, getReportTime, getTestProInfo, initReportSocket, stopTest} from "@/api/report";
import {downloadZip, getProjectApplication, getReport, getReportTime, getTestProInfo, initReportSocket, stopTest} from "@/api/report";
import {getTest, runTest} from "@/api/performance";
@ -420,30 +414,6 @@ export default {
this.reportExportVisible = false;
this.loading = false;
},
downloadJtl() {
downloadJtl(this.reportId)
.then(response => {
const content = response.data;
const blob = new Blob([content], {type: "application/octet-stream"});
if ("download" in document.createElement("a")) {
// IE
// chrome/firefox
let aTag = document.createElement('a');
aTag.download = this.reportName + ".zip";
aTag.href = URL.createObjectURL(blob);
aTag.click();
URL.revokeObjectURL(aTag.href);
} else {
// IE10+
navigator.msSaveBlob(blob, this.filename);
}
}).catch(e => {
let text = e.response.data.text();
text.then((data) => {
Message.error({message: JSON.parse(data).message || e.message, showClose: true});
});
});
},
downloadZipFile() {
downloadZip(this.report)
.then(response => {