mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
fix failed testcase
This commit is contained in:
+9
-11
@@ -35,14 +35,12 @@ public class RandomDataSourceSelectorWithValidationTest {
|
||||
selector.getRecoverThread().setSleepSeconds(3);
|
||||
selector.init();
|
||||
|
||||
Thread.sleep(30 * 1000);
|
||||
|
||||
DruidDataSource dataSource = (DruidDataSource) highAvailableDataSource.getDataSourceMap().get("foo");
|
||||
dataSource.setValidationQuery("select xxx from yyy");
|
||||
Thread.sleep(10 * 1000);
|
||||
Thread.sleep(6 * 1000);
|
||||
assertTrue(dataSource.isTestOnReturn());
|
||||
for (int i = 0; i < 100; i++) {
|
||||
assertNotEquals(dataSource, highAvailableDataSource.getDataSourceSelector().get());
|
||||
assertNotEquals(dataSource, selector.get());
|
||||
}
|
||||
|
||||
dataSource.setValidationQuery(null);
|
||||
@@ -50,7 +48,7 @@ public class RandomDataSourceSelectorWithValidationTest {
|
||||
assertFalse(dataSource.isTestOnReturn());
|
||||
int count = 0;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (dataSource == highAvailableDataSource.getDataSourceSelector().get()) {
|
||||
if (dataSource == selector.get()) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -59,23 +57,23 @@ public class RandomDataSourceSelectorWithValidationTest {
|
||||
|
||||
@Test
|
||||
public void testAllDataSourceFail() throws Exception {
|
||||
((RandomDataSourceSelector) highAvailableDataSource.getDataSourceSelector()).getValidateThread().setCheckingIntervalSeconds(3);
|
||||
((RandomDataSourceSelector) highAvailableDataSource.getDataSourceSelector()).getRecoverThread().setSleepSeconds(3);
|
||||
|
||||
Thread.sleep(30 * 1000);
|
||||
RandomDataSourceSelector selector = (RandomDataSourceSelector) highAvailableDataSource.getDataSourceSelector();
|
||||
selector.setCheckingIntervalSeconds(3);
|
||||
selector.setRecoveryIntervalSeconds(3);
|
||||
selector.init();
|
||||
|
||||
DruidDataSource foo = (DruidDataSource) highAvailableDataSource.getDataSourceMap().get("foo");
|
||||
DruidDataSource bar = (DruidDataSource) highAvailableDataSource.getDataSourceMap().get("bar");
|
||||
foo.setValidationQuery("select xxx from yyy");
|
||||
bar.setValidationQuery("select xxx from yyy");
|
||||
|
||||
Thread.sleep(10 * 1000);
|
||||
Thread.sleep(6 * 1000);
|
||||
assertTrue(foo.isTestOnReturn());
|
||||
assertTrue(bar.isTestOnReturn());
|
||||
|
||||
int[] count = new int[2];
|
||||
for (int i = 0; i < 100; i++) {
|
||||
DataSource dataSource = highAvailableDataSource.getDataSourceSelector().get();
|
||||
DataSource dataSource = selector.get();
|
||||
if (foo == dataSource) {
|
||||
count[0]++;
|
||||
} else if (bar == dataSource) {
|
||||
|
||||
Reference in New Issue
Block a user