|
24 | 24 | AwsWrapperError, FailoverFailedError, FailoverSuccessError, |
25 | 25 | ReadWriteSplittingError, TransactionResolutionUnknownError) |
26 | 26 | from aws_advanced_python_wrapper.host_list_provider import RdsHostListProvider |
| 27 | +from aws_advanced_python_wrapper.host_monitoring_plugin import MonitoringThreadContainer |
27 | 28 | from aws_advanced_python_wrapper.sql_alchemy_connection_provider import \ |
28 | 29 | SqlAlchemyPooledConnectionProvider |
29 | 30 | from aws_advanced_python_wrapper.utils.log import Logger |
@@ -61,6 +62,9 @@ def setup_method(self, request): |
61 | 62 | yield |
62 | 63 | self.logger.info(f"Ending test: {request.node.name}") |
63 | 64 |
|
| 65 | + MonitoringThreadContainer.clean_up() |
| 66 | + gc.collect() |
| 67 | + |
64 | 68 | @pytest.fixture(scope='class') |
65 | 69 | def rds_utils(self): |
66 | 70 | region: str = TestEnvironment.get_current().get_info().get_region() |
@@ -357,15 +361,18 @@ def test_failover_to_new_writer__switch_read_only( |
357 | 361 | current_id = rds_utils.query_instance_id(conn) |
358 | 362 | assert new_writer_id == current_id |
359 | 363 |
|
| 364 | + @pytest.mark.parametrize("plugins", ["read_write_splitting,failover,host_monitoring", "read_write_splitting,failover,host_monitoring_v2"]) |
360 | 365 | @enable_on_features([TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED, |
361 | 366 | TestEnvironmentFeatures.ABORT_CONNECTION_SUPPORTED]) |
362 | 367 | @enable_on_num_instances(min_instances=3) |
363 | 368 | @disable_on_engines([DatabaseEngine.MYSQL]) |
364 | 369 | def test_failover_to_new_reader__switch_read_only( |
365 | 370 | self, test_environment: TestEnvironment, test_driver: TestDriver, |
366 | | - proxied_failover_props, conn_utils, rds_utils): |
| 371 | + proxied_failover_props, conn_utils, rds_utils, plugins): |
367 | 372 | WrapperProperties.FAILOVER_MODE.set(proxied_failover_props, "reader-or-writer") |
368 | 373 |
|
| 374 | + WrapperProperties.PLUGINS.set(proxied_failover_props, plugins) |
| 375 | + |
369 | 376 | target_driver_connect = DriverHelper.get_connect_func(test_driver) |
370 | 377 | with AwsWrapperConnection.connect( |
371 | 378 | target_driver_connect, **conn_utils.get_proxy_connect_params(), **proxied_failover_props) as conn: |
@@ -404,13 +411,15 @@ def test_failover_to_new_reader__switch_read_only( |
404 | 411 | current_id = rds_utils.query_instance_id(conn) |
405 | 412 | assert other_reader_id == current_id |
406 | 413 |
|
| 414 | + @pytest.mark.parametrize("plugins", ["read_write_splitting,failover,host_monitoring", "read_write_splitting,failover,host_monitoring_v2"]) |
407 | 415 | @enable_on_features([TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED, |
408 | 416 | TestEnvironmentFeatures.ABORT_CONNECTION_SUPPORTED]) |
409 | 417 | @enable_on_num_instances(min_instances=3) |
410 | 418 | @disable_on_engines([DatabaseEngine.MYSQL]) |
411 | 419 | def test_failover_reader_to_writer__switch_read_only( |
412 | 420 | self, test_environment: TestEnvironment, test_driver: TestDriver, |
413 | | - proxied_failover_props, conn_utils, rds_utils): |
| 421 | + proxied_failover_props, conn_utils, rds_utils, plugins): |
| 422 | + WrapperProperties.PLUGINS.set(proxied_failover_props, plugins) |
414 | 423 | target_driver_connect = DriverHelper.get_connect_func(test_driver) |
415 | 424 | with AwsWrapperConnection.connect( |
416 | 425 | target_driver_connect, **conn_utils.get_proxy_connect_params(), **proxied_failover_props) as conn: |
@@ -522,19 +531,21 @@ def test_pooled_connection__cluster_url_failover( |
522 | 531 | new_driver_conn = conn.target_connection |
523 | 532 | assert initial_driver_conn is not new_driver_conn |
524 | 533 |
|
| 534 | + @pytest.mark.parametrize("plugins", ["read_write_splitting,failover,host_monitoring", "read_write_splitting,failover,host_monitoring_v2"]) |
525 | 535 | @enable_on_features([TestEnvironmentFeatures.FAILOVER_SUPPORTED, TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED, |
526 | 536 | TestEnvironmentFeatures.ABORT_CONNECTION_SUPPORTED]) |
527 | 537 | @disable_on_engines([DatabaseEngine.MYSQL]) |
528 | 538 | def test_pooled_connection__failover_failed( |
529 | 539 | self, test_environment: TestEnvironment, test_driver: TestDriver, |
530 | | - rds_utils, conn_utils, proxied_failover_props): |
| 540 | + rds_utils, conn_utils, proxied_failover_props, plugins): |
531 | 541 | writer_host = test_environment.get_writer().get_host() |
532 | 542 | provider = SqlAlchemyPooledConnectionProvider(lambda _, __: {"pool_size": 1}, None, lambda host_info, props: writer_host in host_info.host) |
533 | 543 | ConnectionProviderManager.set_connection_provider(provider) |
534 | 544 |
|
535 | 545 | WrapperProperties.FAILOVER_TIMEOUT_SEC.set(proxied_failover_props, "1") |
536 | 546 | WrapperProperties.FAILURE_DETECTION_TIME_MS.set(proxied_failover_props, "1000") |
537 | 547 | WrapperProperties.FAILURE_DETECTION_COUNT.set(proxied_failover_props, "1") |
| 548 | + WrapperProperties.PLUGINS.set(proxied_failover_props, plugins) |
538 | 549 |
|
539 | 550 | target_driver_connect = DriverHelper.get_connect_func(test_driver) |
540 | 551 | with AwsWrapperConnection.connect( |
|
0 commit comments