压力配置

This commit is contained in:
Captain.B 2020-03-02 19:23:28 +08:00
parent 25426b299e
commit 2a1ac00ac8
3 changed files with 66 additions and 11 deletions

View File

@ -6,7 +6,6 @@ import io.metersphere.base.domain.FileMetadata;
import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.ProjectRequest;
import io.metersphere.controller.request.testplan.*; import io.metersphere.controller.request.testplan.*;
import io.metersphere.dto.LoadTestDTO; import io.metersphere.dto.LoadTestDTO;
import io.metersphere.service.FileService; import io.metersphere.service.FileService;
@ -74,6 +73,11 @@ public class LoadTestController {
return loadTestService.getAdvancedConfiguration(testId); return loadTestService.getAdvancedConfiguration(testId);
} }
@GetMapping("/get-load-config/{testId}")
public String getLoadConfiguration(@PathVariable String testId) {
return loadTestService.getLoadConfiguration(testId);
}
@PostMapping("/delete") @PostMapping("/delete")
public void delete(@RequestBody DeleteTestPlanRequest request) { public void delete(@RequestBody DeleteTestPlanRequest request) {
loadTestService.delete(request); loadTestService.delete(request);

View File

@ -192,4 +192,9 @@ public class LoadTestService {
LoadTestWithBLOBs loadTestWithBLOBs = loadTestMapper.selectByPrimaryKey(testId); LoadTestWithBLOBs loadTestWithBLOBs = loadTestMapper.selectByPrimaryKey(testId);
return Optional.ofNullable(loadTestWithBLOBs).orElse(new LoadTestWithBLOBs()).getAdvancedConfiguration(); return Optional.ofNullable(loadTestWithBLOBs).orElse(new LoadTestWithBLOBs()).getAdvancedConfiguration();
} }
public String getLoadConfiguration(String testId) {
LoadTestWithBLOBs loadTestWithBLOBs = loadTestMapper.selectByPrimaryKey(testId);
return Optional.ofNullable(loadTestWithBLOBs).orElse(new LoadTestWithBLOBs()).getLoadConfiguration();
}
} }

View File

@ -81,6 +81,11 @@
</template> </template>
<script> <script>
const TARGET_LEVEL = "TargetLevel";
const RAMP_UP = "RampUp";
const STEPS = "Steps";
const DURATION = "duration";
const RPS_LIMIT = "rpsLimit";
export default { export default {
name: "MsTestPlanPressureConfig", name: "MsTestPlanPressureConfig",
@ -96,16 +101,57 @@
} }
}, },
mounted() { mounted() {
this.testPlan.loadConfigurationObj = []; let testId = this.$route.path.split('/')[2];
this.calculateChart(); if (testId) {
this.convertProperty(); this.getLoadConfig(testId);
}
}, },
watch: { watch: {
testPlan() { '$route'(to) {
this.convertProperty(); let testId = to.path.split('/')[2];
if (testId) {
this.getLoadConfig(testId);
}
} }
}, },
methods: { methods: {
getLoadConfig(testId) {
this.$get('/testplan/get-load-config/' + testId, (response) => {
if (response.data) {
let data = JSON.parse(response.data);
data.forEach(d => {
switch (d.key) {
case TARGET_LEVEL:
this.threadNumber = d.value;
break;
case RAMP_UP:
this.rampUpTime = d.value;
break;
case DURATION:
this.duration = d.value;
break;
case STEPS:
this.step = d.value;
break;
case RPS_LIMIT:
this.rpsLimit = d.value;
break;
default:
break;
}
});
this.threadNumber = this.threadNumber || 10;
this.duration = this.duration || 30;
this.rampUpTime = this.rampUpTime || 12;
this.step = this.step || 3;
this.rpsLimit = this.rpsLimit || 10;
this.calculateChart();
}
});
},
calculateChart() { calculateChart() {
this.orgOptions = { this.orgOptions = {
xAxis: { xAxis: {
@ -142,11 +188,11 @@
convertProperty() { convertProperty() {
/// todo4jmeter ConcurrencyThreadGroup plugin /// todo4jmeter ConcurrencyThreadGroup plugin
return [ return [
{key: "TargetLevel", value: this.threadNumber}, {key: TARGET_LEVEL, value: this.threadNumber},
{key: "RampUp", value: this.rampUpTime}, {key: RAMP_UP, value: this.rampUpTime},
{key: "Steps", value: this.step}, {key: STEPS, value: this.step},
{key: "duration", value: this.duration}, {key: DURATION, value: this.duration},
{key: "rpsLimit", value: this.rpsLimit} {key: RPS_LIMIT, value: this.rpsLimit}
]; ];
} }
} }