Skip to content

Commit d20a07e

Browse files
committed
fix integration tests
1 parent 3cd65ff commit d20a07e

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

docs/using-the-aws-driver/UsingTheAwsDriver.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ In addition to the parameters that you can configure for the [MySQL Connector/OD
3232
| Option | Description | Type | Required | Default |
3333
| ---------------------------------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|----------|------------------------------------------|
3434
| `ENABLE_CLUSTER_FAILOVER` | Set to `1` to enable the fast failover behaviour offered by the AWS ODBC Driver for MySQL. | bool | No | `1` |
35-
| `FAILOVER_MODE` | Defines a mode for failover process. Failover process may prioritize nodes with different roles and connect to them. Possible values: <br><br>- `strict writer` - Failover process follows writer node and connects to a new writer when it changes.<br>- `reader or writer` - During failover, the driver tries to connect to any available/accessible reader node. If no reader is available, the driver will connect to a writer node. This logic mimics the logic of the Aurora read-only cluster endpoint.<br>- `strict reader` - During failover, the driver tries to connect to any available reader node. If no reader is available, the driver raises an error. Reader failover to a writer node will only be allowed for single-node clusters. This logic mimics the logic of the Aurora read-only cluster endpoint. | char* | No | Default value depends on connection url. For Aurora read-only cluster endpoint, it's set to `reader-or-writer`. Otherwise, it's `strict-writer`. | |
35+
| `FAILOVER_MODE` | Defines a mode for failover process. Failover process may prioritize nodes with different roles and connect to them. Possible values: <br><br>- `strict writer` - Failover process follows writer node and connects to a new writer when it changes.<br>- `reader or writer` - During failover, the driver tries to connect to any available/accessible reader node. If no reader is available, the driver will connect to a writer node. This logic mimics the logic of the Aurora read-only cluster endpoint.<br>- `strict reader` - During failover, the driver tries to connect to any available reader node. If no reader is available, the driver raises an error. Reader failover to a writer node will only be allowed for single-node clusters. This logic mimics the logic of the Aurora read-only cluster endpoint. | char* | No | Default value depends on connection url. For Aurora read-only cluster endpoint, it's set to `reader or writer`. Otherwise, it's `strict writer`. | |
3636
| `GATHER_PERF_METRICS` | Set to `1` to record failover-associated metrics. | bool | No | `0` |
3737
| `GATHER_PERF_METRICS_PER_INSTANCE` | Set to `1` to gather additional performance metrics per instance as well as cluster. | bool | No | `0` |
3838
| `HOST_PATTERN` | This parameter is not required unless connecting to an AWS RDS cluster via an IP address or custom domain URL. In those cases, this parameter specifies the cluster instance DNS pattern that will be used to build a complete instance endpoint. A "?" character in this pattern should be used as a placeholder for the DB instance identifiers of the instances in the cluster. <br/><br/>Example: `?.my-domain.com`, `any-subdomain.?.my-domain.com:9999`<br/><br/>Usecase Example: If your cluster instance endpoint follows this pattern:`instanceIdentifier1.customHost`, `instanceIdentifier2.customHost`, etc. and you want your initial connection to be to `customHost:1234`, then your connection string should look like this: `SERVER=customHost;PORT=1234;DATABASE=test;HOST_PATTERN=?.customHost` <br><br/> If the provided connection string is not an IP address or custom domain, the driver will automatically acquire the cluster instance host pattern from the customer-provided connection string. | char\* | If connecting using an IP address or custom domain URL: Yes <br><br> Otherwise: No <br><br> See [Host Pattern](#host-pattern) for more details. | `NONE` |

driver/failover_handler.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ bool FAILOVER_HANDLER::trigger_failover_if_needed(const char* error_code,
612612
failover_start_time_ms = std::chrono::steady_clock::now();
613613

614614
if (current_topology && current_topology->total_hosts() > 1 &&
615+
// Trigger reader failover if failover mode is not strict writer
615616
myodbc_strcasecmp(FAILOVER_MODE_STRICT_WRITER, ds_get_utf8attr(ds->failover_mode, &ds->failover_mode8))) {
616617
failover_success = failover_to_reader(new_error_code, error_msg);
617618
elasped_time_ms =

integration/failover_integration_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ TEST_F(FailoverIntegrationTest, test_failFromReaderToWriterToAnyAvailableInstanc
359359
ConnectionStringBuilder proxied_builder = ConnectionStringBuilder();
360360
proxied_builder.withDSN(dsn).withUID(user).withPWD(pwd).withConnectTimeout(10).withNetworkTimeout(10);
361361
proxied_builder.withPort(MYSQL_PROXY_PORT).withHostPattern(PROXIED_CLUSTER_TEMPLATE).withLogQuery(true);
362-
connection_string = proxied_builder.withServer(initial_reader_endpoint).build();
362+
connection_string = proxied_builder.withServer(initial_reader_endpoint).withFailoverMode("reader or writer").build();
363363
EXPECT_EQ(SQL_SUCCESS, SQLDriverConnect(dbc, nullptr, AS_SQLCHAR(connection_string.c_str()), SQL_NTS, conn_out, MAX_NAME_LEN, &len, SQL_DRIVER_NOPROMPT));
364364

365365
disable_instance(initial_reader_id);

integration/network_failover_integration_test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ TEST_F(NetworkFailoverIntegrationTest, lost_connection_to_reader_instance) {
192192
}
193193

194194
TEST_F(NetworkFailoverIntegrationTest, lost_connection_read_only) {
195-
connection_string = builder.withServer(reader_endpoint).build();
195+
connection_string = builder.withServer(reader_endpoint).withFailoverMode("reader or writer").build();
196196
EXPECT_EQ(SQL_SUCCESS, SQLDriverConnect(dbc, nullptr, AS_SQLCHAR(connection_string.c_str()), SQL_NTS, conn_out, MAX_NAME_LEN, &len, SQL_DRIVER_NOPROMPT));
197197

198198
disable_instance(reader_id);
@@ -231,7 +231,7 @@ TEST_F(NetworkFailoverIntegrationTest, fail_from_reader_to_reader_with_some_read
231231
// Assert there are at least 2 readers in the cluster.
232232
EXPECT_LE(2, readers.size());
233233

234-
connection_string = builder.withServer(reader_endpoint).withFailoverTimeout(GLOBAL_FAILOVER_TIMEOUT).build();
234+
connection_string = builder.withServer(reader_endpoint).withFailoverTimeout(GLOBAL_FAILOVER_TIMEOUT).withFailoverMode("reader or writer").build();
235235
EXPECT_EQ(SQL_SUCCESS, SQLDriverConnect(dbc, nullptr, AS_SQLCHAR(connection_string.c_str()), SQL_NTS, conn_out, MAX_NAME_LEN, &len, SQL_DRIVER_NOPROMPT));
236236

237237
for (size_t index = 0; index < readers.size() - 1; ++index) {
@@ -258,7 +258,7 @@ TEST_F(NetworkFailoverIntegrationTest, failover_back_to_the_previously_down_read
258258
const std::string server = get_proxied_endpoint(first_reader);
259259
previous_readers.push_back(first_reader);
260260

261-
connection_string = builder.withServer(server).withFailoverTimeout(GLOBAL_FAILOVER_TIMEOUT).build();
261+
connection_string = builder.withServer(server).withFailoverTimeout(GLOBAL_FAILOVER_TIMEOUT).withFailoverMode("reader or writer").build();
262262
EXPECT_EQ(SQL_SUCCESS, SQLDriverConnect(dbc, nullptr, AS_SQLCHAR(connection_string.c_str()), SQL_NTS, conn_out, MAX_NAME_LEN, &len, SQL_DRIVER_NOPROMPT));
263263

264264
disable_instance(first_reader);

0 commit comments

Comments
 (0)