From baf7d61a70a9dea852664ae75c79ba4231caa9f9 Mon Sep 17 00:00:00 2001 From: nkorange Date: Wed, 5 Dec 2018 15:16:43 +0800 Subject: [PATCH] #388 Add test case. --- .../test/naming/SelectInstances_ITCase.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/src/test/java/com/alibaba/nacos/test/naming/SelectInstances_ITCase.java b/test/src/test/java/com/alibaba/nacos/test/naming/SelectInstances_ITCase.java index 77b5b526f..2d8e8f26b 100644 --- a/test/src/test/java/com/alibaba/nacos/test/naming/SelectInstances_ITCase.java +++ b/test/src/test/java/com/alibaba/nacos/test/naming/SelectInstances_ITCase.java @@ -190,6 +190,29 @@ public class SelectInstances_ITCase { Assert.assertTrue(verifyInstanceList(instances, instancesGet)); } + @Test + public void selectInstancesCheckClusterName() throws Exception { + + String serviceName = randomDomainName(); + naming.registerInstance(serviceName, "1.1.1.1", TEST_PORT, "c1"); + naming.registerInstance(serviceName, "1.1.1.2", TEST_PORT, "c2"); + + TimeUnit.SECONDS.sleep(8); + + List instancesGet = naming.getAllInstances(serviceName); + + Assert.assertEquals(2, instancesGet.size()); + + for (Instance instance : instancesGet) { + if (instance.getIp().equals("1.1.1.1")) { + Assert.assertEquals(instance.getClusterName(), "c1"); + } + if (instance.getIp().equals("2.2.2.2")) { + Assert.assertEquals(instance.getClusterName(), "c2"); + } + } + } + /** * 获取权重不为0的Instance