测试用例关联性能测试
This commit is contained in:
parent
dde198da93
commit
54000e2f31
|
@ -91,8 +91,8 @@ public class PerformanceTestController {
|
|||
}
|
||||
|
||||
@PostMapping("/run")
|
||||
public void run(@RequestBody RunTestPlanRequest request) {
|
||||
performanceTestService.run(request);
|
||||
public String run(@RequestBody RunTestPlanRequest request) {
|
||||
return performanceTestService.run(request);
|
||||
}
|
||||
|
||||
@GetMapping("/file/metadata/{testId}")
|
||||
|
|
|
@ -186,7 +186,7 @@ public class PerformanceTestService {
|
|||
}
|
||||
|
||||
@Transactional(noRollbackFor = MSException.class)// 保存失败的信息
|
||||
public void run(RunTestPlanRequest request) {
|
||||
public String run(RunTestPlanRequest request) {
|
||||
final LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(request.getId());
|
||||
if (loadTest == null) {
|
||||
MSException.throwException(Translator.get("run_load_test_not_found") + request.getId());
|
||||
|
@ -206,6 +206,8 @@ public class PerformanceTestService {
|
|||
startEngine(loadTest, engine);
|
||||
|
||||
// todo:通过调用stop方法能够停止正在运行的engine,但是如果部署了多个backend实例,页面发送的停止请求如何定位到具体的engine
|
||||
|
||||
return engine.getReportId();
|
||||
}
|
||||
|
||||
private void startEngine(LoadTestWithBLOBs loadTest, Engine engine) {
|
||||
|
|
|
@ -30,10 +30,10 @@
|
|||
<performance-basic-config :test-plan="testPlan" ref="basicConfig"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('load_test.pressure_config')">
|
||||
<performance-pressure-config :test-plan="testPlan" ref="pressureConfig"/>
|
||||
<performance-pressure-config :test-plan="testPlan" :test-id="testId" ref="pressureConfig"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('load_test.advanced_config')" class="advanced-config">
|
||||
<performance-advanced-config ref="advancedConfig"/>
|
||||
<performance-advanced-config :test-id="testId" ref="advancedConfig"/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-card>
|
||||
|
@ -67,6 +67,7 @@
|
|||
runPath: "/performance/run",
|
||||
projects: [],
|
||||
active: '0',
|
||||
testId: '',
|
||||
tabs: [{
|
||||
title: this.$t('load_test.basic_config'),
|
||||
id: '0',
|
||||
|
@ -94,8 +95,9 @@
|
|||
return;
|
||||
}
|
||||
|
||||
let testId = to.path.split('/')[4]; // find testId
|
||||
let testId = to.params.testId;
|
||||
if (testId) {
|
||||
this.testId = testId;
|
||||
this.result = this.$get('/performance/get/' + testId, response => {
|
||||
if (response.data) {
|
||||
this.testPlan = response.data;
|
||||
|
@ -106,8 +108,9 @@
|
|||
|
||||
},
|
||||
created() {
|
||||
let testId = this.$route.path.split('/')[4];
|
||||
let testId = this.$route.params.testId;
|
||||
if (testId) {
|
||||
this.testId = testId;
|
||||
this.result = this.$get('/performance/get/' + testId, response => {
|
||||
this.testPlan = response.data;
|
||||
});
|
||||
|
|
|
@ -198,27 +198,23 @@
|
|||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
testId: String,
|
||||
},
|
||||
mounted() {
|
||||
let testId = this.$route.path.split('/')[4];
|
||||
if (testId) {
|
||||
this.getAdvancedConfig(testId);
|
||||
if (this.testId) {
|
||||
this.getAdvancedConfig();
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'$route'(to) {
|
||||
if (to.name !== 'createPerTest' && to.name !== 'editPerTest') {
|
||||
return;
|
||||
}
|
||||
let testId = to.path.split('/')[4];
|
||||
if (testId) {
|
||||
this.getAdvancedConfig(testId);
|
||||
testId () {
|
||||
if (this.testId) {
|
||||
this.getAdvancedConfig();
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getAdvancedConfig(testId) {
|
||||
this.$get('/performance/get-advanced-config/' + testId, (response) => {
|
||||
getAdvancedConfig() {
|
||||
this.$get('/performance/get-advanced-config/' + this.testId, (response) => {
|
||||
if (response.data) {
|
||||
let data = JSON.parse(response.data);
|
||||
this.timeout = data.timeout || 10;
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
|
||||
export default {
|
||||
name: "PerformancePressureConfig",
|
||||
props: ['testPlan'],
|
||||
props: ['testPlan','testId'],
|
||||
data() {
|
||||
return {
|
||||
result: {},
|
||||
|
@ -123,9 +123,8 @@
|
|||
}
|
||||
},
|
||||
mounted() {
|
||||
let testId = this.$route.path.split('/')[4];
|
||||
if (testId) {
|
||||
this.getLoadConfig(testId);
|
||||
if (this.testId) {
|
||||
this.getLoadConfig();
|
||||
} else {
|
||||
this.calculateChart();
|
||||
}
|
||||
|
@ -133,20 +132,16 @@
|
|||
this.getResourcePools();
|
||||
},
|
||||
watch: {
|
||||
'$route'(to) {
|
||||
if (to.name !== 'createPerTest' && to.name !== 'editPerTest') {
|
||||
return;
|
||||
}
|
||||
let testId = to.path.split('/')[4];
|
||||
if (testId) {
|
||||
this.getLoadConfig(testId);
|
||||
testPlan(n) {
|
||||
this.resourcePool = n.testResourcePoolId;
|
||||
},
|
||||
testId () {
|
||||
if (this.testId) {
|
||||
this.getLoadConfig();
|
||||
} else {
|
||||
this.calculateChart();
|
||||
}
|
||||
},
|
||||
testPlan(n) {
|
||||
this.resourcePool = n.testResourcePoolId;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getResourcePools() {
|
||||
|
@ -158,10 +153,10 @@
|
|||
}
|
||||
})
|
||||
},
|
||||
getLoadConfig(testId) {
|
||||
if (testId) {
|
||||
getLoadConfig() {
|
||||
if (this.testId) {
|
||||
|
||||
this.$get('/performance/get-load-config/' + testId, (response) => {
|
||||
this.$get('/performance/get-load-config/' + this.testId, (response) => {
|
||||
if (response.data) {
|
||||
let data = JSON.parse(response.data);
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
@click="handleNext()"/>
|
||||
<el-divider direction="vertical"></el-divider>
|
||||
|
||||
<el-button type="primary" size="mini" @click="saveCase(false)">{{$t('test_track.save')}}</el-button>
|
||||
<el-button type="primary" size="mini" @click="saveCase()">{{$t('test_track.save')}}</el-button>
|
||||
</el-col>
|
||||
|
||||
</el-row>
|
||||
|
@ -87,14 +87,14 @@
|
|||
|
||||
<el-row v-if="testCase.method == 'auto' && testCase.testId">
|
||||
<el-col class="test-detail" :span="20" :offset="1">
|
||||
<el-tabs type="border-card">
|
||||
<el-tab-pane :label="$t('test_track.plan_view.test_detail')">
|
||||
<api-test-detail v-if="testCase.type == 'api'" @runTest="apiTestRun" :id="testCase.testId" ref="apiTestDetail"/>
|
||||
<performance-test-detail v-if="testCase.type == 'performance'" :id="testCase.testId" ref="performanceTestDetail"/>
|
||||
<el-tabs v-model="activeTab" type="border-card" @tab-click="testTabChange">
|
||||
<el-tab-pane name="detail" :label="$t('test_track.plan_view.test_detail')">
|
||||
<api-test-detail v-if="testCase.type == 'api'" @runTest="testRun" :id="testCase.testId" ref="apiTestDetail"/>
|
||||
<performance-test-detail v-if="testCase.type == 'performance'" @runTest="testRun" :id="testCase.testId" ref="performanceTestDetail"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('test_track.plan_view.test_result')">
|
||||
<el-tab-pane name="result" :label="$t('test_track.plan_view.test_result')">
|
||||
<api-test-result :report-id="testCase.reportId" v-if=" testCase.type == 'api'" ref="apiTestResult"/>
|
||||
<performance-test-result :report-id="testCase.reportId" v-if="testCase.type == 'performance'"/>
|
||||
<performance-test-result :report-id="testCase.reportId" v-if="testCase.type == 'performance'" ref="performanceTestResult"/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-col>
|
||||
|
@ -220,7 +220,8 @@
|
|||
index: 0,
|
||||
testCases: [],
|
||||
editor: ClassicEditor,
|
||||
test: {}
|
||||
test: {},
|
||||
activeTab: 'detail'
|
||||
};
|
||||
},
|
||||
props: {
|
||||
|
@ -312,6 +313,7 @@
|
|||
},
|
||||
openTestCaseEdit(testCase) {
|
||||
this.showDialog = true;
|
||||
this.activeTab = 'detail';
|
||||
this.listenGoBack();
|
||||
this.initData(testCase);
|
||||
},
|
||||
|
@ -326,10 +328,17 @@
|
|||
}
|
||||
});
|
||||
},
|
||||
apiTestRun(reportId) {
|
||||
testRun(reportId) {
|
||||
this.testCase.reportId = reportId;
|
||||
this.saveReport(reportId);
|
||||
},
|
||||
testTabChange(data) {
|
||||
if (this.testCase.type == 'performance' && data.paneName == 'result') {
|
||||
console.log(data);
|
||||
this.$refs.performanceTestResult.checkReportStatus();
|
||||
}
|
||||
// console.log(data);
|
||||
},
|
||||
saveReport(reportId) {
|
||||
this.$post('/test/plan/case/edit', {id: this.testCase.id, reportId: reportId});
|
||||
},
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
<performance-basic-config :test-plan="test" ref="basicConfig"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('load_test.pressure_config')">
|
||||
<performance-pressure-config :test-plan="test" ref="pressureConfig"/>
|
||||
<performance-pressure-config :test-plan="test" :test-id="id" ref="pressureConfig"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('load_test.advanced_config')" class="advanced-config">
|
||||
<performance-advanced-config ref="advancedConfig"/>
|
||||
<performance-advanced-config :test-id="id" ref="advancedConfig"/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-card>
|
||||
|
@ -93,8 +93,9 @@
|
|||
}
|
||||
},
|
||||
runTest() {
|
||||
this.result = this.$post(this.runPath, {id: this.test.id}, () => {
|
||||
this.result = this.$post(this.runPath, {id: this.test.id}, (response) => {
|
||||
this.$success(this.$t('load_test.is_running'));
|
||||
this.$emit('runTest', response.data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,6 +92,14 @@
|
|||
}
|
||||
},
|
||||
props: ['reportId'],
|
||||
mounted() {
|
||||
this.init();
|
||||
},
|
||||
watch: {
|
||||
reportId() {
|
||||
this.init();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initBreadcrumb() {
|
||||
if (this.reportId) {
|
||||
|
@ -124,8 +132,11 @@
|
|||
})
|
||||
}
|
||||
},
|
||||
checkReportStatus(status) {
|
||||
switch (status) {
|
||||
checkReportStatus() {
|
||||
if (!this.report) {
|
||||
return;
|
||||
}
|
||||
switch (this.report.status) {
|
||||
case 'Error':
|
||||
this.$warning(this.$t('report.generation_error'));
|
||||
break;
|
||||
|
@ -148,61 +159,58 @@
|
|||
this.endTime = '0';
|
||||
this.minutes = '0';
|
||||
this.seconds = '0';
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.result = this.$get("/performance/report/" + this.reportId, res => {
|
||||
let data = res.data;
|
||||
this.status = data.status;
|
||||
this.$set(this.report, "id", this.reportId);
|
||||
this.$set(this.report, "status", data.status);
|
||||
this.checkReportStatus(data.status);
|
||||
if (this.status === "Completed") {
|
||||
this.initReportTimeInfo();
|
||||
}
|
||||
});
|
||||
this.initBreadcrumb();
|
||||
},
|
||||
init() {
|
||||
this.getReport();
|
||||
this.getReportView();
|
||||
},
|
||||
getReportView() {
|
||||
if (this.reportId) {
|
||||
this.$get("/performance/report/test/pro/info/" + this.reportId, response => {
|
||||
let data = response.data;
|
||||
if (data) {
|
||||
this.status = data.status;
|
||||
this.reportName = data.name;
|
||||
this.testName = data.testName;
|
||||
this.projectName = data.projectName;
|
||||
|
||||
},
|
||||
watch: {
|
||||
'$route'(to) {
|
||||
if (to.name === "perReportView") {
|
||||
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.projectName = data.projectName;
|
||||
this.$set(this.report, "id", this.reportId);
|
||||
this.$set(this.report, "status", data.status);
|
||||
|
||||
this.$set(this.report, "id", reportId);
|
||||
this.$set(this.report, "status", data.status);
|
||||
|
||||
this.checkReportStatus(data.status);
|
||||
if (this.status === "Completed") {
|
||||
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();
|
||||
})
|
||||
} else {
|
||||
// this.checkReportStatus(data.status);
|
||||
if (this.status === "Completed") {
|
||||
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();
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.clearData();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
getReport() {
|
||||
this.result = this.$get("/performance/report/" + this.reportId, res => {
|
||||
let data = res.data;
|
||||
this.status = data.status;
|
||||
this.$set(this.report, "id", this.reportId);
|
||||
this.$set(this.report, "status", data.status);
|
||||
// this.checkReportStatus(data.status);
|
||||
if (this.status === "Completed") {
|
||||
this.initReportTimeInfo();
|
||||
}
|
||||
});
|
||||
this.initBreadcrumb();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue