From 7be21db324b6a8b66fcf4cc62118e1617670a4b0 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Tue, 24 Nov 2020 13:28:55 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E6=95=B0=E4=B8=8D=E8=83=BD=E5=B0=8F=E4=BA=8E?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=B1=A0=E8=8A=82=E7=82=B9=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TestResourcePoolController.java | 4 ++-- .../resourcepool/QueryResourcePoolRequest.java | 1 + .../service/TestResourcePoolService.java | 14 ++++++++------ .../test/components/PerformancePressureConfig.vue | 8 +++++++- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/backend/src/main/java/io/metersphere/controller/TestResourcePoolController.java b/backend/src/main/java/io/metersphere/controller/TestResourcePoolController.java index 48f461b56c..3088b617b8 100644 --- a/backend/src/main/java/io/metersphere/controller/TestResourcePoolController.java +++ b/backend/src/main/java/io/metersphere/controller/TestResourcePoolController.java @@ -53,13 +53,13 @@ public class TestResourcePoolController { @GetMapping("list/all/valid") @RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR) - public List listValidResourcePools() { + public List listValidResourcePools() { return testResourcePoolService.listValidResourcePools(); } @GetMapping("list/quota/valid") @RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR) - public List listValidQuotaResourcePools() { + public List listValidQuotaResourcePools() { return testResourcePoolService.listValidQuotaResourcePools(); } diff --git a/backend/src/main/java/io/metersphere/controller/request/resourcepool/QueryResourcePoolRequest.java b/backend/src/main/java/io/metersphere/controller/request/resourcepool/QueryResourcePoolRequest.java index 718622d243..cf00ed9e39 100644 --- a/backend/src/main/java/io/metersphere/controller/request/resourcepool/QueryResourcePoolRequest.java +++ b/backend/src/main/java/io/metersphere/controller/request/resourcepool/QueryResourcePoolRequest.java @@ -7,4 +7,5 @@ import lombok.Setter; @Setter public class QueryResourcePoolRequest { private String name; + private String status; } diff --git a/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java b/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java index 6f487a37dd..d43ae6759d 100644 --- a/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java +++ b/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java @@ -145,6 +145,9 @@ public class TestResourcePoolService { if (StringUtils.isNotBlank(request.getName())) { criteria.andNameLike(StringUtils.wrapIfMissing(request.getName(), "%")); } + if (StringUtils.isNotBlank(request.getStatus())) { + criteria.andStatusEqualTo(request.getStatus()); + } example.setOrderByClause("update_time desc"); List testResourcePools = testResourcePoolMapper.selectByExample(example); List testResourcePoolDTOS = new ArrayList<>(); @@ -232,7 +235,7 @@ public class TestResourcePoolService { return testResourcePoolMapper.selectByPrimaryKey(resourcePoolId); } - public List listValidResourcePools() { + public List listValidResourcePools() { QueryResourcePoolRequest request = new QueryResourcePoolRequest(); List testResourcePools = listResourcePools(request); // 重新校验 pool @@ -249,16 +252,15 @@ public class TestResourcePoolService { testResourcePoolMapper.updateByPrimaryKeySelective(pool); } } - TestResourcePoolExample example = new TestResourcePoolExample(); - example.createCriteria().andStatusEqualTo(ResourceStatusEnum.VALID.name()); - return testResourcePoolMapper.selectByExample(example); + request.setStatus(VALID.name()); + return listResourcePools(request); } - public List listValidQuotaResourcePools() { + public List listValidQuotaResourcePools() { return filterQuota(listValidResourcePools()); } - private List filterQuota(List list) { + private List filterQuota(List list) { QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class); if (quotaService != null) { Set pools = quotaService.getQuotaResourcePools(); diff --git a/frontend/src/business/components/performance/test/components/PerformancePressureConfig.vue b/frontend/src/business/components/performance/test/components/PerformancePressureConfig.vue index d94e02c8dc..7d51c4f387 100644 --- a/frontend/src/business/components/performance/test/components/PerformancePressureConfig.vue +++ b/frontend/src/business/components/performance/test/components/PerformancePressureConfig.vue @@ -30,7 +30,7 @@ :placeholder="$t('load_test.input_thread_num')" v-model="threadGroup.threadNumber" @change="calculateChart(threadGroup)" - :min="1" + :min="resourcePoolResourceLength" size="mini"/>
@@ -141,6 +141,7 @@ export default { activeNames: ["0"], threadGroups: [], serializeThreadgroups: false, + resourcePoolResourceLength: 1 } }, mounted() { @@ -368,6 +369,11 @@ export default { if (handler.rampUpTime < handler.step) { handler.step = handler.rampUpTime; } + // 线程数不能小于资源池节点的数量 + let resourcePool = this.resourcePools.filter(v => v.id === this.resourcePool)[0]; + if (resourcePool) { + this.resourcePoolResourceLength = resourcePool.resources.length; + } handler.options = { xAxis: { type: 'category',