diff --git a/backend/src/main/java/io/metersphere/controller/TestResourcePoolController.java b/backend/src/main/java/io/metersphere/controller/TestResourcePoolController.java index aa1a600df7..656764ee60 100644 --- a/backend/src/main/java/io/metersphere/controller/TestResourcePoolController.java +++ b/backend/src/main/java/io/metersphere/controller/TestResourcePoolController.java @@ -39,4 +39,13 @@ public class TestResourcePoolController { Page page = PageHelper.startPage(goPage, pageSize, true); return PageUtils.setPageInfo(page, testResourcePoolService.listResourcePools(request)); } + + @GetMapping("list/all") + public List listResourcePools() { + PageHelper.startPage(1, 10000, true); + QueryResourcePoolRequest request = new QueryResourcePoolRequest(); + return testResourcePoolService.listResourcePools(request); + } + + } diff --git a/backend/src/main/java/io/metersphere/engine/kubernetes/KubernetesTestEngine.java b/backend/src/main/java/io/metersphere/engine/kubernetes/KubernetesTestEngine.java index 25a5bb4e76..19d3fdfb08 100644 --- a/backend/src/main/java/io/metersphere/engine/kubernetes/KubernetesTestEngine.java +++ b/backend/src/main/java/io/metersphere/engine/kubernetes/KubernetesTestEngine.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; import io.fabric8.kubernetes.api.model.ConfigMap; import io.fabric8.kubernetes.api.model.ObjectMeta; import io.fabric8.kubernetes.client.KubernetesClient; +import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.LogUtil; import io.metersphere.engine.Engine; 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.provider.ClientCredential; import io.metersphere.engine.kubernetes.provider.KubernetesProvider; +import io.metersphere.service.TestResourcePoolService; import org.apache.commons.collections.MapUtils; +import org.junit.Test; import java.util.HashMap; public class KubernetesTestEngine implements Engine { private EngineContext context; + private TestResourcePoolService testResourcePoolService; @Override public boolean init(EngineContext context) { // todo 初始化操作 this.context = context; + this.testResourcePoolService = CommonBeanFactory.getBean(TestResourcePoolService.class); return true; } diff --git a/frontend/src/business/components/performance/plan/EditPerformanceTestPlan.vue b/frontend/src/business/components/performance/plan/EditPerformanceTestPlan.vue index 7acff005c6..8fd3f95ed8 100644 --- a/frontend/src/business/components/performance/plan/EditPerformanceTestPlan.vue +++ b/frontend/src/business/components/performance/plan/EditPerformanceTestPlan.vue @@ -207,6 +207,10 @@ return false; } + if (!this.$refs.pressureConfig.validConfig()) { + return false; + } + if (!this.$refs.advancedConfig.validConfig()) { return false; } diff --git a/frontend/src/business/components/performance/plan/components/PerformancePressureConfig.vue b/frontend/src/business/components/performance/plan/components/PerformancePressureConfig.vue index 729bff360a..8ae77b7b3a 100644 --- a/frontend/src/business/components/performance/plan/components/PerformancePressureConfig.vue +++ b/frontend/src/business/components/performance/plan/components/PerformancePressureConfig.vue @@ -73,6 +73,21 @@
{{$t('load_test.ramp_up_time_times')}}
+ + +
{{$t('load_test.select_resource_pool')}}
+
+ + + + + + +
@@ -89,6 +104,7 @@ const STEPS = "Steps"; const DURATION = "duration"; const RPS_LIMIT = "rpsLimit"; + const RESOURCE_POOL = "resourcePoolId"; export default { name: "PerformancePressureConfig", @@ -101,6 +117,8 @@ step: 10, rpsLimit: 10, orgOptions: {}, + resourcePool: null, + resourcePools: [], } }, mounted() { @@ -110,6 +128,8 @@ } else { this.calculateChart(); } + + this.getResourcePools(); }, watch: { '$route'(to, from) { @@ -125,11 +145,16 @@ } }, methods: { + getResourcePools() { + this.$get('/testresourcepool/list/all', response => { + this.resourcePools = response.data; + }) + }, getLoadConfig(testId) { if (testId) { this.$get('/testplan/get-load-config/' + testId, (response) => { - if (response.data && response.data != "") { + if (response.data) { let data = JSON.parse(response.data); data.forEach(d => { @@ -149,6 +174,9 @@ case RPS_LIMIT: this.rpsLimit = d.value; break; + case RESOURCE_POOL: + this.resourcePool = d.value; + break; default: 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() { /// todo:下面4个属性是jmeter ConcurrencyThreadGroup plugin的属性,这种硬编码不太好吧,在哪能转换这种属性? return [ @@ -259,7 +298,8 @@ {key: RAMP_UP, value: this.rampUpTime}, {key: STEPS, value: this.step}, {key: DURATION, value: this.duration}, - {key: RPS_LIMIT, value: this.rpsLimit} + {key: RPS_LIMIT, value: this.rpsLimit}, + {key: RESOURCE_POOL, value: this.resourcePool}, ]; } } diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 21c3f0b398..07c4eef4c0 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -158,6 +158,8 @@ export default { 'custom_http_code': 'Custom HTTP response success status code', 'separated_by_commas': 'Separated by commas', 'create': 'Create Test', + 'select_resource_pool': 'Please Select Resource Pool', + 'resource_pool_is_null': 'Resource Pool is empty', }, fuc_test: { 'select_resource_pool': 'Please select resource pool' diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index f6d08028c3..ce36711187 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -158,6 +158,8 @@ export default { 'custom_http_code': '自定义 HTTP 响应成功状态码', 'separated_by_commas': '按逗号分隔', 'create': '创建测试', + 'select_resource_pool': '请选择资源池', + 'resource_pool_is_null': '资源池为空', }, fuc_test: { 'select_resource_pool': '请选择资源池'