public class MultiHostConnectionTest extends BaseTestCase
BaseTestCase.MockConnectionConfiguration| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
COMM_LINK_ERR_PATTERN |
private static java.lang.String |
HOST_1 |
private static java.lang.String |
HOST_1_FAIL |
private static java.lang.String |
HOST_1_OK |
private static java.lang.String |
HOST_2 |
private static java.lang.String |
HOST_2_FAIL |
private static java.lang.String |
HOST_2_OK |
private static java.lang.String |
HOST_3 |
private static java.lang.String |
HOST_3_FAIL |
private static java.lang.String |
HOST_3_OK |
private static java.lang.String |
HOST_4 |
private static java.lang.String |
HOST_4_FAIL |
private static java.lang.String |
HOST_4_OK |
private static java.lang.String |
HOST_5 |
private static java.lang.String |
HOST_5_OK |
private static java.lang.String |
STMT_CLOSED_ERR_PATTERN |
conn, dbClass, dbName, dbUrl, isOpenSSL, mainConnectionUrl, pstmt, rs, serverVersion, stmt, timeZoneFreeDbUrl| Constructor and Description |
|---|
MultiHostConnectionTest() |
| Modifier and Type | Method and Description |
|---|---|
private static void |
assertSingleValueQuery(java.sql.Statement testStmt,
java.lang.String query,
java.lang.Object result)
Asserts the execution and return for a simple single value query.
|
private static void |
assertSQLException(java.sql.Connection testConn,
java.lang.String command,
java.lang.String messageRegEx)
Asserts the SQLException thrown for connection commit() or rollback();
|
private static void |
assertSQLException(java.sql.Statement testStmt,
java.lang.String query,
java.lang.String messageRegEx)
Asserts the SQLException thrown for a query execution.
|
void |
testFailoverAutoFallBack()
Tests the automatic fall back to primary host in a failover connection using three hosts and the following sequence of events:
+ 1.st part:
- [\HOST_1 : /HOST_2 : \HOST_3] --> HOST_2
- [/HOST_1 : /HOST_2 : /HOST_3] --> no_change vs HOST_1 (auto fall back)
- [/HOST_1 : \HOST_2 : /HOST_3] --> HOST_1 vs no_change
+ 2.nd part:
- [\HOST_1 : /HOST_2 : \HOST_3] --> HOST_2
- [/HOST_1 : /HOST_2 : /HOST_3] --> no_change
- [/HOST_1 : \HOST_2 : /HOST_3] --> HOST_3
- [/HOST_1 : /HOST_2 : \HOST_3] --> HOST_1
- /HOST_2 & \HOST_3
The automatic fall back only happens at transaction boundaries and at least 'queriesBeforeRetrySource' or 'secondsBeforeRetrySource' is greater than 0.
|
void |
testFailoverAutoReconnect()
Tests the property 'autoReconnect' in a failover connection using three hosts and the following sequence of events:
- [\HOST_1 : \HOST_2 : /HOST_3] --> HOST_3
- [\HOST_1 : /HOST_2 : \HOST_3] --> HOST_2
- [/HOST_1 : /HOST_2 : \HOST_3]
- [/HOST_1 : \HOST_2 : \HOST_3] --> HOST_1
- [/HOST_1 : \HOST_2 : /HOST_3]
- [\HOST_1 : \HOST_2 : /HOST_3] --> HOST_3
[Legend: "/HOST_n" --> HOST_n up; "\HOST_n" --> HOST_n down]
|
void |
testFailoverCombinations()
Repeatedly tests a failover connection using three hosts and the following sequence of events, combining distinct failover event triggering:
- [/HOST_1 : /HOST_2 : /HOST_3] --> HOST_1
- [\HOST_1 : /HOST_2 : /HOST_3] --> HOST_2
- [\HOST_1 : \HOST_2 : /HOST_3] --> HOST_3
- [/HOST_1 : /HOST_2 : /HOST_3]
- [/HOST_1 : /HOST_2 : \HOST_3] --> HOST_2
- [/HOST_1 : \HOST_2 : \HOST_3] --> HOST_1
[Legend: "/HOST_n" --> HOST_n up; "\HOST_n" --> HOST_n down]
|
void |
testFailoverConnection()
Tests failover connection establishing with multiple up/down combinations of 3 hosts.
|
void |
testFailoverConnectionSynchronization()
Tests connection properties synchronization in a failover connection using three hosts and the following sequence of events:
- [\HOST_1 : /HOST_2 : \HOST_3] --> HOST_2
- [/HOST_1 : \HOST_2 : \HOST_3] --> HOST_1
- [\HOST_1 : \HOST_2 : /HOST_3] --> HOST_3
[Legend: "/HOST_n" --> HOST_n up; "\HOST_n" --> HOST_n down]
|
void |
testFailoverDefaultSettings()
Tests a default failover connection using three hosts and the following sequence of events:
- [/HOST_1 : /HOST_2 : /HOST_3] --> HOST_1
- [\HOST_1 : /HOST_2 : /HOST_3] --> HOST_2
- [\HOST_1 : \HOST_2 : /HOST_3] --> HOST_3
- [/HOST_1 : /HOST_2 : /HOST_3]
- [/HOST_1 : /HOST_2 : \HOST_3] --> HOST_2
- [/HOST_1 : \HOST_2 : \HOST_3] --> HOST_1
[Legend: "/HOST_n" --> HOST_n up; "\HOST_n" --> HOST_n down]
|
void |
testFailoverQueriesBeforeRetrySource()
Tests the property 'queriesBeforeRetrySource' in a failover connection using three hosts and the following sequence of events:
- [/HOST_1 : /HOST_2 : /HOST_3] --> HOST_1
- [\HOST_1 : \HOST_2 : /HOST_3] --> HOST_3
- [/HOST_1 : /HOST_2 : \HOST_3] --> HOST_1 vs HOST_2
[Legend: "/HOST_n" --> HOST_n up; "\HOST_n" --> HOST_n down]
|
void |
testFailoverReadOnly()
Tests the property 'failOverReadOnly' in a failover connection using three hosts and the following sequence of events:
- [\HOST_1 : /HOST_2 : /HOST_3] --> HOST_2
- [\HOST_1 : \HOST_2 : /HOST_3] --> HOST_3
- [\HOST_1 : /HOST_2 : \HOST_3] --> HOST_2
- [/HOST_1 : \HOST_2 : \HOST_3] --> HOST_1
- [\HOST_1 : \HOST_2 : /HOST_3] --> HOST_3
[Legend: "/HOST_n" --> HOST_n up; "\HOST_n" --> HOST_n down]
|
void |
testFailoverSecondsBeforeRetrySource()
Tests the property 'secondsBeforeRetrySource' in a failover connection using three hosts and the following sequence of events:
- [/HOST_1 : /HOST_2 : /HOST_3] --> HOST_1
- [\HOST_1 : \HOST_2 : /HOST_3] --> HOST_3
- [/HOST_1 : /HOST_2 : \HOST_3] --> HOST_1 vs HOST_2
[Legend: "/HOST_n" --> HOST_n up; "\HOST_n" --> HOST_n down]
|
private void |
testFailoverTransition(java.lang.String fromHost,
java.lang.String toHost,
java.util.Set<java.lang.String> downedHosts,
java.lang.String recoverHost,
java.lang.String... expectedConnectionsHistory)
Tests a failover transition.
|
void |
testFailoverTransitions()
Tests failover transitions in a default failover connection using three hosts.
|
void |
testLoadBalanceServerAffinityStrategy()
Tests "serverAffinity" load-balancing strategy.
|
appendRequiredProperties, assertByteArrayEquals, assertConnectionsHistory, assertEqualsFSAware, assertNonSecureConnection, assertResultSetLength, assertResultSetsEqual, assertSecureConnection, assertSecureConnection, assertSessionStatusEquals, assertThrows, assertThrows, assertThrows, assertThrows, cleanupTempFiles, createDatabase, createDatabase, createFunction, createFunction, createProcedure, createProcedure, createSchemaObject, createSchemaObject, createTable, createTable, createTable, createTable, createUser, createUser, createView, createView, currentTimeMillis, dropDatabase, dropDatabase, dropFunction, dropFunction, dropProcedure, dropProcedure, dropSchemaObject, dropSchemaObject, dropTable, dropTable, dropUser, dropUser, dropView, dropView, fillPrimitiveDefaults, getConnectionWithProps, getConnectionWithProps, getConnectionWithProps, getConnectionWithProps, getEncodedHostFromTestsuiteUrl, getEncodedHostPortPairFromTestsuiteUrl, getFailoverConnection, getFailoverConnection, getHostFreePropertiesFromTestsuiteUrl, getHostFreePropertiesFromTestsuiteUrl, getHostFromTestsuiteUrl, getInstanceNumber, getLoadBalancedConnection, getLoadBalancedConnection, getLoadBalancedConnection, getMysqlVariable, getMysqlVariable, getNewConnection, getNoDbUrl, getPort, getPortFreeHostname, getPortFromTestsuiteUrl, getPropertiesFromTestsuiteUrl, getPropertiesFromUrl, getRowCount, getSingleIndexedValueWithQuery, getSingleIndexedValueWithQuery, getSingleValue, getSingleValueWithQuery, getSourceReplicaReplicationConnection, getSourceReplicaReplicationConnection, getSourceReplicaUrl, getSourceReplicaUrl, getUnreliableFailoverConnection, getUnreliableFailoverConnection, getUnreliableLoadBalancedConnection, getUnreliableLoadBalancedConnection, getUnreliableMultiHostConnection, getUnreliableReplicationConnection, getUnreliableReplicationConnection, getUnreliableReplicationConnection, isClassAvailable, isCommunityEdition, isEnterpriseEdition, isMysqlRunningLocally, isRunningOnJRockit, isServerRunningOnWindows, isSysPropDefined, logDebug, newTempBinaryFile, randomString, removeHostRelatedProps, removeSqlMode, runLongTests, setUpBase, supportsLoadLocalInfile, supportsTestCachingSha2PasswordKeys, supportsTestCertificates, supportsTestSha256PasswordKeys, supportsTimeZoneNames, supportsTLSv1_2, tearDownBase, versionMeetsMinimum, versionMeetsMinimumprivate static final java.lang.String HOST_1
private static final java.lang.String HOST_2
private static final java.lang.String HOST_3
private static final java.lang.String HOST_4
private static final java.lang.String HOST_5
private static final java.lang.String HOST_1_OK
private static final java.lang.String HOST_1_FAIL
private static final java.lang.String HOST_2_OK
private static final java.lang.String HOST_2_FAIL
private static final java.lang.String HOST_3_OK
private static final java.lang.String HOST_3_FAIL
private static final java.lang.String HOST_4_OK
private static final java.lang.String HOST_4_FAIL
private static final java.lang.String HOST_5_OK
private static final java.lang.String STMT_CLOSED_ERR_PATTERN
private static final java.lang.String COMM_LINK_ERR_PATTERN
private static void assertSingleValueQuery(java.sql.Statement testStmt,
java.lang.String query,
java.lang.Object result)
throws java.lang.Exception
testStmt - The statement instance that runs the query.query - The query.result - The expected result.java.lang.Exceptionprivate static void assertSQLException(java.sql.Connection testConn,
java.lang.String command,
java.lang.String messageRegEx)
testConn - The connection instance where to issue the command.command - The command to issue.messageRegEx - The expected message regular expression pattern.private static void assertSQLException(java.sql.Statement testStmt,
java.lang.String query,
java.lang.String messageRegEx)
testStmt - The statement instance that runs the query.query - The query.messageRegEx - The expected message regular expression pattern.@Test
public void testFailoverConnection()
throws java.lang.Exception
java.lang.Exception@Test
public void testFailoverTransitions()
throws java.lang.Exception
java.lang.Exception@Test
private void testFailoverTransition(java.lang.String fromHost,
java.lang.String toHost,
java.util.Set<java.lang.String> downedHosts,
java.lang.String recoverHost,
java.lang.String... expectedConnectionsHistory)
throws java.lang.Exception
fromHost - The host where initially connected to. In order to connect to an host other than the primary all previous hosts must be downed (pinpoint them
in the 'downedHosts' set).toHost - The host where to failover. In order to correctly connect to this host, all hosts between (and eventually before) 'fromHost' and 'toHost' must
be downed.downedHosts - The set of hosts initially down.recoverHost - The host that recovers after first connection.expectedConnectionsHistory - The expected connection attempts sequence.java.lang.Exception@Test
public void testFailoverDefaultSettings()
throws java.lang.Exception
java.lang.Exception@Test
public void testFailoverCombinations()
throws java.lang.Exception
java.lang.Exception@Test
public void testFailoverReadOnly()
throws java.lang.Exception
java.lang.Exception@Test
public void testFailoverQueriesBeforeRetrySource()
throws java.lang.Exception
java.lang.Exception@Test
public void testFailoverSecondsBeforeRetrySource()
throws java.lang.Exception
java.lang.Exception@Test
public void testFailoverAutoFallBack()
throws java.lang.Exception
java.lang.Exception@Test
public void testFailoverAutoReconnect()
throws java.lang.Exception
java.lang.Exception@Test
public void testFailoverConnectionSynchronization()
throws java.lang.Exception
java.lang.Exception@Test
public void testLoadBalanceServerAffinityStrategy()
throws java.lang.Exception
java.lang.Exception