Skip to content

Commit

Permalink
add cache for travis, fix ut for stable (#2501)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrick-zhu authored Sep 13, 2018
1 parent a0c1bef commit 2881738
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 33 deletions.
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ jdk:

cache:
directories:
- '$HOME/.m2/repository'
- $HOME/.m2

install:
- ./mvnw clean install -DskipTests=true -Dcheckstyle.skip=false -Drat.skip=false -Dmaven.javadoc.skip=true
install: true

script:
- travis_wait 30 ./mvnw test
- travis_wait 30 ./mvnw clean install -DskipTests=false -Dcheckstyle.skip=false -Drat.skip=false -Dmaven.javadoc.skip=true

after_success:
- bash <(curl -s https://codecov.io/bash)
- bash <(curl -s https://codecov.io/bash)
Original file line number Diff line number Diff line change
Expand Up @@ -90,35 +90,35 @@ public void testParseFromParameter() {

@Test
public void testParseUrl2() {
String address = "127.0.0.1";
String backupAddress1 = "127.0.0.2";
String backupAddress2 = "127.0.0.3";
String address = "192.168.0.1";
String backupAddress1 = "192.168.0.2";
String backupAddress2 = "192.168.0.3";

Map<String, String> parameters = new HashMap<String, String>();
parameters.put("username", "root");
parameters.put("password", "alibaba");
parameters.put("port", "10000");
parameters.put("protocol", "dubbo");
URL url = UrlUtils.parseURL(address + "," + backupAddress1 + "," + backupAddress2, parameters);
assertEquals(localAddress + ":10000", url.getAddress());
assertEquals("192.168.0.1:10000", url.getAddress());
assertEquals("root", url.getUsername());
assertEquals("alibaba", url.getPassword());
assertEquals(10000, url.getPort());
assertEquals("dubbo", url.getProtocol());
assertEquals("127.0.0.2" + "," + "127.0.0.3", url.getParameter("backup"));
assertEquals("192.168.0.2" + "," + "192.168.0.3", url.getParameter("backup"));
}

@Test
public void testParseUrls() {
String addresses = "127.0.0.1|127.0.0.2|127.0.0.3";
String addresses = "192.168.0.1|192.168.0.2|192.168.0.3";
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("username", "root");
parameters.put("password", "alibaba");
parameters.put("port", "10000");
parameters.put("protocol", "dubbo");
List<URL> urls = UrlUtils.parseURLs(addresses, parameters);
assertEquals(localAddress + ":10000", urls.get(0).getAddress());
assertEquals("127.0.0.2" + ":10000", urls.get(1).getAddress());
assertEquals("192.168.0.1" + ":10000", urls.get(0).getAddress());
assertEquals("192.168.0.2" + ":10000", urls.get(1).getAddress());
}

@Test
Expand Down Expand Up @@ -322,7 +322,7 @@ public void testIsItemMatch() throws Exception {

@Test
public void testIsServiceKeyMatch() throws Exception {
URL url = URL.valueOf("test://127.0.0.0");
URL url = URL.valueOf("test://127.0.0.1");
URL pattern = url.addParameter(Constants.GROUP_KEY, "test")
.addParameter(Constants.INTERFACE_KEY, "test")
.addParameter(Constants.VERSION_KEY, "test");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void testGenericServiceException() {
ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>();
reference.setApplication(new ApplicationConfig("generic-consumer"));
reference.setInterface(DemoService.class);
reference.setUrl("dubbo://127.0.0.1:29581?generic=true");
reference.setUrl("dubbo://127.0.0.1:29581?generic=true&timeout=3000");
DemoService demoService = reference.get();
try {
// say name
Expand Down Expand Up @@ -113,7 +113,7 @@ public void testGenericReferenceException() {
ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>();
reference.setApplication(new ApplicationConfig("generic-consumer"));
reference.setInterface(DemoService.class);
reference.setUrl("dubbo://127.0.0.1:29581?scope=remote");
reference.setUrl("dubbo://127.0.0.1:29581?scope=remote&timeout=3000");
reference.setGeneric(true);
GenericService genericService = reference.get();
try {
Expand Down Expand Up @@ -147,7 +147,7 @@ public void testGenericSerializationJava() throws Exception {
ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>();
reference.setApplication(new ApplicationConfig("generic-consumer"));
reference.setInterface(DemoService.class);
reference.setUrl("dubbo://127.0.0.1:29581?scope=remote");
reference.setUrl("dubbo://127.0.0.1:29581?scope=remote&timeout=3000");
reference.setGeneric(Constants.GENERIC_SERIALIZATION_NATIVE_JAVA);
GenericService genericService = reference.get();
try {
Expand Down Expand Up @@ -216,7 +216,7 @@ public void testGenericInvokeWithBeanSerialization() throws Exception {
reference = new ReferenceConfig<GenericService>();
reference.setApplication(new ApplicationConfig("bean-consumer"));
reference.setInterface(DemoService.class);
reference.setUrl("dubbo://127.0.0.1:29581?scope=remote");
reference.setUrl("dubbo://127.0.0.1:29581?scope=remote&timeout=3000");
reference.setGeneric(Constants.GENERIC_SERIALIZATION_BEAN);
GenericService genericService = reference.get();
User user = new User();
Expand Down Expand Up @@ -270,7 +270,7 @@ public void testGenericImplementationWithBeanSerialization() throws Exception {
ref = new ReferenceConfig<DemoService>();
ref.setApplication(new ApplicationConfig("bean-consumer"));
ref.setInterface(DemoService.class);
ref.setUrl("dubbo://127.0.0.1:29581?scope=remote&generic=bean");
ref.setUrl("dubbo://127.0.0.1:29581?scope=remote&generic=bean&timeout=3000");
DemoService demoService = ref.get();
User user = new User();
user.setName("zhangsan");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ private void testCache(String type) throws Exception {
ServiceConfig<CacheService> service = new ServiceConfig<CacheService>();
service.setApplication(new ApplicationConfig("cache-provider"));
service.setRegistry(new RegistryConfig("N/A"));
service.setProtocol(new ProtocolConfig("dubbo", 29582));
service.setProtocol(new ProtocolConfig("injvm"));
service.setInterface(CacheService.class.getName());
service.setRef(new CacheServiceImpl());
service.export();
try {
ReferenceConfig<CacheService> reference = new ReferenceConfig<CacheService>();
reference.setApplication(new ApplicationConfig("cache-consumer"));
reference.setInterface(CacheService.class);
reference.setUrl("dubbo://127.0.0.1:29582?scope=remote&cache=true");
reference.setUrl("injvm://127.0.0.1?scope=remote&cache=true");

MethodConfig method = new MethodConfig();
method.setName("findCache");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void testServiceClass() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/service-class.xml");
ctx.start();
try {
DemoService demoService = refer("dubbo://127.0.0.1:20887");
DemoService demoService = refer("dubbo://127.0.0.1:30887");
String hello = demoService.sayName("hello");
assertEquals("welcome:hello", hello);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected ExchangeServer newServer(int port, Replier<?> receiver) throws Remotin
}

protected ExchangeChannel newClient(int port) throws RemotingException {
return Exchangers.connect(URL.valueOf("exchange://localhost:" + port + "?client=netty"));
return Exchangers.connect(URL.valueOf("exchange://localhost:" + port + "?client=netty&timeout=3000"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void testReconnect() throws RemotingException, InterruptedException {


public Client startClient(int port, int reconnectPeriod) throws RemotingException {
final String url = "exchange://127.0.0.1:" + port + "/client.reconnect.test?client=netty4&check=false&" + Constants.RECONNECT_KEY + "=" + reconnectPeriod;
final String url = "exchange://127.0.0.1:" + port + "/client.reconnect.test?timeout=3000&client=netty4&check=false&" + Constants.RECONNECT_KEY + "=" + reconnectPeriod;
return Exchangers.connect(url);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService;
import com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils;

import org.junit.After;
import org.junit.Before;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
Expand All @@ -41,20 +41,20 @@
public class PortTelnetHandlerTest {

private static TelnetHandler port = new PortTelnetHandler();
private Invoker<DemoService> mockInvoker;
private static Invoker<DemoService> mockInvoker;

@SuppressWarnings("unchecked")
@Before
public void before() {
@BeforeClass
public static void before() {
mockInvoker = mock(Invoker.class);
given(mockInvoker.getInterface()).willReturn(DemoService.class);
given(mockInvoker.getUrl()).willReturn(URL.valueOf("dubbo://127.0.0.1:20887/demo"));

DubboProtocol.getDubboProtocol().export(mockInvoker);
}

@After
public void after() {
@AfterClass
public static void after() {
ProtocolUtils.closeAll();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ public class WebserviceProtocolTest {
public void testDemoProtocol() throws Exception {
DemoService service = new DemoServiceImpl();
protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName() + "?codec=exchange")));
service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName() + "?codec=exchange")));
service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName() + "?codec=exchange&timeout=3000")));
assertEquals(service.getSize(new String[]{"", "", ""}), 3);
}

@Test
public void testWebserviceProtocol() throws Exception {
DemoService service = new DemoServiceImpl();
protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName())));
service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName())));
service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName() + "?timeout=3000")));
assertEquals(service.create(1,"kk").getName(), "kk");
assertEquals(service.getSize(null), -1);
assertEquals(service.getSize(new String[]{"", "", ""}), 3);
Expand Down

0 comments on commit 2881738

Please sign in to comment.