Skip to content

Commit 984a673

Browse files
committed
test: add timeouts to prevent integration tests from hanging
1 parent 74ae5de commit 984a673

File tree

5 files changed

+95
-83
lines changed

5 files changed

+95
-83
lines changed
Lines changed: 67 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,67 @@
1-
name: Integration Tests
2-
3-
on:
4-
workflow_dispatch:
5-
push:
6-
branches:
7-
- main
8-
9-
permissions:
10-
id-token: write # This is required for requesting the JWT
11-
contents: read # This is required for actions/checkout
12-
13-
jobs:
14-
build-integration-tests:
15-
name: Run Integration Tests
16-
runs-on: ubuntu-latest
17-
strategy:
18-
fail-fast: false
19-
matrix:
20-
python-version: [ "3.8", "3.11" ]
21-
engine-version: [ "lts", "latest"]
22-
environment: ["mysql", "pg"]
23-
24-
steps:
25-
- name: 'Clone repository'
26-
uses: actions/checkout@v4
27-
28-
- name: 'Set up JDK 8'
29-
uses: actions/setup-java@v4
30-
with:
31-
distribution: 'corretto'
32-
java-version: 8
33-
34-
- name: Install poetry
35-
shell: bash
36-
run: |
37-
pipx install poetry==1.8.2
38-
poetry config virtualenvs.prefer-active-python true
39-
40-
- name: Install dependencies
41-
run: poetry install
42-
43-
- name: 'Configure AWS Credentials'
44-
uses: aws-actions/configure-aws-credentials@v4
45-
with:
46-
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_DEPLOY_ROLE }}
47-
role-session-name: python_integration_tests
48-
role-duration-seconds: 21600
49-
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
50-
51-
- name: 'Run Integration Tests'
52-
run: |
53-
./gradlew --no-parallel --no-daemon test-python-${{ matrix.python-version }}-${{ matrix.environment }} --info
54-
env:
55-
RDS_CLUSTER_DOMAIN: ${{ secrets.DB_CONN_SUFFIX }}
56-
RDS_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
57-
AURORA_MYSQL_DB_ENGINE_VERSION: ${{ matrix.engine-version }}
58-
AURORA_PG_ENGINE_VERSION: ${{ matrix.engine-version }}
59-
60-
- name: 'Archive results'
61-
if: always()
62-
uses: actions/upload-artifact@v4
63-
with:
64-
name: pytest-integration-report-${{ matrix.python-version }}-${{ matrix.environment }}-${{ matrix.engine-version }}
65-
path: ./tests/integration/container/reports
66-
retention-days: 5
1+
name: Integration Tests
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
- test/hanging-efm2-integration-test
9+
10+
permissions:
11+
id-token: write # This is required for requesting the JWT
12+
contents: read # This is required for actions/checkout
13+
14+
jobs:
15+
build-integration-tests:
16+
name: Run Integration Tests
17+
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
python-version: [ "3.8", "3.11" ]
22+
engine-version: [ "lts", "latest" ]
23+
environment: ["mysql", "pg"]
24+
25+
steps:
26+
- name: 'Clone repository'
27+
uses: actions/checkout@v4
28+
29+
- name: 'Set up JDK 8'
30+
uses: actions/setup-java@v4
31+
with:
32+
distribution: 'corretto'
33+
java-version: 8
34+
35+
- name: Install poetry
36+
shell: bash
37+
run: |
38+
pipx install poetry==1.8.2
39+
poetry config virtualenvs.prefer-active-python true
40+
41+
- name: Install dependencies
42+
run: poetry install
43+
44+
- name: 'Configure AWS Credentials'
45+
uses: aws-actions/configure-aws-credentials@v4
46+
with:
47+
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_DEPLOY_ROLE }}
48+
role-session-name: python_integration_tests
49+
role-duration-seconds: 21600
50+
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
51+
52+
- name: 'Run Integration Tests'
53+
run: |
54+
./gradlew --no-parallel --no-daemon test-python-${{ matrix.python-version }}-${{ matrix.environment }} --info
55+
env:
56+
RDS_CLUSTER_DOMAIN: ${{ secrets.DB_CONN_SUFFIX }}
57+
RDS_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
58+
AURORA_MYSQL_DB_ENGINE_VERSION: ${{ matrix.engine-version }}
59+
AURORA_PG_ENGINE_VERSION: ${{ matrix.engine-version }}
60+
61+
- name: 'Archive results'
62+
if: always()
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: pytest-integration-report-${{ matrix.python-version }}-${{ matrix.environment }}-${{ matrix.engine-version }}
66+
path: ./tests/integration/container/reports
67+
retention-days: 5

tests/integration/container/test_aurora_failover.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,15 @@ def aurora_utility(self):
5656

5757
@pytest.fixture(scope='class')
5858
def props(self):
59-
p: Properties = Properties({"plugins": "failover", "connect_timeout": 60, "topology_refresh_ms": 10, "autocommit": True})
59+
p: Properties = Properties({
60+
"plugins": "failover",
61+
"socket_timeout": 30,
62+
"connect_timeout": 10,
63+
"monitoring-connect_timeout": 5,
64+
"monitoring-socket_timeout": 5,
65+
"topology_refresh_ms": 10,
66+
"autocommit": True
67+
})
6068

6169
features = TestEnvironment.get_current().get_features()
6270
if TestEnvironmentFeatures.TELEMETRY_TRACES_ENABLED in features \

tests/integration/container/test_basic_connectivity.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,15 @@ def test_proxied_wrapper_connection_failed(
131131
@enable_on_deployments([DatabaseEngineDeployment.AURORA, DatabaseEngineDeployment.RDS_MULTI_AZ_CLUSTER])
132132
@enable_on_features([TestEnvironmentFeatures.ABORT_CONNECTION_SUPPORTED])
133133
def test_wrapper_connection_reader_cluster_with_efm_enabled(self, test_driver: TestDriver, conn_utils, plugins):
134+
props: Properties = Properties({
135+
WrapperProperties.PLUGINS.name: plugins,
136+
"socket_timeout": 5,
137+
"connect_timeout": 5,
138+
"monitoring-connect_timeout": 3,
139+
"monitoring-socket_timeout": 3,
140+
"autocommit": True})
134141
target_driver_connect = DriverHelper.get_connect_func(test_driver)
135-
conn = AwsWrapperConnection.connect(
136-
target_driver_connect,
137-
**conn_utils.get_connect_params(conn_utils.reader_cluster_host),
138-
plugins=plugins, connect_timeout=10)
142+
conn = AwsWrapperConnection.connect(target_driver_connect, **conn_utils.get_connect_params(conn_utils.reader_cluster_host), **props)
139143
cursor = conn.cursor()
140144
cursor.execute("SELECT 1")
141145
result = cursor.fetchone()

tests/integration/container/test_host_monitoring_v2.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
from aws_advanced_python_wrapper.utils.properties import (Properties,
2323
WrapperProperties)
2424
from tests.integration.container.utils.conditions import (
25-
disable_on_features, enable_on_deployments)
25+
disable_on_engines, disable_on_features, enable_on_deployments)
26+
from tests.integration.container.utils.database_engine import DatabaseEngine
2627
from tests.integration.container.utils.database_engine_deployment import \
2728
DatabaseEngineDeployment
2829
from tests.integration.container.utils.driver_helper import DriverHelper
@@ -44,6 +45,7 @@
4445
@disable_on_features([TestEnvironmentFeatures.PERFORMANCE,
4546
TestEnvironmentFeatures.RUN_AUTOSCALING_TESTS_ONLY,
4647
TestEnvironmentFeatures.BLUE_GREEN_DEPLOYMENT])
48+
@disable_on_engines([DatabaseEngine.MYSQL])
4749
class TestHostMonitoringV2:
4850
@pytest.fixture(scope='class')
4951
def rds_utils(self):
@@ -55,6 +57,8 @@ def props(self):
5557
p: Properties = Properties({"plugins": "host_monitoring_v2",
5658
"socket_timeout": 30,
5759
"connect_timeout": 10,
60+
"monitoring-connect_timeout": 5,
61+
"monitoring-socket_timeout": 5,
5862
"failure_detection_time_ms": 5_000,
5963
"failure_detection_interval_ms": 5_000,
6064
"failure_detection_count": 1,

tests/integration/container/test_read_write_splitting.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -349,15 +349,14 @@ def test_failover_to_new_writer__switch_read_only(
349349
current_id = rds_utils.query_instance_id(conn)
350350
assert new_writer_id == current_id
351351

352-
@pytest.mark.parametrize("plugins", ["read_write_splitting,failover,host_monitoring_v2"])
353352
@enable_on_features([TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED,
354353
TestEnvironmentFeatures.ABORT_CONNECTION_SUPPORTED])
355354
@enable_on_num_instances(min_instances=3)
356355
@disable_on_engines([DatabaseEngine.MYSQL])
357356
def test_failover_to_new_reader__switch_read_only(
358357
self, test_environment: TestEnvironment, test_driver: TestDriver,
359-
proxied_failover_props, conn_utils, rds_utils, plugins):
360-
WrapperProperties.PLUGINS.set(proxied_failover_props, plugins)
358+
proxied_failover_props, conn_utils, rds_utils):
359+
WrapperProperties.PLUGINS.set(proxied_failover_props, "read_write_splitting,failover,host_monitoring")
361360
WrapperProperties.FAILOVER_MODE.set(proxied_failover_props, "reader-or-writer")
362361

363362
target_driver_connect = DriverHelper.get_connect_func(test_driver)
@@ -398,16 +397,14 @@ def test_failover_to_new_reader__switch_read_only(
398397
current_id = rds_utils.query_instance_id(conn)
399398
assert other_reader_id == current_id
400399

401-
@pytest.mark.parametrize("plugins", ["read_write_splitting,failover,host_monitoring",
402-
"read_write_splitting,failover,host_monitoring_v2"])
403400
@enable_on_features([TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED,
404401
TestEnvironmentFeatures.ABORT_CONNECTION_SUPPORTED])
405402
@enable_on_num_instances(min_instances=3)
406403
@disable_on_engines([DatabaseEngine.MYSQL])
407404
def test_failover_reader_to_writer__switch_read_only(
408405
self, test_environment: TestEnvironment, test_driver: TestDriver,
409-
proxied_failover_props, conn_utils, rds_utils, plugins):
410-
WrapperProperties.PLUGINS.set(proxied_failover_props, plugins)
406+
proxied_failover_props, conn_utils, rds_utils):
407+
WrapperProperties.PLUGINS.set(proxied_failover_props, "read_write_splitting,failover,host_monitoring")
411408
target_driver_connect = DriverHelper.get_connect_func(test_driver)
412409
with AwsWrapperConnection.connect(
413410
target_driver_connect, **conn_utils.get_proxy_connect_params(), **proxied_failover_props) as conn:
@@ -519,19 +516,17 @@ def test_pooled_connection__cluster_url_failover(
519516
new_driver_conn = conn.target_connection
520517
assert initial_driver_conn is not new_driver_conn
521518

522-
@pytest.mark.parametrize("plugins", ["read_write_splitting,failover,host_monitoring",
523-
"read_write_splitting,failover,host_monitoring_v2"])
524519
@enable_on_features([TestEnvironmentFeatures.FAILOVER_SUPPORTED, TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED,
525520
TestEnvironmentFeatures.ABORT_CONNECTION_SUPPORTED])
526521
@disable_on_engines([DatabaseEngine.MYSQL])
527522
def test_pooled_connection__failover_failed(
528523
self, test_environment: TestEnvironment, test_driver: TestDriver,
529-
rds_utils, conn_utils, proxied_failover_props, plugins):
524+
rds_utils, conn_utils, proxied_failover_props):
530525
writer_host = test_environment.get_writer().get_host()
531526
provider = SqlAlchemyPooledConnectionProvider(lambda _, __: {"pool_size": 1}, None, lambda host_info, props: writer_host in host_info.host)
532527
ConnectionProviderManager.set_connection_provider(provider)
533528

534-
WrapperProperties.PLUGINS.set(proxied_failover_props, plugins)
529+
WrapperProperties.PLUGINS.set(proxied_failover_props, "read_write_splitting,failover,host_monitoring")
535530
WrapperProperties.FAILOVER_TIMEOUT_SEC.set(proxied_failover_props, "1")
536531
WrapperProperties.FAILURE_DETECTION_TIME_MS.set(proxied_failover_props, "1000")
537532
WrapperProperties.FAILURE_DETECTION_COUNT.set(proxied_failover_props, "1")

0 commit comments

Comments
 (0)