Skip to content

Commit 2a681c1

Browse files
committed
test: re-enable efm2 integration test cases
1 parent e8b2445 commit 2a681c1

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

.github/workflows/integration_tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
push:
66
branches:
77
- main
8+
- test/efm2-tests
89

910
permissions:
1011
id-token: write # This is required for requesting the JWT

tests/integration/container/test_aurora_failover.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414

1515
from __future__ import annotations
1616

17+
import gc
1718
from time import sleep
1819
from typing import TYPE_CHECKING, List
1920

2021
import pytest
2122

2223
from aws_advanced_python_wrapper.errors import (
2324
FailoverSuccessError, TransactionResolutionUnknownError)
25+
from aws_advanced_python_wrapper.host_monitoring_plugin import MonitoringThreadContainer
2426
from aws_advanced_python_wrapper.utils.properties import (Properties,
2527
WrapperProperties)
2628
from .utils.conditions import (disable_on_features, enable_on_deployments,
@@ -56,6 +58,8 @@ def setup_method(self, request):
5658
self.logger.info(f"Starting test: {request.node.name}")
5759
yield
5860
self.logger.info(f"Ending test: {request.node.name}")
61+
MonitoringThreadContainer.clean_up()
62+
gc.collect()
5963

6064
@pytest.fixture(scope='class')
6165
def aurora_utility(self):
@@ -132,6 +136,7 @@ def test_fail_from_writer_to_new_writer_fail_on_connection_bound_object_invocati
132136
assert aurora_utility.is_db_instance_writer(current_connection_id) is True
133137
assert current_connection_id != initial_writer_id
134138

139+
@pytest.mark.parametrize("plugins", ["failover,host_monitoring", "failover,host_monitoring_v2"])
135140
@enable_on_features([TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED,
136141
TestEnvironmentFeatures.ABORT_CONNECTION_SUPPORTED])
137142
def test_fail_from_reader_to_writer(
@@ -140,12 +145,13 @@ def test_fail_from_reader_to_writer(
140145
test_driver: TestDriver,
141146
conn_utils,
142147
proxied_props,
143-
aurora_utility):
148+
aurora_utility,
149+
plugins):
144150
target_driver_connect = DriverHelper.get_connect_func(test_driver)
145151
reader: TestInstanceInfo = test_environment.get_proxy_instances()[1]
146152
writer_id: str = test_environment.get_proxy_writer().get_instance_id()
147153

148-
proxied_props["plugins"] = "failover,host_monitoring"
154+
proxied_props["plugins"] = plugins
149155
with AwsWrapperConnection.connect(
150156
target_driver_connect,
151157
**conn_utils.get_proxy_connect_params(reader.get_host()),

tests/integration/container/test_basic_connectivity.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,19 @@ def test_proxied_wrapper_connection_failed(
126126
# That is expected exception. Test pass.
127127
assert True
128128

129+
@pytest.mark.parametrize("plugins", ["failover,host_monitoring", "failover,host_monitoring_v2"])
129130
@enable_on_num_instances(min_instances=2)
130131
@enable_on_deployments([DatabaseEngineDeployment.AURORA, DatabaseEngineDeployment.RDS_MULTI_AZ_CLUSTER])
131132
@enable_on_features([TestEnvironmentFeatures.ABORT_CONNECTION_SUPPORTED])
132133
def test_wrapper_connection_reader_cluster_with_efm_enabled(self, test_driver: TestDriver, conn_utils, plugins):
133134
props: Properties = Properties({
134-
WrapperProperties.PLUGINS.name: "host_monitoring",
135+
WrapperProperties.PLUGINS.name: plugins,
135136
"socket_timeout": 5,
136137
"connect_timeout": 5,
137138
"monitoring-connect_timeout": 3,
138139
"monitoring-socket_timeout": 3,
139-
"autocommit": True})
140+
"autocommit": True,
141+
"plugins": plugins})
140142
target_driver_connect = DriverHelper.get_connect_func(test_driver)
141143
conn = AwsWrapperConnection.connect(target_driver_connect, **conn_utils.get_connect_params(conn_utils.reader_cluster_host), **props)
142144
cursor = conn.cursor()

tests/integration/container/test_read_write_splitting.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
AwsWrapperError, FailoverFailedError, FailoverSuccessError,
2525
ReadWriteSplittingError, TransactionResolutionUnknownError)
2626
from aws_advanced_python_wrapper.host_list_provider import RdsHostListProvider
27+
from aws_advanced_python_wrapper.host_monitoring_plugin import MonitoringThreadContainer
2728
from aws_advanced_python_wrapper.sql_alchemy_connection_provider import \
2829
SqlAlchemyPooledConnectionProvider
2930
from aws_advanced_python_wrapper.utils.log import Logger
@@ -61,6 +62,9 @@ def setup_method(self, request):
6162
yield
6263
self.logger.info(f"Ending test: {request.node.name}")
6364

65+
MonitoringThreadContainer.clean_up()
66+
gc.collect()
67+
6468
@pytest.fixture(scope='class')
6569
def rds_utils(self):
6670
region: str = TestEnvironment.get_current().get_info().get_region()
@@ -357,15 +361,18 @@ def test_failover_to_new_writer__switch_read_only(
357361
current_id = rds_utils.query_instance_id(conn)
358362
assert new_writer_id == current_id
359363

364+
@pytest.mark.parametrize("plugins", ["read_write_splitting,failover,host_monitoring", "read_write_splitting,failover,host_monitoring_v2"])
360365
@enable_on_features([TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED,
361366
TestEnvironmentFeatures.ABORT_CONNECTION_SUPPORTED])
362367
@enable_on_num_instances(min_instances=3)
363368
@disable_on_engines([DatabaseEngine.MYSQL])
364369
def test_failover_to_new_reader__switch_read_only(
365370
self, test_environment: TestEnvironment, test_driver: TestDriver,
366-
proxied_failover_props, conn_utils, rds_utils):
371+
proxied_failover_props, conn_utils, rds_utils, plugins):
367372
WrapperProperties.FAILOVER_MODE.set(proxied_failover_props, "reader-or-writer")
368373

374+
WrapperProperties.PLUGINS.set(proxied_failover_props, plugins)
375+
369376
target_driver_connect = DriverHelper.get_connect_func(test_driver)
370377
with AwsWrapperConnection.connect(
371378
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(
404411
current_id = rds_utils.query_instance_id(conn)
405412
assert other_reader_id == current_id
406413

414+
@pytest.mark.parametrize("plugins", ["read_write_splitting,failover,host_monitoring", "read_write_splitting,failover,host_monitoring_v2"])
407415
@enable_on_features([TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED,
408416
TestEnvironmentFeatures.ABORT_CONNECTION_SUPPORTED])
409417
@enable_on_num_instances(min_instances=3)
410418
@disable_on_engines([DatabaseEngine.MYSQL])
411419
def test_failover_reader_to_writer__switch_read_only(
412420
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)
414423
target_driver_connect = DriverHelper.get_connect_func(test_driver)
415424
with AwsWrapperConnection.connect(
416425
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(
522531
new_driver_conn = conn.target_connection
523532
assert initial_driver_conn is not new_driver_conn
524533

534+
@pytest.mark.parametrize("plugins", ["read_write_splitting,failover,host_monitoring", "read_write_splitting,failover,host_monitoring_v2"])
525535
@enable_on_features([TestEnvironmentFeatures.FAILOVER_SUPPORTED, TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED,
526536
TestEnvironmentFeatures.ABORT_CONNECTION_SUPPORTED])
527537
@disable_on_engines([DatabaseEngine.MYSQL])
528538
def test_pooled_connection__failover_failed(
529539
self, test_environment: TestEnvironment, test_driver: TestDriver,
530-
rds_utils, conn_utils, proxied_failover_props):
540+
rds_utils, conn_utils, proxied_failover_props, plugins):
531541
writer_host = test_environment.get_writer().get_host()
532542
provider = SqlAlchemyPooledConnectionProvider(lambda _, __: {"pool_size": 1}, None, lambda host_info, props: writer_host in host_info.host)
533543
ConnectionProviderManager.set_connection_provider(provider)
534544

535545
WrapperProperties.FAILOVER_TIMEOUT_SEC.set(proxied_failover_props, "1")
536546
WrapperProperties.FAILURE_DETECTION_TIME_MS.set(proxied_failover_props, "1000")
537547
WrapperProperties.FAILURE_DETECTION_COUNT.set(proxied_failover_props, "1")
548+
WrapperProperties.PLUGINS.set(proxied_failover_props, plugins)
538549

539550
target_driver_connect = DriverHelper.get_connect_func(test_driver)
540551
with AwsWrapperConnection.connect(

0 commit comments

Comments
 (0)