Commit 95cf37c5 authored by Jason Song's avatar Jason Song

dramatically improve the apollo client unit test performance

parent 91f5b94c
...@@ -131,7 +131,7 @@ public class ConfigServiceLocator implements Initializable { ...@@ -131,7 +131,7 @@ public class ConfigServiceLocator implements Initializable {
} }
try { try {
TimeUnit.SECONDS.sleep(1); m_configUtil.getOnErrorRetryIntervalTimeUnit().sleep(m_configUtil.getOnErrorRetryInterval());
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
//ignore //ignore
} }
......
...@@ -228,7 +228,7 @@ public class RemoteConfigRepository extends AbstractConfigRepository { ...@@ -228,7 +228,7 @@ public class RemoteConfigRepository extends AbstractConfigRepository {
} }
try { try {
TimeUnit.SECONDS.sleep(1); m_configUtil.getOnErrorRetryIntervalTimeUnit().sleep(m_configUtil.getOnErrorRetryInterval());
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
//ignore //ignore
} }
......
...@@ -29,6 +29,9 @@ public class ConfigUtil { ...@@ -29,6 +29,9 @@ public class ConfigUtil {
private String cluster; private String cluster;
private int loadConfigQPS = 2; //2 times per second private int loadConfigQPS = 2; //2 times per second
private int longPollQPS = 2; //2 times per second private int longPollQPS = 2; //2 times per second
//for on error retry
private long onErrorRetryInterval = 1;//1 second
private TimeUnit onErrorRetryIntervalTimeUnit = TimeUnit.SECONDS;//1 second
//for typed config cache of parser result, e.g. integer, double, long, etc. //for typed config cache of parser result, e.g. integer, double, long, etc.
private long maxConfigCacheSize = 500;//500 cache key private long maxConfigCacheSize = 500;//500 cache key
private long configCacheExpireTime = 1;//1 minute private long configCacheExpireTime = 1;//1 minute
...@@ -212,6 +215,14 @@ public class ConfigUtil { ...@@ -212,6 +215,14 @@ public class ConfigUtil {
return longPollQPS; return longPollQPS;
} }
public long getOnErrorRetryInterval() {
return onErrorRetryInterval;
}
public TimeUnit getOnErrorRetryIntervalTimeUnit() {
return onErrorRetryIntervalTimeUnit;
}
public String getDefaultLocalCacheDir() { public String getDefaultLocalCacheDir() {
String cacheRoot = isOSWindows() ? "C:\\opt\\data\\%s" : "/opt/data/%s"; String cacheRoot = isOSWindows() ? "C:\\opt\\data\\%s" : "/opt/data/%s";
return String.format(cacheRoot, getAppId()); return String.format(cacheRoot, getAppId());
......
...@@ -182,6 +182,16 @@ public abstract class BaseIntegrationTest extends ComponentTestCase { ...@@ -182,6 +182,16 @@ public abstract class BaseIntegrationTest extends ComponentTestCase {
public String getDefaultLocalCacheDir() { public String getDefaultLocalCacheDir() {
return ClassLoaderUtil.getClassPath(); return ClassLoaderUtil.getClassPath();
} }
@Override
public long getOnErrorRetryInterval() {
return 10;
}
@Override
public TimeUnit getOnErrorRetryIntervalTimeUnit() {
return TimeUnit.MILLISECONDS;
}
} }
/** /**
......
...@@ -233,6 +233,16 @@ public class RemoteConfigRepositoryTest extends ComponentTestCase { ...@@ -233,6 +233,16 @@ public class RemoteConfigRepositoryTest extends ComponentTestCase {
public int getLongPollQPS() { public int getLongPollQPS() {
return 200; return 200;
} }
@Override
public long getOnErrorRetryInterval() {
return 10;
}
@Override
public TimeUnit getOnErrorRetryIntervalTimeUnit() {
return TimeUnit.MILLISECONDS;
}
} }
public static class MockConfigServiceLocator extends ConfigServiceLocator { public static class MockConfigServiceLocator extends ConfigServiceLocator {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment