保存测试到数据库

This commit is contained in:
haifeng414 2020-02-15 14:04:05 +08:00
parent 25cefe71df
commit de2ad1337b
6 changed files with 81 additions and 72 deletions

View File

@ -38,7 +38,7 @@ public class LoadTestController {
@PostMapping("/save") @PostMapping("/save")
public void save(@RequestBody SaveTestPlanRequest request) { public void save(@RequestBody SaveTestPlanRequest request) {
System.out.println(String.format("save test plan: %s", request.getName())); loadTestService.save(request);
} }
@PostMapping("/delete") @PostMapping("/delete")

View File

@ -3,7 +3,7 @@ package io.metersphere.controller.request.testplan;
public class TestPlanRequest { public class TestPlanRequest {
private String id; private String id;
private String fileId; private String fileId;
private String project; private String projectId;
private String name; private String name;
@ -23,12 +23,12 @@ public class TestPlanRequest {
this.fileId = fileId; this.fileId = fileId;
} }
public String getProject() { public String getProjectId() {
return project; return projectId;
} }
public void setProject(String project) { public void setProjectId(String projectId) {
this.project = project; this.projectId = projectId;
} }
public String getName() { public String getName() {

View File

@ -7,6 +7,7 @@ import io.metersphere.base.mapper.ProjectMapper;
import io.metersphere.base.mapper.ext.ExtLoadTestMapper; import io.metersphere.base.mapper.ext.ExtLoadTestMapper;
import io.metersphere.controller.request.testplan.DeleteTestPlanRequest; import io.metersphere.controller.request.testplan.DeleteTestPlanRequest;
import io.metersphere.controller.request.testplan.QueryTestPlanRequest; import io.metersphere.controller.request.testplan.QueryTestPlanRequest;
import io.metersphere.controller.request.testplan.SaveTestPlanRequest;
import io.metersphere.dto.LoadTestDTO; import io.metersphere.dto.LoadTestDTO;
import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.RandomUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -61,4 +62,16 @@ public class LoadTestService {
loadTestMapper.deleteByExample(loadTestExample); loadTestMapper.deleteByExample(loadTestExample);
} }
public void save(SaveTestPlanRequest request) {
final LoadTestWithBLOBs loadTest = new LoadTestWithBLOBs();
loadTest.setId(UUID.randomUUID().toString());
loadTest.setName(request.getName());
loadTest.setProjectId(request.getProjectId());
loadTest.setCreateTime(System.currentTimeMillis());
loadTest.setUpdateTime(System.currentTimeMillis());
loadTest.setScenarioDefinition("todo");
loadTest.setDescription("todo");
loadTestMapper.insert(loadTest);
}
} }

View File

@ -19,7 +19,9 @@
"vue-i18n": "^8.15.3", "vue-i18n": "^8.15.3",
"vue-router": "^3.1.3", "vue-router": "^3.1.3",
"vuex": "^3.1.2", "vuex": "^3.1.2",
"js-cookie": "^2.2.0" "js-cookie": "^2.2.0",
"v-charts": "^1.19.0",
"echarts": "^4.1.0"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "^4.1.0", "@vue/cli-plugin-babel": "^4.1.0",

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="testplan-container"> <div class="edit-testplan-container">
<el-row> <el-row>
<el-col :span="10"> <el-col :span="10">
<el-input placeholder="请输入名称" v-model="testPlan.name" class="input-with-select"> <el-input placeholder="请输入名称" v-model="testPlan.name" class="input-with-select">
@ -8,7 +8,7 @@
v-for="item in projects" v-for="item in projects"
:key="item.id" :key="item.id"
:label="item.name" :label="item.name"
:value="item.name"> :value="item.id">
</el-option> </el-option>
</el-select> </el-select>
</el-input> </el-input>
@ -125,7 +125,7 @@
return false; return false;
} }
if (!this.testPlan.project) { if (!this.testPlan.projectId) {
this.$message({ this.$message({
message: '项目不能为空!', message: '项目不能为空!',
type: 'error' type: 'error'
@ -151,16 +151,16 @@
</script> </script>
<style> <style>
.testplan-container .el-tabs__nav { .edit-testplan-container .el-tabs__nav {
float: none; float: none;
text-align: center; text-align: center;
} }
.testplan-container .el-select .el-input { .edit-testplan-container .el-select .el-input {
width: 130px; width: 130px;
} }
.testplan-container .input-with-select .el-input-group__prepend { .edit-testplan-container .input-with-select .el-input-group__prepend {
background-color: #fff; background-color: #fff;
} }
</style> </style>

View File

@ -1,63 +1,38 @@
<template> <template>
<el-row> <div class="pressure-config-container">
<el-col :span="8"> <el-row type="flex">
<div> <div class="small-input">
<el-row> <span>线程数</span>
<el-col :span="12"> <el-input
<div> type="number"
并发用户 placeholder="请输入线程数"
<el-input v-model="threadNumber"
type="number" show-word-limit
placeholder="请输入线程数" >
v-model="threadNumber" </el-input>
show-word-limit
>
</el-input>
</div>
</el-col>
<el-col :span="12">
<div>
压测时长
<el-input
type="number"
placeholder="请输入时长min"
v-model="duration"
show-word-limit
>
</el-input>
</div>
</el-col>
</el-row>
<el-row>
<div>
<div style="width: 80px;">
<el-input
type="number"
v-model="rampUpTime"
show-word-limit
>
</el-input>
</div>
分钟内
<div style="width: 80px;">
<el-input
type="number"
v-model="rampUpCount"
show-word-limit
>
</el-input>
</div>
次增加并发用户
</div>
</el-row>
</div> </div>
</el-col> <div class="small-input">
<el-col :span="16"> <span>压测时长分钟</span>
压力预估图 <el-input
type="number"
</el-col> placeholder="请输入时长"
</el-row> v-model="duration"
show-word-limit
>
</el-input>
</div>
<div class="small-input">
<span>Ramp-Up时间</span>
<el-input
type="number"
placeholder="请输入时间"
v-model="rampUpTime"
show-word-limit
>
</el-input>
</div>
</el-row>
</div>
</template> </template>
<script> <script>
@ -68,8 +43,21 @@
threadNumber: 10, threadNumber: 10,
duration: 10, duration: 10,
rampUpTime: 5, rampUpTime: 5,
rampUpCount: 2, chartData: {
columns: ['压测时长(分钟)', '并发量'],
rows: [
{'压测时长(分钟)': '1月1日', '并发量': 123},
{'压测时长(分钟)': '1月2日', '并发量': 1223},
{'压测时长(分钟)': '1月3日', '并发量': 2123},
{'压测时长(分钟)': '1月4日', '并发量': 4123},
{'压测时长(分钟)': '1月5日', '并发量': 3123},
{'压测时长(分钟)': '1月6日', '并发量': 7123}
]
},
} }
},
beforeCreate() {
}, },
methods: { methods: {
testChange() { testChange() {
@ -83,3 +71,9 @@
} }
} }
</script> </script>
<style>
.pressure-config-container .small-input {
width: 150px;
}
</style>