配置资源池

This commit is contained in:
Captain.B 2020-03-23 17:11:07 +08:00
parent ca66c782d8
commit 8652b0566d
6 changed files with 64 additions and 2 deletions

View File

@ -39,4 +39,13 @@ public class TestResourcePoolController {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true); Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testResourcePoolService.listResourcePools(request)); return PageUtils.setPageInfo(page, testResourcePoolService.listResourcePools(request));
} }
@GetMapping("list/all")
public List<TestResourcePool> listResourcePools() {
PageHelper.startPage(1, 10000, true);
QueryResourcePoolRequest request = new QueryResourcePoolRequest();
return testResourcePoolService.listResourcePools(request);
}
} }

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import io.fabric8.kubernetes.api.model.ConfigMap; import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.ObjectMeta; import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.KubernetesClient;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
import io.metersphere.engine.Engine; import io.metersphere.engine.Engine;
import io.metersphere.engine.EngineContext; import io.metersphere.engine.EngineContext;
@ -11,17 +12,21 @@ import io.metersphere.engine.kubernetes.crds.jmeter.Jmeter;
import io.metersphere.engine.kubernetes.crds.jmeter.JmeterSpec; import io.metersphere.engine.kubernetes.crds.jmeter.JmeterSpec;
import io.metersphere.engine.kubernetes.provider.ClientCredential; import io.metersphere.engine.kubernetes.provider.ClientCredential;
import io.metersphere.engine.kubernetes.provider.KubernetesProvider; import io.metersphere.engine.kubernetes.provider.KubernetesProvider;
import io.metersphere.service.TestResourcePoolService;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.junit.Test;
import java.util.HashMap; import java.util.HashMap;
public class KubernetesTestEngine implements Engine { public class KubernetesTestEngine implements Engine {
private EngineContext context; private EngineContext context;
private TestResourcePoolService testResourcePoolService;
@Override @Override
public boolean init(EngineContext context) { public boolean init(EngineContext context) {
// todo 初始化操作 // todo 初始化操作
this.context = context; this.context = context;
this.testResourcePoolService = CommonBeanFactory.getBean(TestResourcePoolService.class);
return true; return true;
} }

View File

@ -207,6 +207,10 @@
return false; return false;
} }
if (!this.$refs.pressureConfig.validConfig()) {
return false;
}
if (!this.$refs.advancedConfig.validConfig()) { if (!this.$refs.advancedConfig.validConfig()) {
return false; return false;
} }

View File

@ -73,6 +73,21 @@
<div>{{$t('load_test.ramp_up_time_times')}}</div> <div>{{$t('load_test.ramp_up_time_times')}}</div>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-form :inline="true" class="input-bottom-border">
<el-form-item>
<div>{{$t('load_test.select_resource_pool')}}</div>
</el-form-item>
<el-form-item>
<el-select v-model="resourcePool" size="mini">
<el-option
v-for="item in resourcePools"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-form>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<chart class="chart-container" ref="chart1" :options="orgOptions" :autoresize="true"></chart> <chart class="chart-container" ref="chart1" :options="orgOptions" :autoresize="true"></chart>
@ -89,6 +104,7 @@
const STEPS = "Steps"; const STEPS = "Steps";
const DURATION = "duration"; const DURATION = "duration";
const RPS_LIMIT = "rpsLimit"; const RPS_LIMIT = "rpsLimit";
const RESOURCE_POOL = "resourcePoolId";
export default { export default {
name: "PerformancePressureConfig", name: "PerformancePressureConfig",
@ -101,6 +117,8 @@
step: 10, step: 10,
rpsLimit: 10, rpsLimit: 10,
orgOptions: {}, orgOptions: {},
resourcePool: null,
resourcePools: [],
} }
}, },
mounted() { mounted() {
@ -110,6 +128,8 @@
} else { } else {
this.calculateChart(); this.calculateChart();
} }
this.getResourcePools();
}, },
watch: { watch: {
'$route'(to, from) { '$route'(to, from) {
@ -125,11 +145,16 @@
} }
}, },
methods: { methods: {
getResourcePools() {
this.$get('/testresourcepool/list/all', response => {
this.resourcePools = response.data;
})
},
getLoadConfig(testId) { getLoadConfig(testId) {
if (testId) { if (testId) {
this.$get('/testplan/get-load-config/' + testId, (response) => { this.$get('/testplan/get-load-config/' + testId, (response) => {
if (response.data && response.data != "") { if (response.data) {
let data = JSON.parse(response.data); let data = JSON.parse(response.data);
data.forEach(d => { data.forEach(d => {
@ -149,6 +174,9 @@
case RPS_LIMIT: case RPS_LIMIT:
this.rpsLimit = d.value; this.rpsLimit = d.value;
break; break;
case RESOURCE_POOL:
this.resourcePool = d.value;
break;
default: default:
break; break;
} }
@ -252,6 +280,17 @@
} }
} }
}, },
validConfig() {
if (!this.resourcePool) {
this.$message({
message: this.$t('load_test.resource_pool_is_null'),
type: 'warning'
});
return false;
}
return true;
},
convertProperty() { convertProperty() {
/// todo4jmeter ConcurrencyThreadGroup plugin /// todo4jmeter ConcurrencyThreadGroup plugin
return [ return [
@ -259,7 +298,8 @@
{key: RAMP_UP, 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: RPS_LIMIT, value: this.rpsLimit} {key: RPS_LIMIT, value: this.rpsLimit},
{key: RESOURCE_POOL, value: this.resourcePool},
]; ];
} }
} }

View File

@ -158,6 +158,8 @@ export default {
'custom_http_code': 'Custom HTTP response success status code', 'custom_http_code': 'Custom HTTP response success status code',
'separated_by_commas': 'Separated by commas', 'separated_by_commas': 'Separated by commas',
'create': 'Create Test', 'create': 'Create Test',
'select_resource_pool': 'Please Select Resource Pool',
'resource_pool_is_null': 'Resource Pool is empty',
}, },
fuc_test: { fuc_test: {
'select_resource_pool': 'Please select resource pool' 'select_resource_pool': 'Please select resource pool'

View File

@ -158,6 +158,8 @@ export default {
'custom_http_code': '自定义 HTTP 响应成功状态码', 'custom_http_code': '自定义 HTTP 响应成功状态码',
'separated_by_commas': '按逗号分隔', 'separated_by_commas': '按逗号分隔',
'create': '创建测试', 'create': '创建测试',
'select_resource_pool': '请选择资源池',
'resource_pool_is_null': '资源池为空',
}, },
fuc_test: { fuc_test: {
'select_resource_pool': '请选择资源池' 'select_resource_pool': '请选择资源池'