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