Merge remote-tracking branch 'origin/v1.2' into v1.2

This commit is contained in:
wenyann 2020-08-28 16:39:23 +08:00
commit 5353d7a04a
2 changed files with 207 additions and 223 deletions

View File

@ -22,9 +22,9 @@
@click="rerun(testId)"> @click="rerun(testId)">
{{ $t('report.test_execute_again') }} {{ $t('report.test_execute_again') }}
</el-button> </el-button>
<!-- <el-button :disabled="isReadOnly" type="info" plain size="mini" @click="exports(reportName)"> <!-- <el-button :disabled="isReadOnly" type="info" plain size="mini" @click="exports(reportName)">
{{$t('report.export')}} {{$t('report.export')}}
</el-button>--> </el-button>-->
<!-- <!--
<el-button :disabled="isReadOnly" type="warning" plain size="mini"> <el-button :disabled="isReadOnly" type="warning" plain size="mini">
{{$t('report.compare')}} {{$t('report.compare')}}
@ -82,252 +82,235 @@
</template> </template>
<script> <script>
import MsReportErrorLog from './components/ErrorLog'; import MsReportErrorLog from './components/ErrorLog';
import MsReportLogDetails from './components/LogDetails'; import MsReportLogDetails from './components/LogDetails';
import MsReportRequestStatistics from './components/RequestStatistics'; import MsReportRequestStatistics from './components/RequestStatistics';
import MsReportTestOverview from './components/TestOverview'; import MsReportTestOverview from './components/TestOverview';
import MsPerformancePressureConfig from "./components/PerformancePressureConfig"; 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} from "@/common/js/utils";
import writer from "file-writer";
import ResumeCss from "../../../../common/css/main.css";
export default { export default {
name: "PerformanceReportView", name: "PerformanceReportView",
components: { components: {
MsReportErrorLog, MsReportErrorLog,
MsReportLogDetails, MsReportLogDetails,
MsReportRequestStatistics, MsReportRequestStatistics,
MsReportTestOverview, MsReportTestOverview,
MsContainer, MsContainer,
MsMainContainer, MsMainContainer,
MsPerformancePressureConfig MsPerformancePressureConfig
}, },
data() { data() {
return { return {
result: {}, result: {},
active: '1', active: '1',
reportId: '', reportId: '',
status: '', status: '',
reportName: '', reportName: '',
testId: '', testId: '',
testName: '', testName: '',
projectId: '', projectId: '',
projectName: '', projectName: '',
startTime: '0', startTime: '0',
endTime: '0', endTime: '0',
minutes: '0', minutes: '0',
seconds: '0', seconds: '0',
title: 'Logging', title: 'Logging',
report: {}, report: {},
isReadOnly: false, isReadOnly: false,
websocket: null, websocket: null,
dialogFormVisible: false, dialogFormVisible: false,
testPlan: {testResourcePoolId: null} testPlan: {testResourcePoolId: null}
}
},
methods: {
initBreadcrumb() {
if (this.reportId) {
this.result = this.$get("/performance/report/test/pro/info/" + this.reportId, res => {
let data = res.data;
if (data) {
this.reportName = data.name;
this.testId = data.testId;
this.testName = data.testName;
this.projectId = data.projectId;
this.projectName = data.projectName;
}
})
} }
}, },
methods: { initReportTimeInfo() {
initBreadcrumb() { if (this.reportId) {
if (this.reportId) { this.result = this.$get("/performance/report/content/report_time/" + this.reportId)
this.result = this.$get("/performance/report/test/pro/info/" + this.reportId, res => { .then(res => {
let data = res.data; let data = res.data.data;
if (data) { if (data) {
this.reportName = data.name; this.startTime = data.startTime;
this.testId = data.testId; this.endTime = data.endTime;
this.testName = data.testName; let duration = data.duration;
this.projectId = data.projectId; this.minutes = Math.floor(duration / 60);
this.projectName = data.projectName; this.seconds = duration % 60;
} }
}).catch(() => {
this.clearData();
}) })
}
},
initReportTimeInfo() {
if (this.reportId) {
this.result = this.$get("/performance/report/content/report_time/" + this.reportId)
.then(res => {
let data = res.data.data;
if (data) {
this.startTime = data.startTime;
this.endTime = data.endTime;
let duration = data.duration;
this.minutes = Math.floor(duration / 60);
this.seconds = duration % 60;
}
}).catch(() => {
this.clearData();
})
}
},
initWebSocket() {
let protocol = "ws://";
if (window.location.protocol === 'https:') {
protocol = "wss://";
}
const uri = protocol + window.location.host + "/performance/report/" + this.reportId;
this.websocket = new WebSocket(uri);
this.websocket.onmessage = this.onMessage;
this.websocket.onopen = this.onOpen;
this.websocket.onerror = this.onError;
this.websocket.onclose = this.onClose;
},
checkReportStatus(status) {
switch (status) {
case 'Error':
this.$warning(this.$t('report.generation_error'));
break;
case 'Starting':
this.$alert(this.$t('report.start_status'));
break;
case 'Reporting':
case 'Running':
case 'Completed':
default:
break;
}
},
clearData() {
this.startTime = '0';
this.endTime = '0';
this.minutes = '0';
this.seconds = '0';
},
stopTest(forceStop) {
this.result = this.$get('/performance/stop/' + this.reportId + '/' + forceStop, () => {
this.$success(this.$t('report.test_stop_success'));
if (forceStop) {
this.$router.push('/performance/report/all');
} else {
this.report.status = 'Completed';
}
});
this.dialogFormVisible = false;
},
rerun(testId) {
this.$confirm(this.$t('report.test_rerun_confirm'), '', {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
type: 'warning'
}).then(() => {
this.result = this.$post('/performance/run', {id: testId, triggerMode: 'MANUAL'}, (response) => {
this.reportId = response.data;
this.$router.push({path: '/performance/report/view/' + this.reportId});
// socket
this.initWebSocket();
})
}).catch(() => {
});
},
onOpen() {
window.console.log("socket opening.");
},
onError(e) {
window.console.error(e)
},
onMessage(e) {
this.$set(this.report, "refresh", e.data); //
this.$set(this.report, "status", 'Running');
this.initReportTimeInfo();
window.console.log('receive a message:', e.data);
},
onClose(e) {
this.$set(this.report, "refresh", Math.random()); //
this.$set(this.report, "status", 'Completed');
this.initReportTimeInfo();
window.console.log("socket closed.");
} }
}, },
created() { initWebSocket() {
this.isReadOnly = false; let protocol = "ws://";
if (!checkoutTestManagerOrTestUser()) { if (window.location.protocol === 'https:') {
this.isReadOnly = true; protocol = "wss://";
} }
this.reportId = this.$route.path.split('/')[4]; const uri = protocol + window.location.host + "/performance/report/" + this.reportId;
this.result = this.$get("/performance/report/" + this.reportId, res => { this.websocket = new WebSocket(uri);
let data = res.data; this.websocket.onmessage = this.onMessage;
if (data) { this.websocket.onopen = this.onOpen;
this.status = data.status; this.websocket.onerror = this.onError;
this.$set(this.report, "id", this.reportId); this.websocket.onclose = this.onClose;
this.$set(this.report, "status", data.status); },
this.$set(this.report, "testId", data.testId); checkReportStatus(status) {
this.$set(this.report, "loadConfiguration", data.loadConfiguration); switch (status) {
this.checkReportStatus(data.status); case 'Error':
if (this.status === "Completed" || this.status === "Running") { this.$warning(this.$t('report.generation_error'));
this.initReportTimeInfo(); break;
} case 'Starting':
this.initBreadcrumb(); this.$alert(this.$t('report.start_status'));
this.initWebSocket(); break;
case 'Reporting':
case 'Running':
case 'Completed':
default:
break;
}
},
clearData() {
this.startTime = '0';
this.endTime = '0';
this.minutes = '0';
this.seconds = '0';
},
stopTest(forceStop) {
this.result = this.$get('/performance/stop/' + this.reportId + '/' + forceStop, () => {
this.$success(this.$t('report.test_stop_success'));
if (forceStop) {
this.$router.push('/performance/report/all');
} else { } else {
this.$error(this.$t('report.not_exist')) this.report.status = 'Completed';
} }
}); });
this.dialogFormVisible = false;
}, },
beforeDestroy() { rerun(testId) {
this.websocket.close() //websocket this.$confirm(this.$t('report.test_rerun_confirm'), '', {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
type: 'warning'
}).then(() => {
this.result = this.$post('/performance/run', {id: testId, triggerMode: 'MANUAL'}, (response) => {
this.reportId = response.data;
this.$router.push({path: '/performance/report/view/' + this.reportId});
// socket
this.initWebSocket();
})
}).catch(() => {
});
}, },
watch: { onOpen() {
'$route'(to) { window.console.log("socket opening.");
if (to.name === "perReportView") { },
this.isReadOnly = false; onError(e) {
if (!checkoutTestManagerOrTestUser()) { window.console.error(e)
this.isReadOnly = true; },
} onMessage(e) {
let reportId = to.path.split('/')[4]; this.$set(this.report, "refresh", e.data); //
this.reportId = reportId; this.$set(this.report, "status", 'Running');
if (reportId) { this.initReportTimeInfo();
this.$get("/performance/report/test/pro/info/" + reportId, response => { window.console.log('receive a message:', e.data);
let data = response.data; },
if (data) { onClose(e) {
this.status = data.status; this.$set(this.report, "refresh", Math.random()); //
this.reportName = data.name; this.$set(this.report, "status", 'Completed');
this.testName = data.testName; this.initReportTimeInfo();
this.testId = data.testId; window.console.log("socket closed.");
this.projectName = data.projectName; }
},
created() {
this.isReadOnly = false;
if (!checkoutTestManagerOrTestUser()) {
this.isReadOnly = true;
}
this.reportId = this.$route.path.split('/')[4];
this.result = this.$get("/performance/report/" + this.reportId, res => {
let data = res.data;
if (data) {
this.status = data.status;
this.$set(this.report, "id", this.reportId);
this.$set(this.report, "status", data.status);
this.$set(this.report, "testId", data.testId);
this.$set(this.report, "loadConfiguration", data.loadConfiguration);
this.checkReportStatus(data.status);
if (this.status === "Completed" || this.status === "Running") {
this.initReportTimeInfo();
}
this.initBreadcrumb();
this.initWebSocket();
} else {
this.$error(this.$t('report.not_exist'))
}
});
this.$set(this.report, "id", reportId); },
this.$set(this.report, "status", data.status); beforeDestroy() {
this.websocket.close() //websocket
},
watch: {
'$route'(to) {
if (to.name === "perReportView") {
this.isReadOnly = false;
if (!checkoutTestManagerOrTestUser()) {
this.isReadOnly = true;
}
let reportId = to.path.split('/')[4];
this.reportId = reportId;
if (reportId) {
this.$get("/performance/report/test/pro/info/" + reportId, response => {
let data = response.data;
if (data) {
this.status = data.status;
this.reportName = data.name;
this.testName = data.testName;
this.testId = data.testId;
this.projectName = data.projectName;
this.checkReportStatus(data.status); this.$set(this.report, "id", reportId);
if (this.status === "Completed") { this.$set(this.report, "status", data.status);
this.result = this.$get("/performance/report/content/report_time/" + this.reportId).then(res => {
let data = res.data.data; this.checkReportStatus(data.status);
if (data) { this.initReportTimeInfo();
this.startTime = data.startTime; } else {
this.endTime = data.endTime; this.$error(this.$t('report.not_exist'));
let duration = data.duration; }
this.minutes = Math.floor(duration / 60); });
this.seconds = duration % 60;
}
}).catch(() => {
this.clearData();
})
} else {
this.clearData();
}
} else {
this.$error(this.$t('report.not_exist'));
}
});
}
} }
} }
} }
} }
}
</script> </script>
<style scoped> <style scoped>
.ms-report-view-btns { .ms-report-view-btns {
margin-top: 15px; margin-top: 15px;
} }
.ms-report-time-desc { .ms-report-time-desc {
text-align: left; text-align: left;
display: block; display: block;
color: #5C7878; color: #5C7878;
} }
</style> </style>

View File

@ -164,6 +164,7 @@ export default {
} else { } else {
this.calculateChart(); this.calculateChart();
} }
this.getResourcePools();
}, },
}, },
methods: { methods: {