Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: skip host list provider check if url is not a cluster endpoint #1275

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ The development team is aware of these limitations and is working to improve the

#### Amazon Aurora Global Databases

This driver currently does not support `planned failover` or `switchover` of Amazon Aurora Global Databases. Failing over to a secondary cluster will result in errors and there may be additional unforeseen errors when working with global databases. Connecting to the primary cluster is fully supported. There is a limitation when connected to the secondary cluster; the [failover2 plugin](using-the-jdbc-driver/using-plugins/UsingTheFailover2Plugin) will not work on the secondary cluster, however the [failover plugin](using-the-jdbc-driver/using-plugins/UsingTheFailoverPlugin) will work. Full Support for Amazon Aurora Global Databases is in the backlog, but we cannot comment on a timeline right now.
This driver currently does not support `planned failover` or `switchover` of Amazon Aurora Global Databases. Failing over to a secondary cluster will result in errors and there may be additional unforeseen errors when working with global databases. Connecting to the primary cluster is fully supported. There is a limitation when connected to the secondary cluster; the [failover2 plugin](./docs/using-the-jdbc-driver/using-plugins/UsingTheFailover2Plugin.md) will not work on the secondary cluster, however the [failover plugin](./docs/using-the-jdbc-driver/using-plugins/UsingTheFailoverPlugin.md) will work. Full Support for Amazon Aurora Global Databases is in the backlog, but we cannot comment on a timeline right now.

## Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ public void initHostProvider(
final HostListProviderService hostListProviderService,
final JdbcCallable<Void, SQLException> initHostProviderFunc) throws SQLException {

final RdsUrlType type = this.rdsUtils.identifyRdsType(initialUrl);
this.hostListProviderService = hostListProviderService;
if (hostListProviderService.isStaticHostListProvider()) {
if ((type.isRdsCluster() || this.verifyOpenedConnectionType != null)
&& hostListProviderService.isStaticHostListProvider()) {
throw new SQLException(Messages.get("AuroraInitialConnectionStrategyPlugin.requireDynamicProvider"));
}
initHostProviderFunc.call();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package integration.container.tests;

import static integration.container.ConnectionStringHelper.getDefaultProperties;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand All @@ -32,13 +33,17 @@
import integration.container.TestDriverProvider;
import integration.container.TestEnvironment;
import integration.container.condition.DisableOnTestFeature;
import integration.container.condition.EnableOnDatabaseEngineDeployment;
import integration.container.condition.EnableOnNumOfInstances;
import integration.container.condition.EnableOnTestFeature;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
Expand All @@ -52,10 +57,30 @@
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import software.amazon.jdbc.PropertyDefinition;
import software.amazon.jdbc.plugin.AuroraConnectionTrackerPluginFactory;
import software.amazon.jdbc.plugin.AuroraInitialConnectionStrategyPluginFactory;
import software.amazon.jdbc.plugin.AwsSecretsManagerConnectionPluginFactory;
import software.amazon.jdbc.plugin.ConnectTimeConnectionPluginFactory;
import software.amazon.jdbc.plugin.DataCacheConnectionPluginFactory;
import software.amazon.jdbc.plugin.DriverMetaDataConnectionPluginFactory;
import software.amazon.jdbc.plugin.ExecutionTimeConnectionPluginFactory;
import software.amazon.jdbc.plugin.LogQueryConnectionPluginFactory;
import software.amazon.jdbc.plugin.customendpoint.CustomEndpointPluginFactory;
import software.amazon.jdbc.plugin.dev.DeveloperConnectionPluginFactory;
import software.amazon.jdbc.plugin.efm.HostMonitoringConnectionPluginFactory;
import software.amazon.jdbc.plugin.failover.FailoverConnectionPluginFactory;
import software.amazon.jdbc.plugin.federatedauth.FederatedAuthPluginFactory;
import software.amazon.jdbc.plugin.federatedauth.OktaAuthPluginFactory;
import software.amazon.jdbc.plugin.iam.IamAuthConnectionPluginFactory;
import software.amazon.jdbc.plugin.limitless.LimitlessConnectionPluginFactory;
import software.amazon.jdbc.plugin.readwritesplitting.ReadWriteSplittingPluginFactory;
import software.amazon.jdbc.plugin.staledns.AuroraStaleDnsPluginFactory;
import software.amazon.jdbc.plugin.strategy.fastestresponse.FastestResponseStrategyPluginFactory;
import software.amazon.jdbc.util.StringUtils;
import software.amazon.jdbc.wrapper.ConnectionWrapper;

@TestMethodOrder(MethodOrderer.MethodName.class)
@ExtendWith(TestDriverProvider.class)
@DisableOnTestFeature({
TestEnvironmentFeatures.PERFORMANCE,
TestEnvironmentFeatures.RUN_HIBERNATE_TESTS_ONLY,
Expand All @@ -64,9 +89,27 @@
public class BasicConnectivityTests {

private static final Logger LOGGER = Logger.getLogger(BasicConnectivityTests.class.getName());
private static final List<String> PLUGINS = Arrays.asList(
"executionTime",
"logQuery",
"dataCache",
"customEndpoint",
"efm",
"efm2",
"failover",
"failover2",
"auroraStaleDns",
"readWriteSplitting",
"auroraConnectionTracker",
"driverMetaData",
"connectTime",
"dev",
"fastestResponseStrategy",
"initialConnection",
"limitless"
);

@TestTemplate
@ExtendWith(TestDriverProvider.class)
public void test_DirectConnection(TestDriver testDriver) throws SQLException {
LOGGER.info(testDriver.toString());

Expand Down Expand Up @@ -105,7 +148,6 @@ public void test_DirectConnection(TestDriver testDriver) throws SQLException {
}

@TestTemplate
@ExtendWith(TestDriverProvider.class)
public void test_WrapperConnection(TestDriver testDriver) throws SQLException {
LOGGER.info(testDriver.toString());

Expand Down Expand Up @@ -144,7 +186,6 @@ public void test_WrapperConnection(TestDriver testDriver) throws SQLException {
}

@TestTemplate
@ExtendWith(TestDriverProvider.class)
@EnableOnTestFeature(TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED)
public void test_ProxiedDirectConnection(TestDriver testDriver) throws SQLException {
LOGGER.info(testDriver.toString());
Expand Down Expand Up @@ -183,7 +224,41 @@ public void test_ProxiedDirectConnection(TestDriver testDriver) throws SQLExcept
}

@TestTemplate
@ExtendWith(TestDriverProvider.class)
@EnableOnNumOfInstances(min = 2)
@EnableOnDatabaseEngineDeployment({DatabaseEngineDeployment.AURORA, DatabaseEngineDeployment.RDS_MULTI_AZ_CLUSTER})
public void testBasicConnectivityTestWithPlugins() throws SQLException {
final TestInstanceInfo readerInstance = TestEnvironment.getCurrent()
.getInfo()
.getDatabaseInfo()
.getInstances()
.get(1);

final List<String> urls = Arrays.asList(
ConnectionStringHelper.getWrapperUrl(),
ConnectionStringHelper.getWrapperUrl(readerInstance),
ConnectionStringHelper.getWrapperClusterEndpointUrl(),
ConnectionStringHelper.getWrapperReaderClusterUrl()
);

for (String url : urls) {
for (String plugin : PLUGINS) {
final Properties props = getDefaultProperties();
props.setProperty(PropertyDefinition.PLUGINS.name, plugin);
LOGGER.finest("Connecting to " + url);

try (Connection conn = DriverManager.getConnection(url, props);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT 1");
) {
assertTrue(rs.next());
assertEquals(1, rs.getInt(1));
}
}
}

}

@TestTemplate
@EnableOnTestFeature(TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED)
public void test_ProxiedWrapperConnection() throws SQLException {
LOGGER.info(TestEnvironment.getCurrent().getCurrentDriver().toString());
Expand Down Expand Up @@ -221,16 +296,15 @@ public void test_ProxiedWrapperConnection() throws SQLException {
}

@TestTemplate
@ExtendWith(TestDriverProvider.class)
public void testSuccessOpenConnectionNoPort() throws SQLException {
String url =
DriverHelper.getWrapperDriverProtocol()
+ TestEnvironment.getCurrent()
.getInfo()
.getDatabaseInfo()
.getInstances()
.get(0)
.getHost()
.getInfo()
.getDatabaseInfo()
.getInstances()
.get(0)
.getHost()
+ "/"
+ TestEnvironment.getCurrent().getInfo().getDatabaseInfo().getDefaultDbName()
+ DriverHelper.getDriverRequiredParameters();
Expand Down Expand Up @@ -272,10 +346,10 @@ public void testFailedProperties(
TestEnvironment.getCurrent().setCurrentDriver(testDriver);

if (TestEnvironment.getCurrent().getInfo().getRequest().getDatabaseEngine()
== DatabaseEngine.MARIADB
== DatabaseEngine.MARIADB
&& TestEnvironment.getCurrent().getCurrentDriver() == TestDriver.MARIADB
&& TestEnvironment.getCurrent().getInfo().getRequest().getDatabaseEngineDeployment()
== DatabaseEngineDeployment.DOCKER
== DatabaseEngineDeployment.DOCKER
&& StringUtils.isNullOrEmpty(username)) {
// MariaDb driver uses "root" username if no username is provided. Since MariaDb database in
// docker container
Expand Down Expand Up @@ -314,7 +388,7 @@ protected static String buildConnectionString(
}

private static Stream<Arguments> testConnectionParameters() {
ArrayList<Arguments> results = new ArrayList<>();
final List<Arguments> results = new ArrayList<>();
for (TestDriver testDriver : TestEnvironment.getCurrent().getAllowedTestDrivers()) {

// missing connection prefix
Expand Down Expand Up @@ -365,9 +439,8 @@ private static Stream<Arguments> testConnectionParameters() {
}

private static Stream<Arguments> testPropertiesParameters() {
ArrayList<Arguments> results = new ArrayList<>();
final List<Arguments> results = new ArrayList<>();
for (TestDriver testDriver : TestEnvironment.getCurrent().getAllowedTestDrivers()) {

// missing username
results.add(
Arguments.of(
Expand Down
Loading