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