Skip to content

Commit c334eee

Browse files
committed
fix: clear topology cache before each test
1 parent 243c8ee commit c334eee

File tree

5 files changed

+37
-7
lines changed

5 files changed

+37
-7
lines changed

wrapper/src/main/java/com/amazon/awslabs/jdbc/hostlistprovider/AuroraHostListProvider.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public class AuroraHostListProvider implements HostListProvider, DynamicHostList
9999
private final int refreshRateInMilliseconds;
100100
private List<HostSpec> hostList = new ArrayList<>();
101101

102-
static final ExpiringCache<String, ClusterTopologyInfo> topologyCache =
102+
protected static final ExpiringCache<String, ClusterTopologyInfo> topologyCache =
103103
new ExpiringCache<>(DEFAULT_CACHE_EXPIRE_MS);
104104
private static final Object cacheLock = new Object();
105105

@@ -383,8 +383,6 @@ public void addToDownHostList(HostSpec downHost) {
383383
clusterTopologyInfo.downHosts = ConcurrentHashMap.newKeySet();
384384
}
385385
clusterTopologyInfo.downHosts.add(downHost.getUrl());
386-
LOGGER.fine("add to down host list: " + downHost.getUrl());
387-
LOGGER.fine("addToDownHostList: " + Arrays.toString(new SQLException().getStackTrace()));
388386
this.pluginService.setAvailability(downHost.getAliases(), HostAvailability.NOT_AVAILABLE);
389387
}
390388
}

wrapper/src/main/java/com/amazon/awslabs/jdbc/plugin/failover/ClusterAwareReaderFailoverHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ private void addActiveReaders(
219219
}
220220
}
221221
Collections.shuffle(activeReaders);
222-
LOGGER.fine("active readers: " + Arrays.toString(activeReaders.toArray()));
223222
list.addAll(activeReaders);
224223
}
225224

wrapper/src/test/java/integration/container/aurora/postgres/AuroraPostgresBaseTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ public void setUpEach() throws InterruptedException, SQLException {
214214
clusterSize >= 2); // many tests assume that cluster contains at least a writer and a reader
215215
assertTrue(isDBInstanceWriter(instanceIDs[0]));
216216
makeSureInstancesUp(instanceIDs);
217+
TestAuroraHostListProvider.clearCache();
217218
}
218219

219220
protected Properties initDefaultPropsNoTimeouts() {

wrapper/src/test/java/integration/container/aurora/postgres/AuroraPostgresTestSuite.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package integration.container.aurora.postgres;
1818

19-
import org.junit.platform.suite.api.IncludeTags;
2019
import org.junit.platform.suite.api.SelectClasses;
2120
import org.junit.platform.suite.api.Suite;
2221

@@ -25,7 +24,7 @@
2524
@Suite
2625
@SelectClasses({
2726
AuroraPostgresIntegrationTest.class,
28-
// AuroraPostgresFailoverTest.class,
29-
// AuroraPostgresDataSourceTest.class
27+
AuroraPostgresFailoverTest.class,
28+
AuroraPostgresDataSourceTest.class
3029
})
3130
public class AuroraPostgresTestSuite {}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package integration.container.aurora.postgres;
18+
19+
import com.amazon.awslabs.jdbc.PluginService;
20+
import com.amazon.awslabs.jdbc.hostlistprovider.AuroraHostListProvider;
21+
import java.util.Properties;
22+
23+
public class TestAuroraHostListProvider extends AuroraHostListProvider {
24+
25+
public TestAuroraHostListProvider(String driverProtocol, PluginService pluginService,
26+
Properties properties, String originalUrl) {
27+
super(driverProtocol, pluginService, properties, originalUrl);
28+
}
29+
30+
public static void clearCache() {
31+
AuroraHostListProvider.topologyCache.clear();
32+
}
33+
}

0 commit comments

Comments
 (0)