Skip to content

Commit

Permalink
[ISSUE alibaba#243]fix Integration testing too long
Browse files Browse the repository at this point in the history
  • Loading branch information
mingyixu committed Dec 5, 2018
1 parent 0a1d949 commit e15e902
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 34 deletions.
2 changes: 2 additions & 0 deletions test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
<version>2.9</version>
<configuration>
<argLine>-Dnacos.standalone=true</argLine>
<parallel>methods</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
@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;

Expand Down Expand Up @@ -148,7 +148,7 @@ public void nacos_getconfig_4() throws Exception {
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);
Expand Down Expand Up @@ -232,7 +232,7 @@ public void nacos_publishConfig_4() throws Exception {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
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;
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -66,11 +67,9 @@ public void init() throws Exception {
* @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");
Expand All @@ -86,8 +85,8 @@ public void autoDregDomClustersTest() throws Exception {

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());
Expand All @@ -97,7 +96,6 @@ public void autoDregDomClustersTest() throws Exception {

instances = naming.getAllInstances(serviceName, Arrays.asList("c1"));
Assert.assertEquals(0, instances.size());

}


Expand All @@ -107,11 +105,9 @@ public void autoDregDomClustersTest() throws Exception {
* @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);
Expand All @@ -127,8 +123,8 @@ public void autoDregDomTest() throws Exception {

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());
Expand All @@ -144,7 +140,6 @@ public void autoDregDomTest() throws Exception {
*/
@Test
public void autoRegDomTest() throws Exception {

String serviceName = randomDomainName();

naming.registerInstance(serviceName, "127.0.0.1", TEST_PORT);
Expand All @@ -161,7 +156,8 @@ public void autoRegDomTest() throws Exception {

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);

Expand All @@ -172,13 +168,11 @@ public void autoRegDomTest() throws Exception {
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);


}


Expand Down Expand Up @@ -206,7 +200,8 @@ public void autoRegDomClustersTest() throws Exception {

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);

Expand All @@ -219,7 +214,8 @@ public void autoRegDomClustersTest() throws Exception {


namingServiceImpl.getBeatReactor().addBeatInfo(serviceName, beatInfo);
TimeUnit.SECONDS.sleep(15);
//TimeUnit.SECONDS.sleep(15);
verifyInstanceList(instances, 2, serviceName);

instances = naming.getAllInstances(serviceName);

Expand All @@ -234,4 +230,17 @@ public void autoRegDomClustersTest() throws Exception {

}

public void verifyInstanceList(List<Instance> 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++;
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -65,7 +65,6 @@ public void init() throws Exception {
*/
@Test
public void dregDomTest() throws Exception {

String serviceName = randomDomainName();

naming.registerInstance(serviceName, "127.0.0.1", TEST_PORT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -212,7 +212,7 @@ public void onEvent(Event event) {
int i = 0;
while (instances.isEmpty()) {
Thread.sleep(1000L);
if (i++ > 20) {
if (i++ > 10) {
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -98,7 +98,7 @@ public void onEvent(Event event) {
int i = 0;
while (instances.isEmpty()) {
Thread.sleep(1000L);
if (i++ > 20) {
if (i++ > 10) {
return;
}
}
Expand Down Expand Up @@ -141,7 +141,7 @@ public void onEvent(Event event) {
int i = 0;
while (instances.isEmpty()) {
Thread.sleep(1000L);
if (i++ > 20) {
if (i++ > 10) {
return;
}
}
Expand Down

0 comments on commit e15e902

Please sign in to comment.