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

Disable failing integration test for PG driver #742

Merged
merged 3 commits into from
Nov 21, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
public class TestDriverProvider implements TestTemplateInvocationContextProvider {
private static final Logger LOGGER = Logger.getLogger(TestDriverProvider.class.getName());

private static final String POSTGRES_AUTH_ERROR_CODE = "28P01";

@Override
public boolean supportsTestTemplate(ExtensionContext context) {
return true;
Expand Down Expand Up @@ -165,6 +167,10 @@ public void beforeEach(ExtensionContext context) throws Exception {
try {
instanceIDs = auroraUtil.getAuroraInstanceIds();
} catch (SQLException ex) {
if (POSTGRES_AUTH_ERROR_CODE.equals(ex.getSQLState())) {
// This authentication error for PG is caused by test environment configuration.
throw ex;
}
instanceIDs = new ArrayList<>();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
import integration.TestInstanceInfo;
import integration.container.ConnectionStringHelper;
import integration.container.ProxyHelper;
import integration.container.TestDriver;
import integration.container.TestDriverProvider;
import integration.container.TestEnvironment;
import integration.container.condition.DisableOnTestDriver;
import integration.container.condition.DisableOnTestFeature;
import integration.container.condition.EnableOnDatabaseEngine;
import integration.container.condition.EnableOnDatabaseEngineDeployment;
Expand Down Expand Up @@ -106,8 +108,10 @@ protected static Properties getProxiedProps() {

protected static Properties getDefaultPropsNoPlugins() {
final Properties props = ConnectionStringHelper.getDefaultProperties();
DriverHelper.setSocketTimeout(props, 10, TimeUnit.SECONDS);
DriverHelper.setConnectTimeout(props, 10, TimeUnit.SECONDS);
props.setProperty(
PropertyDefinition.SOCKET_TIMEOUT.name, String.valueOf(TimeUnit.SECONDS.toMillis(10)));
props.setProperty(
PropertyDefinition.CONNECT_TIMEOUT.name, String.valueOf(TimeUnit.SECONDS.toMillis(10)));
return props;
}

Expand Down Expand Up @@ -338,8 +342,13 @@ public void test_setReadOnly_closedConnection() throws SQLException {
}
}

/**
* PG driver has check of internal readOnly flag and doesn't communicate to a DB server
* if there's no changes. Thus, network exception is not raised.
*/
@TestTemplate
@EnableOnTestFeature(TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED)
@DisableOnTestDriver(TestDriver.PG) // see comments above
public void test_setReadOnlyFalse_allInstancesDown() throws SQLException {
try (final Connection conn = DriverManager.getConnection(
ConnectionStringHelper.getProxyWrapperUrl(), getProxiedProps())) {
Expand All @@ -359,6 +368,24 @@ public void test_setReadOnlyFalse_allInstancesDown() throws SQLException {
}
}

@TestTemplate
@EnableOnTestFeature(TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED)
public void test_setReadOnlyFalse_whenAllInstancesDown() throws SQLException {
try (final Connection conn = DriverManager.getConnection(
ConnectionStringHelper.getWrapperReaderClusterUrl(), getProxiedProps())) {

// Kill all instances
ProxyHelper.disableAllConnectivity();

// setReadOnly(false) triggers switching reader connection to a new writer connection.
// Since connectivity to all instances are down, it's expected to get a network-bound exception
// while opening a new connection to a writer node.
final SQLException exception =
assertThrows(SQLException.class, () -> conn.setReadOnly(false));
assertEquals(SqlState.CONNECTION_UNABLE_TO_CONNECT.getState(), exception.getSQLState());
}
}

@TestTemplate
public void test_executeWithOldConnection() throws SQLException {
try (final Connection conn = DriverManager.getConnection(ConnectionStringHelper.getWrapperUrl(), getProps())) {
Expand Down
Loading