fix(测试计划): 测试计划报告的通过率执行率精度改为小数点后2位
【【富国基金】测试计划报告通过率的计算,希望保留两位小数,不用四舍五入。】 https://www.tapd.cn/55049933/prong/stories/view/1155049933001012667
This commit is contained in:
parent
3822c100ac
commit
fef7e26254
|
@ -1,16 +1,16 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-loading="result.loading" v-if="threadGroups.length > 0" class="pressure-config-container">
|
<div v-loading="result.loading" v-if="loadIsOver" class="pressure-config-container">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-form :inline="true" :disabled="isReadOnly">
|
<el-form :inline="true" :disabled="isReadOnly">
|
||||||
<el-form-item :label="$t('load_test.select_resource_pool')">
|
<el-form-item :label="$t('load_test.select_resource_pool')">
|
||||||
<el-select v-model="resourcePool" size="mini" @change="resourcePoolChange">
|
<el-select v-model="resourcePool" size="mini" @change="resourcePoolChange">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in resourcePools"
|
v-for="item in resourcePools"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:label="item.name"
|
:label="item.name"
|
||||||
:disabled="!item.performance"
|
:disabled="!item.performance"
|
||||||
:value="item.id">
|
:value="item.id">
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -81,10 +81,10 @@
|
||||||
<el-form-item :label="$t('load_test.on_sample_error')">
|
<el-form-item :label="$t('load_test.on_sample_error')">
|
||||||
<el-select v-model="threadGroup.onSampleError" size="mini">
|
<el-select v-model="threadGroup.onSampleError" size="mini">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in onSampleErrors"
|
v-for="item in onSampleErrors"
|
||||||
:key="item.value"
|
:key="item.value"
|
||||||
:label="item.label"
|
:label="item.label"
|
||||||
:value="item.value">
|
:value="item.value">
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -213,10 +213,10 @@
|
||||||
<el-select v-model="threadGroup.resourceNodeIndex" @change="specifyNodeChange(threadGroup)"
|
<el-select v-model="threadGroup.resourceNodeIndex" @change="specifyNodeChange(threadGroup)"
|
||||||
size="mini">
|
size="mini">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="(node, index) in resourceNodes"
|
v-for="(node, index) in resourceNodes"
|
||||||
:key="node.ip"
|
:key="node.ip"
|
||||||
:label="node.ip"
|
:label="node.ip"
|
||||||
:value="index">
|
:value="index">
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -283,7 +283,7 @@ const RATIOS = "ratios";
|
||||||
|
|
||||||
const hexToRgb = function (hex) {
|
const hexToRgb = function (hex) {
|
||||||
return 'rgb(' + parseInt('0x' + hex.slice(1, 3)) + ',' + parseInt('0x' + hex.slice(3, 5))
|
return 'rgb(' + parseInt('0x' + hex.slice(1, 3)) + ',' + parseInt('0x' + hex.slice(3, 5))
|
||||||
+ ',' + parseInt('0x' + hex.slice(5, 7)) + ')';
|
+ ',' + parseInt('0x' + hex.slice(5, 7)) + ')';
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -320,6 +320,7 @@ export default {
|
||||||
step: 0,
|
step: 0,
|
||||||
rpsLimit: 0,
|
rpsLimit: 0,
|
||||||
rpsLimitEnable: false,
|
rpsLimitEnable: false,
|
||||||
|
loadIsOver: true,
|
||||||
options: {},
|
options: {},
|
||||||
resourcePool: null,
|
resourcePool: null,
|
||||||
setPoolNull: false,
|
setPoolNull: false,
|
||||||
|
@ -397,136 +398,138 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
getResourcePools() {
|
getResourcePools() {
|
||||||
getResourcePools(this.isShare)
|
getResourcePools(this.isShare)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.resourcePools = response.data;
|
this.resourcePools = response.data;
|
||||||
// 如果当前的资源池无效 设置 null
|
// 如果当前的资源池无效 设置 null
|
||||||
if (this.resourcePool) {
|
if (this.resourcePool) {
|
||||||
if (response.data.filter(p => p.id === this.resourcePool && p.performance).length === 0) {
|
if (response.data.filter(p => p.id === this.resourcePool && p.performance).length === 0) {
|
||||||
this.resourcePool = null;
|
this.resourcePool = null;
|
||||||
// 标记因资源池无效而将资源池ID置为null
|
// 标记因资源池无效而将资源池ID置为null
|
||||||
this.setPoolNull = true;
|
this.setPoolNull = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.resourcePoolChange();
|
this.resourcePoolChange();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getLoadConfig() {
|
getLoadConfig() {
|
||||||
getLoadConfig(this.testId, this.reportId, this.isShare)
|
getLoadConfig(this.testId, this.reportId, this.isShare)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
let data = JSON.parse(response.data);
|
let data = JSON.parse(response.data);
|
||||||
for (let i = 0; i < this.threadGroups.length; i++) {
|
this.loadIsOver = false;
|
||||||
data[i].forEach(item => {
|
for (let i = 0; i < this.threadGroups.length; i++) {
|
||||||
switch (item.key) {
|
data[i].forEach(item => {
|
||||||
case TARGET_LEVEL:
|
switch (item.key) {
|
||||||
this.threadGroups[i].threadNumber = item.value;
|
case TARGET_LEVEL:
|
||||||
break;
|
this.threadGroups[i].threadNumber = item.value;
|
||||||
case RAMP_UP:
|
break;
|
||||||
this.threadGroups[i].rampUpTime = item.value;
|
case RAMP_UP:
|
||||||
break;
|
this.threadGroups[i].rampUpTime = item.value;
|
||||||
case ITERATE_RAMP_UP:
|
break;
|
||||||
this.threadGroups[i].iterateRampUp = item.value;
|
case ITERATE_RAMP_UP:
|
||||||
break;
|
this.threadGroups[i].iterateRampUp = item.value;
|
||||||
case DURATION:
|
break;
|
||||||
this.threadGroups[i].duration = item.value;
|
case DURATION:
|
||||||
break;
|
this.threadGroups[i].duration = item.value;
|
||||||
case DURATION_HOURS:
|
break;
|
||||||
this.threadGroups[i].durationHours = item.value;
|
case DURATION_HOURS:
|
||||||
break;
|
this.threadGroups[i].durationHours = item.value;
|
||||||
case DURATION_MINUTES:
|
break;
|
||||||
this.threadGroups[i].durationMinutes = item.value;
|
case DURATION_MINUTES:
|
||||||
break;
|
this.threadGroups[i].durationMinutes = item.value;
|
||||||
case DURATION_SECONDS:
|
break;
|
||||||
this.threadGroups[i].durationSeconds = item.value;
|
case DURATION_SECONDS:
|
||||||
break;
|
this.threadGroups[i].durationSeconds = item.value;
|
||||||
case UNIT:
|
break;
|
||||||
this.threadGroups[i].unit = item.value;
|
case UNIT:
|
||||||
break;
|
this.threadGroups[i].unit = item.value;
|
||||||
case STEPS:
|
break;
|
||||||
this.threadGroups[i].step = item.value;
|
case STEPS:
|
||||||
break;
|
this.threadGroups[i].step = item.value;
|
||||||
case RPS_LIMIT:
|
break;
|
||||||
this.threadGroups[i].rpsLimit = item.value;
|
case RPS_LIMIT:
|
||||||
break;
|
this.threadGroups[i].rpsLimit = item.value;
|
||||||
case RPS_LIMIT_ENABLE:
|
break;
|
||||||
this.threadGroups[i].rpsLimitEnable = item.value;
|
case RPS_LIMIT_ENABLE:
|
||||||
break;
|
this.threadGroups[i].rpsLimitEnable = item.value;
|
||||||
case THREAD_TYPE:
|
break;
|
||||||
this.threadGroups[i].threadType = item.value;
|
case THREAD_TYPE:
|
||||||
break;
|
this.threadGroups[i].threadType = item.value;
|
||||||
case ITERATE_NUM:
|
break;
|
||||||
this.threadGroups[i].iterateNum = item.value;
|
case ITERATE_NUM:
|
||||||
break;
|
this.threadGroups[i].iterateNum = item.value;
|
||||||
case ENABLED:
|
break;
|
||||||
this.threadGroups[i].enabled = item.value;
|
case ENABLED:
|
||||||
break;
|
this.threadGroups[i].enabled = item.value;
|
||||||
case DELETED:
|
break;
|
||||||
this.threadGroups[i].deleted = item.value;
|
case DELETED:
|
||||||
break;
|
this.threadGroups[i].deleted = item.value;
|
||||||
case HANDLER:
|
break;
|
||||||
this.threadGroups[i].handler = item.value;
|
case HANDLER:
|
||||||
break;
|
this.threadGroups[i].handler = item.value;
|
||||||
case THREAD_GROUP_TYPE:
|
break;
|
||||||
this.threadGroups[i].tgType = item.value;
|
case THREAD_GROUP_TYPE:
|
||||||
break;
|
this.threadGroups[i].tgType = item.value;
|
||||||
case ON_SAMPLE_ERROR:
|
break;
|
||||||
this.threadGroups[i].onSampleError = item.value;
|
case ON_SAMPLE_ERROR:
|
||||||
break;
|
this.threadGroups[i].onSampleError = item.value;
|
||||||
case STRATEGY:
|
break;
|
||||||
this.threadGroups[i].strategy = item.value;
|
case STRATEGY:
|
||||||
break;
|
this.threadGroups[i].strategy = item.value;
|
||||||
case RESOURCE_NODE_INDEX:
|
break;
|
||||||
this.threadGroups[i].resourceNodeIndex = item.value;
|
case RESOURCE_NODE_INDEX:
|
||||||
break;
|
this.threadGroups[i].resourceNodeIndex = item.value;
|
||||||
case RATIOS:
|
break;
|
||||||
this.threadGroups[i].ratios = item.value;
|
case RATIOS:
|
||||||
break;
|
this.threadGroups[i].ratios = item.value;
|
||||||
case SERIALIZE_THREAD_GROUPS:
|
break;
|
||||||
this.serializeThreadGroups = item.value;// 所有的线程组值一样
|
case SERIALIZE_THREAD_GROUPS:
|
||||||
break;
|
this.serializeThreadGroups = item.value;// 所有的线程组值一样
|
||||||
case AUTO_STOP:
|
break;
|
||||||
this.autoStop = item.value;// 所有的线程组值一样
|
case AUTO_STOP:
|
||||||
break;
|
this.autoStop = item.value;// 所有的线程组值一样
|
||||||
case AUTO_STOP_DELAY:
|
break;
|
||||||
this.autoStopDelay = item.value;// 所有的线程组值一样
|
case AUTO_STOP_DELAY:
|
||||||
break;
|
this.autoStopDelay = item.value;// 所有的线程组值一样
|
||||||
default:
|
break;
|
||||||
break;
|
default:
|
||||||
}
|
break;
|
||||||
//
|
}
|
||||||
this.$set(this.threadGroups[i], "unit", this.threadGroups[i].unit || 'S');
|
//
|
||||||
this.$set(this.threadGroups[i], "threadType", this.threadGroups[i].threadType || 'DURATION');
|
this.$set(this.threadGroups[i], "unit", this.threadGroups[i].unit || 'S');
|
||||||
this.$set(this.threadGroups[i], "iterateNum", this.threadGroups[i].iterateNum || 1);
|
this.$set(this.threadGroups[i], "threadType", this.threadGroups[i].threadType || 'DURATION');
|
||||||
this.$set(this.threadGroups[i], "iterateRampUp", this.threadGroups[i].iterateRampUp || 10);
|
this.$set(this.threadGroups[i], "iterateNum", this.threadGroups[i].iterateNum || 1);
|
||||||
this.$set(this.threadGroups[i], "enabled", this.threadGroups[i].enabled || 'true');
|
this.$set(this.threadGroups[i], "iterateRampUp", this.threadGroups[i].iterateRampUp || 10);
|
||||||
this.$set(this.threadGroups[i], "deleted", this.threadGroups[i].deleted || 'false');
|
this.$set(this.threadGroups[i], "enabled", this.threadGroups[i].enabled || 'true');
|
||||||
this.$set(this.threadGroups[i], "onSampleError", this.threadGroups[i].onSampleError || 'continue');
|
this.$set(this.threadGroups[i], "deleted", this.threadGroups[i].deleted || 'false');
|
||||||
});
|
this.$set(this.threadGroups[i], "onSampleError", this.threadGroups[i].onSampleError || 'continue');
|
||||||
}
|
});
|
||||||
for (let i = 0; i < this.threadGroups.length; i++) {
|
}
|
||||||
let tg = this.threadGroups[i];
|
for (let i = 0; i < this.threadGroups.length; i++) {
|
||||||
tg.durationHours = Math.floor(tg.duration / 3600);
|
let tg = this.threadGroups[i];
|
||||||
tg.durationMinutes = Math.floor((tg.duration / 60 % 60));
|
tg.durationHours = Math.floor(tg.duration / 3600);
|
||||||
tg.durationSeconds = Math.floor((tg.duration % 60));
|
tg.durationMinutes = Math.floor((tg.duration / 60 % 60));
|
||||||
}
|
tg.durationSeconds = Math.floor((tg.duration % 60));
|
||||||
this.resourcePoolChange();
|
}
|
||||||
this.calculateTotalChart();
|
this.loadIsOver = true;
|
||||||
});
|
this.resourcePoolChange();
|
||||||
|
this.calculateTotalChart();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
getJmxContent() {
|
getJmxContent() {
|
||||||
let threadGroups = [];
|
let threadGroups = [];
|
||||||
getJmxContent(this.testId, this.reportId, this.isShare)
|
getJmxContent(this.testId, this.reportId, this.isShare)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
response.data.forEach(d => {
|
response.data.forEach(d => {
|
||||||
threadGroups = threadGroups.concat(findThreadGroup(d.jmx, d.name));
|
threadGroups = threadGroups.concat(findThreadGroup(d.jmx, d.name));
|
||||||
threadGroups.forEach(tg => {
|
threadGroups.forEach(tg => {
|
||||||
tg.options = {};
|
tg.options = {};
|
||||||
});
|
|
||||||
});
|
});
|
||||||
this.threadGroups = threadGroups;
|
|
||||||
this.$emit('fileChange', threadGroups);
|
|
||||||
this.getLoadConfig();
|
|
||||||
});
|
});
|
||||||
|
this.threadGroups = threadGroups;
|
||||||
|
this.$emit('fileChange', threadGroups);
|
||||||
|
this.getLoadConfig();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
resourcePoolChange() {
|
resourcePoolChange() {
|
||||||
let result = this.resourcePools.filter(p => p.id === this.resourcePool);
|
let result = this.resourcePools.filter(p => p.id === this.resourcePool);
|
||||||
|
@ -607,8 +610,8 @@ export default {
|
||||||
let tg = handler.threadGroups[i];
|
let tg = handler.threadGroups[i];
|
||||||
|
|
||||||
if (tg.enabled === 'false' ||
|
if (tg.enabled === 'false' ||
|
||||||
tg.deleted === 'true' ||
|
tg.deleted === 'true' ||
|
||||||
tg.threadType === 'ITERATION') {
|
tg.threadType === 'ITERATION') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (this.getDuration(tg) < tg.rampUpTime) {
|
if (this.getDuration(tg) < tg.rampUpTime) {
|
||||||
|
@ -733,7 +736,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tg.threadNumber || !tg.duration
|
if (!tg.threadNumber || !tg.duration
|
||||||
|| !tg.rampUpTime || !tg.step || !tg.iterateNum) {
|
|| !tg.rampUpTime || !tg.step || !tg.iterateNum) {
|
||||||
this.$warning(this.$t('load_test.pressure_config_params_is_empty'));
|
this.$warning(this.$t('load_test.pressure_config_params_is_empty'));
|
||||||
this.$emit('changeActive', '1');
|
this.$emit('changeActive', '1');
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -80,6 +80,7 @@ import java.io.InputStreamReader;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
@ -1750,15 +1751,29 @@ public class TestPlanService {
|
||||||
}
|
}
|
||||||
issuesService.calculateReportByIssueList(testPlanCaseReportResultDTO.getIssueList(), report);
|
issuesService.calculateReportByIssueList(testPlanCaseReportResultDTO.getIssueList(), report);
|
||||||
|
|
||||||
|
DecimalFormat rateFormat = new DecimalFormat("#0.00");
|
||||||
|
rateFormat.setMinimumFractionDigits(2);
|
||||||
|
rateFormat.setMaximumFractionDigits(2);
|
||||||
|
|
||||||
if (report.getExecuteCount() != 0 && report.getCaseCount() != null) {
|
if (report.getExecuteCount() != 0 && report.getCaseCount() != null) {
|
||||||
report.setExecuteRate(report.getExecuteCount() * 0.1 * 10 / report.getCaseCount());
|
double executeRate = Double.parseDouble(rateFormat.format((double) report.getExecuteCount() / (double) report.getCaseCount()));
|
||||||
|
if (executeRate == 1 && report.getExecuteCount() < report.getCaseCount()) {
|
||||||
|
report.setExecuteRate(0.99);
|
||||||
|
} else {
|
||||||
|
report.setExecuteRate(executeRate);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
report.setExecuteRate(0.0);
|
report.setExecuteRate(0.00);
|
||||||
}
|
}
|
||||||
if (report.getPassCount() != 0 && report.getCaseCount() != null) {
|
if (report.getPassCount() != 0 && report.getCaseCount() != null) {
|
||||||
report.setPassRate(report.getPassCount() * 0.1 * 10 / report.getCaseCount());
|
double passRate = Double.parseDouble(rateFormat.format((double) report.getPassCount() / (double) report.getCaseCount()));
|
||||||
|
if (passRate == 1 && report.getPassCount() < report.getCaseCount()) {
|
||||||
|
report.setPassRate(0.99);
|
||||||
|
} else {
|
||||||
|
report.setPassRate(passRate);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
report.setPassRate(0.0);
|
report.setPassRate(0.00);
|
||||||
}
|
}
|
||||||
|
|
||||||
report.setName(testPlan.getName());
|
report.setName(testPlan.getName());
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
{{ resourcePool }}
|
{{ resourcePool }}
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8"> </el-col>
|
<el-col :span="8"></el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row
|
<el-row
|
||||||
class="select-time"
|
class="select-time"
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
:label="$t('test_track.report.executive_finish_rate') + ':'"
|
:label="$t('test_track.report.executive_finish_rate') + ':'"
|
||||||
>
|
>
|
||||||
{{
|
{{
|
||||||
(report.executeRate ? (report.executeRate * 100).toFixed(1) : 0) +
|
(report.executeRate ? (report.executeRate * 100).toFixed(2) : 0) +
|
||||||
"%"
|
"%"
|
||||||
}}
|
}}
|
||||||
<ms-instructions-icon
|
<ms-instructions-icon
|
||||||
|
@ -81,7 +81,7 @@
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-form-item :label="$t('test_track.report.passing_rate') + ':'">
|
<el-form-item :label="$t('test_track.report.passing_rate') + ':'">
|
||||||
{{
|
{{
|
||||||
(report.passRate ? (report.passRate * 100).toFixed(1) : 0) + "%"
|
(report.passRate ? (report.passRate * 100).toFixed(2) : 0) + "%"
|
||||||
}}
|
}}
|
||||||
<ms-instructions-icon
|
<ms-instructions-icon
|
||||||
:content="$t('test_track.report.passing_rate_tip')"
|
:content="$t('test_track.report.passing_rate_tip')"
|
||||||
|
@ -98,7 +98,7 @@ import MsFormDivider from "metersphere-frontend/src/components/MsFormDivider";
|
||||||
import TestPlanReportContainer from "@/business/plan/view/comonents/report/detail/TestPlanReportContainer";
|
import TestPlanReportContainer from "@/business/plan/view/comonents/report/detail/TestPlanReportContainer";
|
||||||
import MsInstructionsIcon from "metersphere-frontend/src/components/MsInstructionsIcon";
|
import MsInstructionsIcon from "metersphere-frontend/src/components/MsInstructionsIcon";
|
||||||
import MsTag from "metersphere-frontend/src/components/MsTag";
|
import MsTag from "metersphere-frontend/src/components/MsTag";
|
||||||
import { datetimeFormat } from "fit2cloud-ui/src/filters/time";
|
import {datetimeFormat} from "fit2cloud-ui/src/filters/time";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "TestPlanOverviewReport",
|
name: "TestPlanOverviewReport",
|
||||||
|
|
Loading…
Reference in New Issue