refactor(性能测试): 修改文件名称

This commit is contained in:
Captain.B 2020-11-11 16:02:36 +08:00
parent 6b443008cd
commit 8394d88093
7 changed files with 94 additions and 77 deletions

View File

@ -2,8 +2,8 @@ import MsProject from "@/business/components/project/MsProject";
const PerformanceTest = () => import('@/business/components/performance/PerformanceTest') const PerformanceTest = () => import('@/business/components/performance/PerformanceTest')
const PerformanceTestHome = () => import('@/business/components/performance/home/PerformanceTestHome') const PerformanceTestHome = () => import('@/business/components/performance/home/PerformanceTestHome')
const EditPerformanceTestPlan = () => import('@/business/components/performance/test/EditPerformanceTestPlan') const EditPerformanceTest = () => import('@/business/components/performance/test/EditPerformanceTest')
const PerformanceTestPlan = () => import('@/business/components/performance/test/PerformanceTestPlan') const PerformanceTestList = () => import('@/business/components/performance/test/PerformanceTestList')
const PerformanceTestReport = () => import('@/business/components/performance/report/PerformanceTestReport') const PerformanceTestReport = () => import('@/business/components/performance/report/PerformanceTestReport')
const PerformanceChart = () => import('@/business/components/performance/report/components/PerformanceChart') const PerformanceChart = () => import('@/business/components/performance/report/components/PerformanceChart')
const PerformanceReportView = () => import('@/business/components/performance/report/PerformanceReportView') const PerformanceReportView = () => import('@/business/components/performance/report/PerformanceReportView')
@ -24,12 +24,12 @@ export default {
{ {
path: 'test/create', path: 'test/create',
name: "createPerTest", name: "createPerTest",
component: EditPerformanceTestPlan, component: EditPerformanceTest,
}, },
{ {
path: "test/edit/:testId", path: "test/edit/:testId",
name: "editPerTest", name: "editPerTest",
component: EditPerformanceTestPlan, component: EditPerformanceTest,
props: { props: {
content: (route) => { content: (route) => {
return { return {
@ -41,7 +41,7 @@ export default {
{ {
path: "test/:projectId", path: "test/:projectId",
name: "perPlan", name: "perPlan",
component: PerformanceTestPlan component: PerformanceTestList
}, },
{ {
path: "project/:type", path: "project/:type",

View File

@ -4,12 +4,12 @@
<el-card v-loading="result.loading"> <el-card v-loading="result.loading">
<el-row> <el-row>
<el-col :span="10"> <el-col :span="10">
<el-input :disabled="isReadOnly" :placeholder="$t('load_test.input_name')" v-model="testPlan.name" <el-input :disabled="isReadOnly" :placeholder="$t('load_test.input_name')" v-model="test.name"
class="input-with-select" class="input-with-select"
maxlength="30" show-word-limit maxlength="30" show-word-limit
> >
<template v-slot:prepend> <template v-slot:prepend>
<el-select filterable v-model="testPlan.projectId" <el-select filterable v-model="test.projectId"
:placeholder="$t('load_test.select_project')"> :placeholder="$t('load_test.select_project')">
<el-option <el-option
v-for="item in projects" v-for="item in projects"
@ -29,7 +29,7 @@
<el-button :disabled="isReadOnly" type="warning" plain @click="cancel">{{ $t('commons.cancel') }} <el-button :disabled="isReadOnly" type="warning" plain @click="cancel">{{ $t('commons.cancel') }}
</el-button> </el-button>
<ms-schedule-config :schedule="testPlan.schedule" :save="saveCronExpression" @scheduleChange="saveSchedule" <ms-schedule-config :schedule="test.schedule" :save="saveCronExpression" @scheduleChange="saveSchedule"
:check-open="checkScheduleEdit" :test-id="testId" :custom-validate="durationValidate"/> :check-open="checkScheduleEdit" :test-id="testId" :custom-validate="durationValidate"/>
</el-col> </el-col>
</el-row> </el-row>
@ -37,11 +37,11 @@
<el-tabs class="testplan-config" v-model="active" type="border-card" :stretch="true"> <el-tabs class="testplan-config" v-model="active" type="border-card" :stretch="true">
<el-tab-pane :label="$t('load_test.basic_config')"> <el-tab-pane :label="$t('load_test.basic_config')">
<performance-basic-config :is-read-only="isReadOnly" :test-plan="testPlan" ref="basicConfig" <performance-basic-config :is-read-only="isReadOnly" :test="test" ref="basicConfig"
@fileChange="fileChange"/> @fileChange="fileChange"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="$t('load_test.pressure_config')"> <el-tab-pane :label="$t('load_test.pressure_config')">
<performance-pressure-config :is-read-only="isReadOnly" :test-plan="testPlan" :test-id="testId" <performance-pressure-config :is-read-only="isReadOnly" :test="test" :test-id="testId"
ref="pressureConfig" @changeActive="changeTabActive"/> ref="pressureConfig" @changeActive="changeTabActive"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="$t('load_test.advanced_config')" class="advanced-config"> <el-tab-pane :label="$t('load_test.advanced_config')" class="advanced-config">
@ -64,7 +64,7 @@ import MsScheduleConfig from "../../common/components/MsScheduleConfig";
import {LIST_CHANGE, PerformanceEvent} from "@/business/components/common/head/ListEvent"; import {LIST_CHANGE, PerformanceEvent} from "@/business/components/common/head/ListEvent";
export default { export default {
name: "EditPerformanceTestPlan", name: "EditPerformanceTest",
components: { components: {
MsScheduleConfig, MsScheduleConfig,
PerformancePressureConfig, PerformancePressureConfig,
@ -76,7 +76,7 @@ export default {
data() { data() {
return { return {
result: {}, result: {},
testPlan: {schedule: {}}, test: {schedule: {}},
listProjectPath: "/project/listAll", listProjectPath: "/project/listAll",
savePath: "/performance/save", savePath: "/performance/save",
editPath: "/performance/edit", editPath: "/performance/edit",
@ -137,8 +137,8 @@ export default {
importAPITest() { importAPITest() {
let apiTest = this.$store.state.api.test; let apiTest = this.$store.state.api.test;
if (apiTest && apiTest.name) { if (apiTest && apiTest.name) {
this.$set(this.testPlan, "projectId", apiTest.projectId); this.$set(this.test, "projectId", apiTest.projectId);
this.$set(this.testPlan, "name", apiTest.name); this.$set(this.test, "name", apiTest.name);
let blob = new Blob([apiTest.jmx.xml], {type: "application/octet-stream"}); let blob = new Blob([apiTest.jmx.xml], {type: "application/octet-stream"});
let file = new File([blob], apiTest.jmx.name); let file = new File([blob], apiTest.jmx.name);
this.$refs.basicConfig.beforeUpload(file); this.$refs.basicConfig.beforeUpload(file);
@ -152,9 +152,9 @@ export default {
this.testId = testId; this.testId = testId;
this.result = this.$get('/performance/get/' + testId, response => { this.result = this.$get('/performance/get/' + testId, response => {
if (response.data) { if (response.data) {
this.testPlan = response.data; this.test = response.data;
if (!this.testPlan.schedule) { if (!this.test.schedule) {
this.testPlan.schedule = {}; this.test.schedule = {};
} }
} }
}); });
@ -166,7 +166,7 @@ export default {
}) })
}, },
save() { save() {
if (!this.validTestPlan()) { if (!this.validTest()) {
return; return;
} }
@ -181,16 +181,16 @@ export default {
}); });
}, },
saveAndRun() { saveAndRun() {
if (!this.validTestPlan()) { if (!this.validTest()) {
return; return;
} }
let options = this.getSaveOption(); let options = this.getSaveOption();
this.result = this.$request(options, (response) => { this.result = this.$request(options, (response) => {
this.testPlan.id = response.data; this.test.id = response.data;
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
this.result = this.$post(this.runPath, {id: this.testPlan.id, triggerMode: 'MANUAL'}, (response) => { this.result = this.$post(this.runPath, {id: this.test.id, triggerMode: 'MANUAL'}, (response) => {
let reportId = response.data; let reportId = response.data;
this.$router.push({path: '/performance/report/view/' + reportId}) this.$router.push({path: '/performance/report/view/' + reportId})
// 广 head // 广 head
@ -200,7 +200,7 @@ export default {
}, },
getSaveOption() { getSaveOption() {
let formData = new FormData(); let formData = new FormData();
let url = this.testPlan.id ? this.editPath : this.savePath; let url = this.test.id ? this.editPath : this.savePath;
if (this.$refs.basicConfig.uploadList.length > 0) { if (this.$refs.basicConfig.uploadList.length > 0) {
this.$refs.basicConfig.uploadList.forEach(f => { this.$refs.basicConfig.uploadList.forEach(f => {
@ -208,15 +208,15 @@ export default {
}); });
} }
// //
this.testPlan.updatedFileList = this.$refs.basicConfig.updatedFileList(); this.test.updatedFileList = this.$refs.basicConfig.updatedFileList();
// //
this.testPlan.loadConfiguration = JSON.stringify(this.$refs.pressureConfig.convertProperty()); this.test.loadConfiguration = JSON.stringify(this.$refs.pressureConfig.convertProperty());
this.testPlan.testResourcePoolId = this.$refs.pressureConfig.resourcePool; this.test.testResourcePoolId = this.$refs.pressureConfig.resourcePool;
// //
this.testPlan.advancedConfiguration = JSON.stringify(this.$refs.advancedConfig.configurations()); this.test.advancedConfiguration = JSON.stringify(this.$refs.advancedConfig.configurations());
// filejson // filejson
let requestJson = JSON.stringify(this.testPlan, function (key, value) { let requestJson = JSON.stringify(this.test, function (key, value) {
return key === "file" ? undefined : value return key === "file" ? undefined : value
}); });
@ -236,13 +236,13 @@ export default {
cancel() { cancel() {
this.$router.push({path: '/performance/test/all'}) this.$router.push({path: '/performance/test/all'})
}, },
validTestPlan() { validTest() {
if (!this.testPlan.name) { if (!this.test.name) {
this.$error(this.$t('load_test.test_name_is_null')); this.$error(this.$t('load_test.test_name_is_null'));
return false; return false;
} }
if (!this.testPlan.projectId) { if (!this.test.projectId) {
this.$error(this.$t('load_test.project_is_null')); this.$error(this.$t('load_test.project_is_null'));
return false; return false;
} }
@ -269,26 +269,26 @@ export default {
}); });
}, },
saveCronExpression(cronExpression) { saveCronExpression(cronExpression) {
this.testPlan.schedule.enable = true; this.test.schedule.enable = true;
this.testPlan.schedule.value = cronExpression; this.test.schedule.value = cronExpression;
this.saveSchedule(); this.saveSchedule();
}, },
saveSchedule() { saveSchedule() {
this.checkScheduleEdit(); this.checkScheduleEdit();
let param = {}; let param = {};
param = this.testPlan.schedule; param = this.test.schedule;
param.resourceId = this.testPlan.id; param.resourceId = this.test.id;
let url = '/performance/schedule/create'; let url = '/performance/schedule/create';
if (param.id) { if (param.id) {
url = '/performance/schedule/update'; url = '/performance/schedule/update';
} }
this.$post(url, param, response => { this.$post(url, param, response => {
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
this.getTest(this.testPlan.id); this.getTest(this.test.id);
}); });
}, },
checkScheduleEdit() { checkScheduleEdit() {
if (!this.testPlan.id) { if (!this.test.id) {
this.$message(this.$t('api_test.environment.please_save_test')); this.$message(this.$t('api_test.environment.please_save_test'));
return false; return false;
} }

View File

@ -80,7 +80,7 @@ import MsContainer from "../../common/components/MsContainer";
import MsMainContainer from "../../common/components/MsMainContainer"; import MsMainContainer from "../../common/components/MsMainContainer";
import MsPerformanceTestStatus from "./PerformanceTestStatus"; import MsPerformanceTestStatus from "./PerformanceTestStatus";
import MsTableOperators from "../../common/components/MsTableOperators"; import MsTableOperators from "../../common/components/MsTableOperators";
import {_filter, _sort} from "../../../../common/js/utils"; import {_filter, _sort} from "@/common/js/utils";
import MsTableHeader from "../../common/components/MsTableHeader"; import MsTableHeader from "../../common/components/MsTableHeader";
import {TEST_CONFIGS} from "../../common/components/search/search-components"; import {TEST_CONFIGS} from "../../common/components/search/search-components";
import {LIST_CHANGE, PerformanceEvent} from "@/business/components/common/head/ListEvent"; import {LIST_CHANGE, PerformanceEvent} from "@/business/components/common/head/ListEvent";
@ -164,30 +164,30 @@ export default {
handleSelectionChange(val) { handleSelectionChange(val) {
this.multipleSelection = val; this.multipleSelection = val;
}, },
handleEdit(testPlan) { handleEdit(test) {
this.$router.push({ this.$router.push({
path: '/performance/test/edit/' + testPlan.id, path: '/performance/test/edit/' + test.id,
}) })
}, },
handleCopy(testPlan) { handleCopy(test) {
this.result = this.$post("/performance/copy", {id: testPlan.id}, () => { this.result = this.$post("/performance/copy", {id: test.id}, () => {
this.$success(this.$t('commons.copy_success')); this.$success(this.$t('commons.copy_success'));
this.search(); this.search();
}); });
}, },
handleDelete(testPlan) { handleDelete(test) {
this.$alert(this.$t('load_test.delete_confirm') + testPlan.name + "", '', { this.$alert(this.$t('load_test.delete_confirm') + test.name + "", '', {
confirmButtonText: this.$t('commons.confirm'), confirmButtonText: this.$t('commons.confirm'),
callback: (action) => { callback: (action) => {
if (action === 'confirm') { if (action === 'confirm') {
this._handleDelete(testPlan); this._handleDelete(test);
} }
} }
}); });
}, },
_handleDelete(testPlan) { _handleDelete(test) {
let data = { let data = {
id: testPlan.id id: test.id
}; };
this.result = this.$post(this.deletePath, data, () => { this.result = this.$post(this.deletePath, data, () => {

View File

@ -61,7 +61,7 @@ import {findThreadGroup} from "@/business/components/performance/test/model/Thre
export default { export default {
name: "PerformanceBasicConfig", name: "PerformanceBasicConfig",
props: { props: {
testPlan: { test: {
type: Object type: Object
}, },
isReadOnly: { isReadOnly: {
@ -82,14 +82,14 @@ export default {
}; };
}, },
created() { created() {
if (this.testPlan.id) { if (this.test.id) {
this.getFileMetadata(this.testPlan) this.getFileMetadata(this.test)
} }
}, },
watch: { watch: {
testPlan() { test() {
if (this.testPlan.id) { if (this.test.id) {
this.getFileMetadata(this.testPlan) this.getFileMetadata(this.test)
} }
}, },
uploadList() { uploadList() {
@ -107,11 +107,11 @@ export default {
} }
}, },
methods: { methods: {
getFileMetadata(testPlan) { getFileMetadata(test) {
this.fileList = []; this.fileList = [];
this.tableData = []; this.tableData = [];
this.uploadList = []; this.uploadList = [];
this.result = this.$get(this.getFileMetadataPath + "/" + testPlan.id, response => { this.result = this.$get(this.getFileMetadataPath + "/" + test.id, response => {
let files = response.data; let files = response.data;
if (!files) { if (!files) {

View File

@ -92,7 +92,7 @@
<script> <script>
import echarts from "echarts"; import echarts from "echarts";
import MsChart from "@/business/components/common/chart/MsChart"; import MsChart from "@/business/components/common/chart/MsChart";
import {findThreadGroup} from "@/business/components/performance/test/model/ThreadGroup"; import {findTestPlan, findThreadGroup} from "@/business/components/performance/test/model/ThreadGroup";
const TARGET_LEVEL = "TargetLevel"; const TARGET_LEVEL = "TargetLevel";
const RAMP_UP = "RampUp"; const RAMP_UP = "RampUp";
@ -115,7 +115,7 @@ export default {
name: "PerformancePressureConfig", name: "PerformancePressureConfig",
components: {MsChart}, components: {MsChart},
props: { props: {
testPlan: { test: {
type: Object type: Object
}, },
testId: { testId: {
@ -140,6 +140,7 @@ export default {
resourcePools: [], resourcePools: [],
activeNames: ["0"], activeNames: ["0"],
threadGroups: [], threadGroups: [],
serializeThreadgroups: false,
} }
}, },
mounted() { mounted() {
@ -148,11 +149,11 @@ export default {
} else { } else {
this.calculateTotalChart(); this.calculateTotalChart();
} }
this.resourcePool = this.testPlan.testResourcePoolId; this.resourcePool = this.test.testResourcePoolId;
this.getResourcePools(); this.getResourcePools();
}, },
watch: { watch: {
testPlan(n) { test(n) {
this.resourcePool = n.testResourcePoolId; this.resourcePool = n.testResourcePoolId;
}, },
testId() { testId() {
@ -240,6 +241,12 @@ export default {
if (this.testId) { if (this.testId) {
this.$get('/performance/get-jmx-content/' + this.testId, (response) => { this.$get('/performance/get-jmx-content/' + this.testId, (response) => {
if (response.data) { if (response.data) {
let testPlan = findTestPlan(response.data);
testPlan.elements.forEach(e => {
if (e.attributes.name === 'TestPlan.serialize_threadgroups') {
this.serializeThreadgroups = Boolean(e.elements[0].text);
}
});
this.threadGroups = findThreadGroup(response.data); this.threadGroups = findThreadGroup(response.data);
this.threadGroups.forEach(tg => { this.threadGroups.forEach(tg => {
tg.options = {}; tg.options = {};
@ -273,7 +280,6 @@ export default {
series: [] series: []
}; };
for (let i = 0; i < handler.threadGroups.length; i++) { for (let i = 0; i < handler.threadGroups.length; i++) {
let seriesData = { let seriesData = {
name: handler.threadGroups[i].attributes.testname, name: handler.threadGroups[i].attributes.testname,

View File

@ -18,3 +18,13 @@ export function findThreadGroup(jmxContent) {
travel(jmxJson.elements, threadGroups); travel(jmxJson.elements, threadGroups);
return threadGroups; return threadGroups;
} }
export function findTestPlan(jmxContent) {
let jmxJson = JSON.parse(xml2json(jmxContent));
for (let element of jmxJson.elements[0].elements[0].elements) {
if (element.name === 'TestPlan') {
return element;
}
}
}

View File

@ -19,10 +19,10 @@
<el-tabs class="test-config" v-model="active" type="border-card" :stretch="true"> <el-tabs class="test-config" v-model="active" type="border-card" :stretch="true">
<el-tab-pane :label="$t('load_test.basic_config')"> <el-tab-pane :label="$t('load_test.basic_config')">
<performance-basic-config :is-read-only="true" :test-plan="test" ref="basicConfig"/> <performance-basic-config :is-read-only="true" :test="test" ref="basicConfig"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="$t('load_test.pressure_config')"> <el-tab-pane :label="$t('load_test.pressure_config')">
<performance-pressure-config :is-read-only="true" :test-plan="test" :test-id="id" ref="pressureConfig"/> <performance-pressure-config :is-read-only="true" :test="test" :test-id="id" ref="pressureConfig"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="$t('load_test.advanced_config')" class="advanced-config"> <el-tab-pane :label="$t('load_test.advanced_config')" class="advanced-config">
<performance-advanced-config :read-only="true" :test-id="id" ref="advancedConfig"/> <performance-advanced-config :read-only="true" :test-id="id" ref="advancedConfig"/>
@ -35,22 +35,23 @@
<script> <script>
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 PerformanceBasicConfig from "../../../../../performance/test/components/PerformanceBasicConfig"; import PerformanceBasicConfig from "../../../../../performance/test/components/PerformanceBasicConfig";
import PerformancePressureConfig from "../../../../../performance/test/components/PerformancePressureConfig"; import PerformancePressureConfig from "../../../../../performance/test/components/PerformancePressureConfig";
import PerformanceAdvancedConfig from "../../../../../performance/test/components/PerformanceAdvancedConfig"; import PerformanceAdvancedConfig from "../../../../../performance/test/components/PerformanceAdvancedConfig";
export default {
name: "PerformanceTestDetail", export default {
components: { name: "PerformanceTestDetail",
PerformanceAdvancedConfig, components: {
PerformancePressureConfig, PerformanceAdvancedConfig,
PerformanceBasicConfig, PerformancePressureConfig,
MsMainContainer, PerformanceBasicConfig,
MsContainer MsMainContainer,
}, MsContainer
data() { },
return { data() {
return {
result: {}, result: {},
test: {}, test: {},
savePath: "/performance/save", savePath: "/performance/save",