@@ -61,9 +61,9 @@ def rds_utils(self):
6161 return RdsTestUtility (region )
6262
6363 @pytest .fixture (scope = 'class' )
64- def props (self ):
64+ def default_props (self ):
6565 p : Properties = Properties (
66- {"plugins" : "custom_endpoint,read_write_splitting,failover" , " connect_timeout" : 10_000 , "autocommit" : True , "cluster_id" : "cluster1" })
66+ {"connect_timeout" : 10_000 , "autocommit" : True , "cluster_id" : "cluster1" })
6767
6868 features = TestEnvironment .get_current ().get_features ()
6969 if TestEnvironmentFeatures .TELEMETRY_TRACES_ENABLED in features \
@@ -77,6 +77,18 @@ def props(self):
7777
7878 return p
7979
80+ @pytest .fixture (scope = 'class' )
81+ def props_with_failover (self , default_props ):
82+ p = default_props .copy ()
83+ p ["plugins" ] = "custom_endpoint,read_write_splitting,failover"
84+ return p
85+
86+ @pytest .fixture (scope = 'class' )
87+ def props (self , default_props ):
88+ p = default_props .copy ()
89+ p ["plugins" ] = "custom_endpoint,read_write_splitting"
90+ return p
91+
8092 @pytest .fixture (scope = 'class' , autouse = True )
8193 def setup_and_teardown (self ):
8294 env_info = TestEnvironment .get_current ().get_info ()
@@ -193,7 +205,7 @@ def _wait_until_endpoint_deleted(self, rds_client):
193205 else :
194206 self .logger .debug (f"Custom endpoint '{ self .endpoint_id } ' successfully deleted." )
195207
196- def wait_until_endpoint_has_members (self , rds_client , expected_members : Set [str ]):
208+ def wait_until_endpoint_has_members (self , rds_client , expected_members : Set [str ], rds_utils ):
197209 start_ns = perf_counter_ns ()
198210 end_ns = perf_counter_ns () + 20 * 60 * 1_000_000_000 # 20 minutes
199211 has_correct_state = False
@@ -218,16 +230,17 @@ def wait_until_endpoint_has_members(self, rds_client, expected_members: Set[str]
218230 pytest .fail (f"Timed out while waiting for the custom endpoint to stabilize: "
219231 f"'{ TestCustomEndpoint .endpoint_id } '." )
220232
233+ rds_utils .make_sure_instances_up (list (expected_members ))
221234 duration_sec = (perf_counter_ns () - start_ns ) / 1_000_000_000
222235 self .logger .debug (f"wait_until_endpoint_has_specified_members took { duration_sec } seconds." )
223236
224- def test_custom_endpoint_failover (self , test_driver : TestDriver , conn_utils , props , rds_utils ):
225- props ["failover_mode" ] = "reader_or_writer"
237+ def test_custom_endpoint_failover (self , test_driver : TestDriver , conn_utils , props_with_failover , rds_utils ):
238+ props_with_failover ["failover_mode" ] = "reader_or_writer"
226239
227240 target_driver_connect = DriverHelper .get_connect_func (test_driver )
228241 kwargs = conn_utils .get_connect_params ()
229242 kwargs ["host" ] = self .endpoint_info ["Endpoint" ]
230- conn = AwsWrapperConnection .connect (target_driver_connect , ** kwargs , ** props )
243+ conn = AwsWrapperConnection .connect (target_driver_connect , ** kwargs , ** props_with_failover )
231244
232245 endpoint_members = self .endpoint_info ["StaticMembers" ]
233246 instance_id = rds_utils .query_instance_id (conn )
@@ -281,7 +294,7 @@ def _setup_custom_endpoint_role(self, target_driver_connect, conn_kwargs, rds_ut
281294 self .logger .debug ("Custom endpoint instance successfully set to role: " + host_role .name )
282295
283296 def test_custom_endpoint_read_write_splitting__with_custom_endpoint_changes__with_reader_as_init_conn (
284- self , test_driver : TestDriver , conn_utils , props , rds_utils ):
297+ self , test_driver : TestDriver , conn_utils , props_with_failover , rds_utils ):
285298 '''
286299 Will test for the following scenario:
287300 1. Initially connect to a reader instance via the custom endpoint.
@@ -297,13 +310,13 @@ def test_custom_endpoint_read_write_splitting__with_custom_endpoint_changes__wit
297310 kwargs ["host" ] = self .endpoint_info ["Endpoint" ]
298311 # This setting is not required for the test, but it allows us to also test re-creation of expired monitors since
299312 # it takes more than 30 seconds to modify the cluster endpoint (usually around 140s).
300- props ["custom_endpoint_idle_monitor_expiration_ms" ] = 30_000
301- props ["wait_for_custom_endpoint_info_timeout_ms" ] = 30_000
313+ props_with_failover ["custom_endpoint_idle_monitor_expiration_ms" ] = 30_000
314+ props_with_failover ["wait_for_custom_endpoint_info_timeout_ms" ] = 30_000
302315
303316 # Ensure that we are starting with a reader connection
304317 self ._setup_custom_endpoint_role (target_driver_connect , kwargs , rds_utils , HostRole .READER )
305318
306- conn = AwsWrapperConnection .connect (target_driver_connect , ** kwargs , ** props )
319+ conn = AwsWrapperConnection .connect (target_driver_connect , ** kwargs , ** props_with_failover )
307320 endpoint_members = self .endpoint_info ["StaticMembers" ]
308321 original_reader_id = rds_utils .query_instance_id (conn )
309322 assert original_reader_id in endpoint_members
@@ -323,7 +336,7 @@ def test_custom_endpoint_read_write_splitting__with_custom_endpoint_changes__wit
323336 )
324337
325338 try :
326- self .wait_until_endpoint_has_members (rds_client , {original_reader_id , writer_id })
339+ self .wait_until_endpoint_has_members (rds_client , {original_reader_id , writer_id }, rds_utils )
327340
328341 # We should now be able to switch to writer.
329342 conn .read_only = False
@@ -339,7 +352,7 @@ def test_custom_endpoint_read_write_splitting__with_custom_endpoint_changes__wit
339352 rds_client .modify_db_cluster_endpoint (
340353 DBClusterEndpointIdentifier = self .endpoint_id ,
341354 StaticMembers = [original_reader_id ])
342- self .wait_until_endpoint_has_members (rds_client , {original_reader_id })
355+ self .wait_until_endpoint_has_members (rds_client , {original_reader_id }, rds_utils )
343356
344357 # We should not be able to switch again because new_member was removed from the custom endpoint.
345358 # We are connected to the reader. Attempting to switch to the writer will throw an exception.
@@ -350,16 +363,16 @@ def test_custom_endpoint_read_write_splitting__with_custom_endpoint_changes__wit
350363
351364 def test_custom_endpoint_read_write_splitting__with_custom_endpoint_changes__with_writer_as_init_conn (
352365 self , test_driver : TestDriver , conn_utils , props , rds_utils ):
353- '''
366+ """
354367 Will test for the following scenario:
355- 1. Iniitially connect to the writer instance via the custom endpoint.
368+ 1. Initially connect to the writer instance via the custom endpoint.
356369 2. Attempt to switch to reader instance - should succeed, but will still use writer instance as reader.
357370 3. Modify the custom endpoint to add a reader instance as a static member.
358371 4. Switch to reader instance - should succeed.
359372 5. Switch back to writer instance - should succeed.
360373 6. Modify the custom endpoint to remove the reader instance as a static member.
361374 7. Attempt to switch to reader instance - should fail since the custom endpoint no longer has the reader instance.
362- '''
375+ """
363376
364377 target_driver_connect = DriverHelper .get_connect_func (test_driver )
365378 kwargs = conn_utils .get_connect_params ()
@@ -401,7 +414,7 @@ def test_custom_endpoint_read_write_splitting__with_custom_endpoint_changes__wit
401414 )
402415
403416 try :
404- self .wait_until_endpoint_has_members (rds_client , {original_writer_id , reader_id_to_add })
417+ self .wait_until_endpoint_has_members (rds_client , {original_writer_id , reader_id_to_add }, rds_utils )
405418 # We should now be able to switch to new_member.
406419 conn .read_only = True
407420 new_instance_id = rds_utils .query_instance_id (conn )
@@ -414,7 +427,7 @@ def test_custom_endpoint_read_write_splitting__with_custom_endpoint_changes__wit
414427 rds_client .modify_db_cluster_endpoint (
415428 DBClusterEndpointIdentifier = self .endpoint_id ,
416429 StaticMembers = [original_writer_id ])
417- self .wait_until_endpoint_has_members (rds_client , {original_writer_id })
430+ self .wait_until_endpoint_has_members (rds_client , {original_writer_id }, rds_utils )
418431
419432 # We should not be able to switch again because new_member was removed from the custom endpoint.
420433 # We are connected to the writer. Attempting to switch to the reader will not work but will intentionally
0 commit comments