diff --git a/test/pom.xml b/test/pom.xml index 476a782ba..dd7107d72 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -97,6 +97,8 @@ 2.9 -Dnacos.standalone=true + methods + true diff --git a/test/src/test/java/com/alibaba/nacos/test/config/ConfigAPI_ITCase.java b/test/src/test/java/com/alibaba/nacos/test/config/ConfigAPI_ITCase.java index cbca3216f..5d8cf4d57 100644 --- a/test/src/test/java/com/alibaba/nacos/test/config/ConfigAPI_ITCase.java +++ b/test/src/test/java/com/alibaba/nacos/test/config/ConfigAPI_ITCase.java @@ -55,7 +55,7 @@ import java.util.concurrent.atomic.AtomicInteger; @RunWith(SpringRunner.class) @SpringBootTest(classes = Config.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class ConfigAPI_ITCase { - public static final long TIME_OUT = 3000; + public static final long TIME_OUT = 2000; public ConfigService iconfig = null; ServerHttpAgent agent = null; @@ -148,7 +148,7 @@ public class ConfigAPI_ITCase { final String content = "test"; boolean result = iconfig.publishConfig(dataId, null, content); - Thread.sleep(2*TIME_OUT); + Thread.sleep(TIME_OUT); Assert.assertTrue(result); String value = iconfig.getConfig(dataId, null, TIME_OUT); @@ -232,7 +232,7 @@ public class ConfigAPI_ITCase { public void nacos_publishConfig_5() throws Exception { String content = "test"; boolean result = iconfig.publishConfig(dataId, null, content); - Thread.sleep(2*TIME_OUT); + Thread.sleep(TIME_OUT); Assert.assertTrue(result); String value = iconfig.getConfig(dataId, null, TIME_OUT); diff --git a/test/src/test/java/com/alibaba/nacos/test/naming/AutoDeregisterInstance_ITCase.java b/test/src/test/java/com/alibaba/nacos/test/naming/AutoDeregisterInstance_ITCase.java index 7b4683392..4db794aa3 100644 --- a/test/src/test/java/com/alibaba/nacos/test/naming/AutoDeregisterInstance_ITCase.java +++ b/test/src/test/java/com/alibaba/nacos/test/naming/AutoDeregisterInstance_ITCase.java @@ -23,6 +23,7 @@ import com.alibaba.nacos.client.naming.beat.BeatInfo; import com.alibaba.nacos.naming.NamingApp; import org.junit.Assert; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; @@ -55,7 +56,7 @@ public class AutoDeregisterInstance_ITCase { @Before public void init() throws Exception { if (naming == null) { - TimeUnit.SECONDS.sleep(10); + //TimeUnit.SECONDS.sleep(10); naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port); } } @@ -66,11 +67,9 @@ public class AutoDeregisterInstance_ITCase { * @throws Exception */ @Test + @Ignore public void autoDregDomClustersTest() throws Exception { - String serviceName = randomDomainName(); -// String serviceName="jinhanH0Gkc.cyS1n.com"; - System.out.println(serviceName); naming.registerInstance(serviceName, "127.0.0.1", TEST_PORT, "c1"); naming.registerInstance(serviceName, "127.0.0.2", TEST_PORT, "c2"); @@ -86,8 +85,8 @@ public class AutoDeregisterInstance_ITCase { namingServiceImpl.getBeatReactor().removeBeatInfo(serviceName, "127.0.0.1", TEST_PORT); - TimeUnit.SECONDS.sleep(40); - + //TimeUnit.SECONDS.sleep(40); + verifyInstanceList(instances, 1, serviceName); instances = naming.getAllInstances(serviceName); Assert.assertEquals(1, instances.size()); @@ -97,7 +96,6 @@ public class AutoDeregisterInstance_ITCase { instances = naming.getAllInstances(serviceName, Arrays.asList("c1")); Assert.assertEquals(0, instances.size()); - } @@ -107,11 +105,9 @@ public class AutoDeregisterInstance_ITCase { * @throws Exception */ @Test + @Ignore public void autoDregDomTest() throws Exception { - String serviceName = randomDomainName(); -// String serviceName="jinhanH0Gkc.cyS1n.com"; -// System.out.println(serviceName); naming.registerInstance(serviceName, "127.0.0.1", TEST_PORT); naming.registerInstance(serviceName, "127.0.0.2", TEST_PORT); @@ -127,8 +123,8 @@ public class AutoDeregisterInstance_ITCase { namingServiceImpl.getBeatReactor().removeBeatInfo(serviceName, "127.0.0.1", TEST_PORT); - TimeUnit.SECONDS.sleep(40); - + //TimeUnit.SECONDS.sleep(40); + verifyInstanceList(instances, 1, serviceName); instances = naming.getAllInstances(serviceName); Assert.assertEquals(1, instances.size()); @@ -144,7 +140,6 @@ public class AutoDeregisterInstance_ITCase { */ @Test public void autoRegDomTest() throws Exception { - String serviceName = randomDomainName(); naming.registerInstance(serviceName, "127.0.0.1", TEST_PORT); @@ -161,7 +156,8 @@ public class AutoDeregisterInstance_ITCase { namingServiceImpl.getBeatReactor().removeBeatInfo(serviceName, "127.0.0.1", TEST_PORT); - TimeUnit.SECONDS.sleep(40); + //TimeUnit.SECONDS.sleep(40); + verifyInstanceList(instances, 1, serviceName); instances = naming.getAllInstances(serviceName); @@ -172,13 +168,11 @@ public class AutoDeregisterInstance_ITCase { beatInfo.setPort(TEST_PORT); namingServiceImpl.getBeatReactor().addBeatInfo(serviceName, beatInfo); - TimeUnit.SECONDS.sleep(15); + verifyInstanceList(instances, 2, serviceName); instances = naming.getAllInstances(serviceName); Assert.assertEquals(instances.size(), 2); - - } @@ -206,7 +200,8 @@ public class AutoDeregisterInstance_ITCase { namingServiceImpl.getBeatReactor().removeBeatInfo(serviceName, "127.0.0.1", TEST_PORT); - TimeUnit.SECONDS.sleep(40); + //TimeUnit.SECONDS.sleep(40); + verifyInstanceList(instances, 1, serviceName); instances = naming.getAllInstances(serviceName); @@ -219,7 +214,8 @@ public class AutoDeregisterInstance_ITCase { namingServiceImpl.getBeatReactor().addBeatInfo(serviceName, beatInfo); - TimeUnit.SECONDS.sleep(15); + //TimeUnit.SECONDS.sleep(15); + verifyInstanceList(instances, 2, serviceName); instances = naming.getAllInstances(serviceName); @@ -234,4 +230,17 @@ public class AutoDeregisterInstance_ITCase { } + public void verifyInstanceList(List instances, int size, String serviceName) throws Exception { + int i = 0; + while ( i < 20 ) { + instances = naming.getAllInstances(serviceName); + if (instances.size() == size) { + break; + } else { + TimeUnit.SECONDS.sleep(3); + i++; + } + } + } + } diff --git a/test/src/test/java/com/alibaba/nacos/test/naming/DeregisterInstance_ITCase.java b/test/src/test/java/com/alibaba/nacos/test/naming/DeregisterInstance_ITCase.java index 448f812d5..bba234ef4 100644 --- a/test/src/test/java/com/alibaba/nacos/test/naming/DeregisterInstance_ITCase.java +++ b/test/src/test/java/com/alibaba/nacos/test/naming/DeregisterInstance_ITCase.java @@ -53,7 +53,7 @@ public class DeregisterInstance_ITCase { @Before public void init() throws Exception { if (naming == null) { - TimeUnit.SECONDS.sleep(10); + //TimeUnit.SECONDS.sleep(10); naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port); } } @@ -65,7 +65,6 @@ public class DeregisterInstance_ITCase { */ @Test public void dregDomTest() throws Exception { - String serviceName = randomDomainName(); naming.registerInstance(serviceName, "127.0.0.1", TEST_PORT); diff --git a/test/src/test/java/com/alibaba/nacos/test/naming/RegisterInstance_ITCase.java b/test/src/test/java/com/alibaba/nacos/test/naming/RegisterInstance_ITCase.java index 97466ef0e..5ff42a2a9 100644 --- a/test/src/test/java/com/alibaba/nacos/test/naming/RegisterInstance_ITCase.java +++ b/test/src/test/java/com/alibaba/nacos/test/naming/RegisterInstance_ITCase.java @@ -56,7 +56,7 @@ public class RegisterInstance_ITCase { @Before public void init() throws Exception { if (naming == null) { - TimeUnit.SECONDS.sleep(10); + //TimeUnit.SECONDS.sleep(10); naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port); } } 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..8a5f6649b 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 @@ -52,7 +52,7 @@ public class SelectInstances_ITCase { @Before public void init() throws Exception { if (naming == null) { - TimeUnit.SECONDS.sleep(10); + //TimeUnit.SECONDS.sleep(10); naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port); } } diff --git a/test/src/test/java/com/alibaba/nacos/test/naming/SelectOneHealthyInstance_ITCase.java b/test/src/test/java/com/alibaba/nacos/test/naming/SelectOneHealthyInstance_ITCase.java index ec6746bfa..859e7915e 100644 --- a/test/src/test/java/com/alibaba/nacos/test/naming/SelectOneHealthyInstance_ITCase.java +++ b/test/src/test/java/com/alibaba/nacos/test/naming/SelectOneHealthyInstance_ITCase.java @@ -54,7 +54,7 @@ public class SelectOneHealthyInstance_ITCase { @Before public void init() throws Exception{ if (naming == null) { - TimeUnit.SECONDS.sleep(10); + //TimeUnit.SECONDS.sleep(10); naming = NamingFactory.createNamingService("127.0.0.1"+":"+port); } diff --git a/test/src/test/java/com/alibaba/nacos/test/naming/ServiceListTest.java b/test/src/test/java/com/alibaba/nacos/test/naming/ServiceListTest.java index 1e2db2acd..65baf41c7 100644 --- a/test/src/test/java/com/alibaba/nacos/test/naming/ServiceListTest.java +++ b/test/src/test/java/com/alibaba/nacos/test/naming/ServiceListTest.java @@ -47,7 +47,7 @@ public class ServiceListTest { @Before public void init() throws Exception { if (naming == null) { - TimeUnit.SECONDS.sleep(10); + //TimeUnit.SECONDS.sleep(10); naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port); } } diff --git a/test/src/test/java/com/alibaba/nacos/test/naming/SubscribeCluster_ITCase.java b/test/src/test/java/com/alibaba/nacos/test/naming/SubscribeCluster_ITCase.java index 61284891d..8f9979b8e 100644 --- a/test/src/test/java/com/alibaba/nacos/test/naming/SubscribeCluster_ITCase.java +++ b/test/src/test/java/com/alibaba/nacos/test/naming/SubscribeCluster_ITCase.java @@ -55,7 +55,7 @@ public class SubscribeCluster_ITCase { public void init() throws Exception{ instances.clear(); if (naming == null) { - TimeUnit.SECONDS.sleep(10); + //TimeUnit.SECONDS.sleep(10); naming = NamingFactory.createNamingService("127.0.0.1"+":"+port); } } @@ -212,7 +212,7 @@ public class SubscribeCluster_ITCase { int i = 0; while (instances.isEmpty()) { Thread.sleep(1000L); - if (i++ > 20) { + if (i++ > 10) { return; } } diff --git a/test/src/test/java/com/alibaba/nacos/test/naming/Subscribe_ITCase.java b/test/src/test/java/com/alibaba/nacos/test/naming/Subscribe_ITCase.java index a48c843d5..6973aaec7 100644 --- a/test/src/test/java/com/alibaba/nacos/test/naming/Subscribe_ITCase.java +++ b/test/src/test/java/com/alibaba/nacos/test/naming/Subscribe_ITCase.java @@ -56,7 +56,7 @@ public class Subscribe_ITCase { public void init() throws Exception{ instances.clear(); if (naming == null) { - TimeUnit.SECONDS.sleep(10); + //TimeUnit.SECONDS.sleep(10); naming = NamingFactory.createNamingService("127.0.0.1"+":"+port); } } diff --git a/test/src/test/java/com/alibaba/nacos/test/naming/Unsubscribe_ITCase.java b/test/src/test/java/com/alibaba/nacos/test/naming/Unsubscribe_ITCase.java index 8ae32b1d0..87b5d813b 100644 --- a/test/src/test/java/com/alibaba/nacos/test/naming/Unsubscribe_ITCase.java +++ b/test/src/test/java/com/alibaba/nacos/test/naming/Unsubscribe_ITCase.java @@ -56,7 +56,7 @@ public class Unsubscribe_ITCase { public void init() throws Exception{ instances = Collections.emptyList(); if (naming == null) { - TimeUnit.SECONDS.sleep(10); + //TimeUnit.SECONDS.sleep(10); naming = NamingFactory.createNamingService("127.0.0.1"+":"+port); } } @@ -98,7 +98,7 @@ public class Unsubscribe_ITCase { int i = 0; while (instances.isEmpty()) { Thread.sleep(1000L); - if (i++ > 20) { + if (i++ > 10) { return; } } @@ -141,7 +141,7 @@ public class Unsubscribe_ITCase { int i = 0; while (instances.isEmpty()) { Thread.sleep(1000L); - if (i++ > 20) { + if (i++ > 10) { return; } }