From 827dac097aee94ef1058fe63656506f97688cc17 Mon Sep 17 00:00:00 2001 From: Coooder-X <55648333+Coooder-X@users.noreply.github.com> Date: Tue, 26 Jan 2021 13:07:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=EF=BC=88=E6=B5=8B=E8=AF=95=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=B1=A0=EF=BC=89=E5=A2=9E=E5=8A=A0=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=B1=A0=E4=B8=AD=E7=AB=AF=E5=8F=A3=E9=87=8D=E5=A4=8D=E5=88=A4?= =?UTF-8?q?=E6=96=AD=20(#1260)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/NodeResourcePoolService.java | 15 ++++++++++++++- .../main/resources/i18n/messages_en_US.properties | 2 ++ .../main/resources/i18n/messages_zh_CN.properties | 2 ++ .../main/resources/i18n/messages_zh_TW.properties | 2 ++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/io/metersphere/service/NodeResourcePoolService.java b/backend/src/main/java/io/metersphere/service/NodeResourcePoolService.java index b22c00f9c2..fc16e3c70c 100644 --- a/backend/src/main/java/io/metersphere/service/NodeResourcePoolService.java +++ b/backend/src/main/java/io/metersphere/service/NodeResourcePoolService.java @@ -46,9 +46,22 @@ public class NodeResourcePoolService { }) .distinct() .collect(Collectors.toList()); - if (nodeIps.size() < testResourcePool.getResources().size()) { + List nodePorts = testResourcePool.getResources().stream() + .map(resource -> { + NodeDTO nodeDTO = JSON.parseObject(resource.getConfiguration(), NodeDTO.class); + return nodeDTO.getPort(); + }) + .distinct() + .collect(Collectors.toList()); + if (nodeIps.size() < testResourcePool.getResources().size() && nodePorts.size() < testResourcePool.getResources().size()) { + MSException.throwException(Translator.get("duplicate_node_ip_port")); + } + else if (nodeIps.size() < testResourcePool.getResources().size()) { MSException.throwException(Translator.get("duplicate_node_ip")); } + else if (nodePorts.size() < testResourcePool.getResources().size()) { + MSException.throwException(Translator.get("duplicate_node_port")); + } testResourcePool.setStatus(VALID.name()); boolean isValid = true; for (TestResource resource : testResourcePool.getResources()) { diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 63a9f26f1e..3ac43e7a11 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -43,6 +43,8 @@ test_not_running=Test is not running load_test_already_exists=Duplicate load test name no_nodes_message=No node message duplicate_node_ip=Duplicate IPs +duplicate_node_port=Duplicate Ports +duplicate_node_ip_port=Duplicate IPs & Ports max_thread_insufficient=The number of concurrent users exceeds related_case_del_fail_prefix=Connected to related_case_del_fail_suffix=TestCase, please disassociate first diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index d42e0b0162..87c7dd1353 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -43,6 +43,8 @@ test_not_running=测试未运行 load_test_already_exists=测试名称不能重复 no_nodes_message=没有节点信息 duplicate_node_ip=节点 IP 重复 +duplicate_node_port=节点 Port 重复 +duplicate_node_ip_port=节点 IP、Port 重复 max_thread_insufficient=并发用户数超额 related_case_del_fail_prefix=已关联到 related_case_del_fail_suffix=测试用例,请先解除关联 diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 5c2666354b..4e9f9ffff4 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -43,6 +43,8 @@ test_not_running=測試未運行 load_test_already_exists=測試名稱不能重復 no_nodes_message=沒有節點信息 duplicate_node_ip=節點 IP 重復 +duplicate_node_port=節點 Port 重復 +duplicate_node_ip_port=節點 IP、Port 重復 max_thread_insufficient=並發用戶數超額 related_case_del_fail_prefix=已關聯到 related_case_del_fail_suffix=測試用例,請先解除關聯