压力配置

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

View File

@ -192,4 +192,9 @@ public class LoadTestService {
LoadTestWithBLOBs loadTestWithBLOBs = loadTestMapper.selectByPrimaryKey(testId);
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>
<script>
const TARGET_LEVEL = "TargetLevel";
const RAMP_UP = "RampUp";
const STEPS = "Steps";
const DURATION = "duration";
const RPS_LIMIT = "rpsLimit";
export default {
name: "MsTestPlanPressureConfig",
@ -96,16 +101,57 @@
}
},
mounted() {
this.testPlan.loadConfigurationObj = [];
this.calculateChart();
this.convertProperty();
let testId = this.$route.path.split('/')[2];
if (testId) {
this.getLoadConfig(testId);
}
},
watch: {
testPlan() {
this.convertProperty();
'$route'(to) {
let testId = to.path.split('/')[2];
if (testId) {
this.getLoadConfig(testId);
}
}
},
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() {
this.orgOptions = {
xAxis: {
@ -142,11 +188,11 @@
convertProperty() {
/// todo4jmeter ConcurrencyThreadGroup plugin
return [
{key: "TargetLevel", value: this.threadNumber},
{key: "RampUp", value: this.rampUpTime},
{key: "Steps", value: this.step},
{key: "duration", value: this.duration},
{key: "rpsLimit", value: this.rpsLimit}
{key: TARGET_LEVEL, value: this.threadNumber},
{key: RAMP_UP, value: this.rampUpTime},
{key: STEPS, value: this.step},
{key: DURATION, value: this.duration},
{key: RPS_LIMIT, value: this.rpsLimit}
];
}
}