Skip to content
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
4 changes: 4 additions & 0 deletions spec/integration/container/gdb_switchover_failover_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ def drive_txn_until_terminal(conn, timeout_secs:)
# @param txn_scenario [Scenario, nil] optional open-transaction data-integrity scenario
def run_planned_transition(from_writer_instance:, from_db_info:, target_cluster_id:,
scenarios:, aggregate_label:, txn_scenario: nil)
# Let the previous transition settle before any connection is opened, so the wait does not count
# against the drive threads' failover deadlines.
rds_util.wait_until_global_members_available

conns = {}
threads = {}
results = {}
Expand Down
12 changes: 0 additions & 12 deletions spec/integration/container/iam_auth_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,6 @@
Integration::DriverHelper.close(drv, conn) if conn
end

it 'raises IamAuthError when iam_region is missing for global endpoint' do
props_no_region = {
AwsAdvancedRubyDriverWrapper::PropertyDefinition::PLUGINS.name => 'iam',
AwsAdvancedRubyDriverWrapper::PropertyDefinition::GLOBAL_CLUSTER_INSTANCE_HOST_PATTERNS.name =>
"[#{env.primary_region}]?.#{info.instance_endpoint_suffix}:#{writer.port}"
}

expect do
Integration::DriverHelper.wrapper_connect(drv, **gdb_config, **props_no_region)
end.to raise_error(AwsAdvancedRubyDriverWrapper::Errors::IamAuthError, /unable to determine connection region/)
end

it 'connects to secondary cluster endpoint with IAM' do
skip 'Secondary cluster endpoint not available' unless env.secondary_cluster_endpoint

Expand Down
2 changes: 1 addition & 1 deletion spec/integration/container/performance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
PERF_INTER_ITERATION_SLEEP = ENV.fetch('INTER_ITERATION_SLEEP', '15').to_i
PERF_FINISH_LATCH_TIMEOUT = 120
PERF_RECONNECT_TIMEOUT_SEC = 5
PERF_SOCKET_TIMEOUT_PARAMS = [[30, 10_000], [30, 20_000], [30, 30_000]].freeze
PERF_SOCKET_TIMEOUT_PARAMS = [[30, 5_000], [30, 10_000], [30, 20_000]].freeze

RSpec.describe 'Failover Performance', :integration,
features: [Integration::TestEnvironmentFeatures::PERFORMANCE,
Expand Down
47 changes: 43 additions & 4 deletions spec/integration/container/utils/rds_test_utility.rb
Comment thread
karenc-bq marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
Expand Up @@ -658,13 +658,52 @@ def switchover_global_cluster(target_cluster_id, timeout_secs: GLOBAL_TRANSITION

target_arn = cluster_arn(target_cluster_id)
TestUtils.logger.info("GDB switchover: #{global_cluster_id} -> #{target_cluster_id}")
@client.switchover_global_cluster(
global_cluster_identifier: global_cluster_id,
target_db_cluster_identifier: target_arn
)
request_global_switchover(global_cluster_id, target_arn)
wait_until_primary_cluster(target_cluster_id, timeout_secs: timeout_secs)
end

# RDS rejects a switchover while the global cluster or a member is still settling from a previous
# transition, so wait for them to settle and retry the request, as request_cluster_failover does.
def request_global_switchover(global_cluster_id, target_arn, max_request_attempts: 10)
max_request_attempts.times do
wait_until_global_members_available
@client.switchover_global_cluster(
global_cluster_identifier: global_cluster_id,
target_db_cluster_identifier: target_arn
)
return
rescue Aws::RDS::Errors::InvalidDBClusterStateFault, Aws::RDS::Errors::InvalidGlobalClusterStateFault => e
TestUtils.logger.warn("switchover_global_cluster request failed (#{e.message}), retrying")
sleep(GLOBAL_TRANSITION_POLL_SECS)
end

raise "Failed to request a global switchover for #{global_cluster_id} after #{max_request_attempts} attempts"
end

# Waits until the global cluster and every member cluster report 'available', querying each member
# in its own region.
def wait_until_global_members_available
env = TestEnvironment.current
wait_until_global_cluster_available(env.global_cluster_identifier) if env.global_cluster_identifier
[env.cluster_name, env.secondary_cluster_identifier].compact.each do |cluster_id|
util = cluster_id == env.secondary_cluster_identifier ? self.class.secondary_utility : self
util.wait_until_cluster_has_desired_status(cluster_id, 'available')
end
end

def wait_until_global_cluster_available(global_cluster_id, timeout_secs: GLOBAL_TRANSITION_TIMEOUT_SECS)
deadline = Time.now + timeout_secs
loop do
status = @client.describe_global_clusters(global_cluster_identifier: global_cluster_id)
.global_clusters.first&.status
return if status == 'available'

raise "Timeout waiting for global cluster #{global_cluster_id} to become available" if Time.now > deadline

sleep(GLOBAL_TRANSITION_POLL_SECS)
end
end

# Polls the global cluster members until the expected region is home to the global writer.
# +region_or_cluster_id+ may be a region id (e.g. 'us-west-2') or a cluster identifier.
def wait_until_primary_region(region_or_cluster_id, timeout: GLOBAL_TRANSITION_TIMEOUT_SECS)
Expand Down
6 changes: 2 additions & 4 deletions spec/integration/container/utils/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@
props
end

# Base IAM props — extends base_wrapper_props with IAM plugin + region.
# Base IAM props — extends base_wrapper_props with the IAM plugin.
let(:base_iam_props) do
props = base_wrapper_props.merge(
base_wrapper_props.merge(
AwsAdvancedRubyDriverWrapper::PropertyDefinition::PLUGINS.name => 'iam'
)
props[AwsAdvancedRubyDriverWrapper::PropertyDefinition::IAM_REGION.name] = env.primary_region if env.global_cluster_endpoint
props
end

let(:base_config) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1644,6 +1644,7 @@ private static void createTestContainer(TestEnvironment env) {
.withEnv("AWS_ACCESS_KEY_ID", env.awsAccessKeyId)
.withEnv("AWS_SECRET_ACCESS_KEY", env.awsSecretAccessKey)
.withEnv("AWS_SESSION_TOKEN", env.awsSessionToken)
.withEnv("AWS_REGION", env.info.getRegion())
.withEnv("KMS_KEY_ID", env.kmsKeyId);
}

Expand Down
Loading