Skip to content

Commit 3f57b87

Browse files
committed
run a subset of integration tests. Only mysql with test_tortoise filter
1 parent 117f2ce commit 3f57b87

File tree

4 files changed

+408
-407
lines changed

4 files changed

+408
-407
lines changed

.github/workflows/integration_tests.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
python-version: [ "3.11", "3.12", "3.13" ]
22-
environment: [ "mysql", "pg" ]
21+
python-version: [ "3.11", ]
22+
# environment: [ "mysql", "pg" ]
23+
environment: [ "mysql",]
2324

2425
steps:
2526
- name: 'Clone repository'
Lines changed: 155 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,155 @@
1-
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License").
4-
# You may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
15-
from time import perf_counter_ns, sleep
16-
from uuid import uuid4
17-
18-
import pytest
19-
import pytest_asyncio
20-
from boto3 import client
21-
from botocore.exceptions import ClientError
22-
23-
from tests.integration.container.tortoise.test_tortoise_common import (
24-
run_basic_read_operations, run_basic_write_operations, setup_tortoise)
25-
from tests.integration.container.utils.conditions import (
26-
disable_on_engines, disable_on_features, enable_on_deployments,
27-
enable_on_num_instances)
28-
from tests.integration.container.utils.database_engine import DatabaseEngine
29-
from tests.integration.container.utils.database_engine_deployment import \
30-
DatabaseEngineDeployment
31-
from tests.integration.container.utils.rds_test_utility import RdsTestUtility
32-
from tests.integration.container.utils.test_environment import TestEnvironment
33-
from tests.integration.container.utils.test_environment_features import \
34-
TestEnvironmentFeatures
35-
36-
37-
@disable_on_engines([DatabaseEngine.PG])
38-
@enable_on_num_instances(min_instances=2)
39-
@enable_on_deployments([DatabaseEngineDeployment.AURORA])
40-
@disable_on_features([TestEnvironmentFeatures.RUN_AUTOSCALING_TESTS_ONLY,
41-
TestEnvironmentFeatures.BLUE_GREEN_DEPLOYMENT,
42-
TestEnvironmentFeatures.PERFORMANCE])
43-
class TestTortoiseCustomEndpoint:
44-
"""Test class for Tortoise ORM with custom endpoint plugin."""
45-
endpoint_id = f"test-tortoise-endpoint-{uuid4()}"
46-
endpoint_info: dict[str, str] = {}
47-
48-
@pytest.fixture(scope='class')
49-
def rds_utils(self):
50-
region: str = TestEnvironment.get_current().get_info().get_region()
51-
return RdsTestUtility(region)
52-
53-
@pytest.fixture(scope='class')
54-
def create_custom_endpoint(self, rds_utils):
55-
"""Create a custom endpoint for testing."""
56-
env_info = TestEnvironment.get_current().get_info()
57-
region = env_info.get_region()
58-
rds_client = client('rds', region_name=region)
59-
60-
instance_ids = [rds_utils.get_cluster_writer_instance_id()]
61-
62-
try:
63-
rds_client.create_db_cluster_endpoint(
64-
DBClusterEndpointIdentifier=self.endpoint_id,
65-
DBClusterIdentifier=TestEnvironment.get_current().get_cluster_name(),
66-
EndpointType="ANY",
67-
StaticMembers=instance_ids
68-
)
69-
70-
self._wait_until_endpoint_available(rds_client)
71-
yield self.endpoint_info["Endpoint"]
72-
finally:
73-
try:
74-
rds_client.delete_db_cluster_endpoint(DBClusterEndpointIdentifier=self.endpoint_id)
75-
self._wait_until_endpoint_deleted(rds_client)
76-
except ClientError as e:
77-
if e.response['Error']['Code'] != 'DBClusterEndpointNotFoundFault':
78-
pass # Ignore if endpoint doesn't exist
79-
rds_client.close()
80-
81-
def _wait_until_endpoint_available(self, rds_client):
82-
"""Wait for the custom endpoint to become available."""
83-
end_ns = perf_counter_ns() + 5 * 60 * 1_000_000_000 # 5 minutes
84-
available = False
85-
86-
while perf_counter_ns() < end_ns:
87-
response = rds_client.describe_db_cluster_endpoints(
88-
DBClusterEndpointIdentifier=self.endpoint_id,
89-
Filters=[
90-
{
91-
"Name": "db-cluster-endpoint-type",
92-
"Values": ["custom"]
93-
}
94-
]
95-
)
96-
97-
response_endpoints = response["DBClusterEndpoints"]
98-
if len(response_endpoints) != 1:
99-
sleep(3)
100-
continue
101-
102-
response_endpoint = response_endpoints[0]
103-
TestTortoiseCustomEndpoint.endpoint_info = response_endpoint
104-
available = "available" == response_endpoint["Status"]
105-
if available:
106-
break
107-
108-
sleep(3)
109-
110-
if not available:
111-
pytest.fail(f"Timed out waiting for custom endpoint to become available: {self.endpoint_id}")
112-
113-
def _wait_until_endpoint_deleted(self, rds_client):
114-
"""Wait for the custom endpoint to be deleted."""
115-
end_ns = perf_counter_ns() + 5 * 60 * 1_000_000_000 # 5 minutes
116-
117-
while perf_counter_ns() < end_ns:
118-
try:
119-
rds_client.describe_db_cluster_endpoints(DBClusterEndpointIdentifier=self.endpoint_id)
120-
sleep(5) # Still exists, keep waiting
121-
except ClientError as e:
122-
if e.response['Error']['Code'] == 'DBClusterEndpointNotFoundFault':
123-
return # Successfully deleted
124-
raise # Other error, re-raise
125-
126-
@pytest_asyncio.fixture
127-
async def setup_tortoise_custom_endpoint(self, conn_utils, create_custom_endpoint, request):
128-
"""Setup Tortoise with custom endpoint plugin."""
129-
plugins, user = request.param
130-
user_value = getattr(conn_utils, user) if user != "default" else None
131-
132-
kwargs = {}
133-
if "fastest_response_strategy" in plugins:
134-
kwargs["reader_host_selector_strategy"] = "fastest_response"
135-
136-
async for result in setup_tortoise(conn_utils, plugins=plugins, host=create_custom_endpoint, user=user_value, **kwargs):
137-
yield result
138-
139-
@pytest.mark.parametrize("setup_tortoise_custom_endpoint", [
140-
("custom_endpoint,aurora_connection_tracker", "default"),
141-
("failover,iam,aurora_connection_tracker,custom_endpoint,fastest_response_strategy", "iam_user")
142-
], indirect=True)
143-
@pytest.mark.asyncio
144-
async def test_basic_read_operations(self, setup_tortoise_custom_endpoint):
145-
"""Test basic read operations with custom endpoint plugin."""
146-
await run_basic_read_operations("Custom Test", "custom")
147-
148-
@pytest.mark.parametrize("setup_tortoise_custom_endpoint", [
149-
("custom_endpoint,aurora_connection_tracker", "default"),
150-
("failover,iam,aurora_connection_tracker,custom_endpoint,fastest_response_strategy", "iam_user")
151-
], indirect=True)
152-
@pytest.mark.asyncio
153-
async def test_basic_write_operations(self, setup_tortoise_custom_endpoint):
154-
"""Test basic write operations with custom endpoint plugin."""
155-
await run_basic_write_operations("Custom", "customwrite")
1+
# # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# #
3+
# # Licensed under the Apache License, Version 2.0 (the "License").
4+
# # You may not use this file except in compliance with the License.
5+
# # You may obtain a copy of the License at
6+
# #
7+
# # http://www.apache.org/licenses/LICENSE-2.0
8+
# #
9+
# # Unless required by applicable law or agreed to in writing, software
10+
# # distributed under the License is distributed on an "AS IS" BASIS,
11+
# # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# # See the License for the specific language governing permissions and
13+
# # limitations under the License.
14+
15+
# from time import perf_counter_ns, sleep
16+
# from uuid import uuid4
17+
18+
# import pytest
19+
# import pytest_asyncio
20+
# from boto3 import client
21+
# from botocore.exceptions import ClientError
22+
23+
# from tests.integration.container.tortoise.test_tortoise_common import (
24+
# run_basic_read_operations, run_basic_write_operations, setup_tortoise)
25+
# from tests.integration.container.utils.conditions import (
26+
# disable_on_engines, disable_on_features, enable_on_deployments,
27+
# enable_on_num_instances)
28+
# from tests.integration.container.utils.database_engine import DatabaseEngine
29+
# from tests.integration.container.utils.database_engine_deployment import \
30+
# DatabaseEngineDeployment
31+
# from tests.integration.container.utils.rds_test_utility import RdsTestUtility
32+
# from tests.integration.container.utils.test_environment import TestEnvironment
33+
# from tests.integration.container.utils.test_environment_features import \
34+
# TestEnvironmentFeatures
35+
36+
37+
# @disable_on_engines([DatabaseEngine.PG])
38+
# @enable_on_num_instances(min_instances=2)
39+
# @enable_on_deployments([DatabaseEngineDeployment.AURORA])
40+
# @disable_on_features([TestEnvironmentFeatures.RUN_AUTOSCALING_TESTS_ONLY,
41+
# TestEnvironmentFeatures.BLUE_GREEN_DEPLOYMENT,
42+
# TestEnvironmentFeatures.PERFORMANCE])
43+
# class TestTortoiseCustomEndpoint:
44+
# """Test class for Tortoise ORM with custom endpoint plugin."""
45+
# endpoint_id = f"test-tortoise-endpoint-{uuid4()}"
46+
# endpoint_info: dict[str, str] = {}
47+
48+
# @pytest.fixture(scope='class')
49+
# def rds_utils(self):
50+
# region: str = TestEnvironment.get_current().get_info().get_region()
51+
# return RdsTestUtility(region)
52+
53+
# @pytest.fixture(scope='class')
54+
# def create_custom_endpoint(self, rds_utils):
55+
# """Create a custom endpoint for testing."""
56+
# env_info = TestEnvironment.get_current().get_info()
57+
# region = env_info.get_region()
58+
# rds_client = client('rds', region_name=region)
59+
60+
# instance_ids = [rds_utils.get_cluster_writer_instance_id()]
61+
62+
# try:
63+
# rds_client.create_db_cluster_endpoint(
64+
# DBClusterEndpointIdentifier=self.endpoint_id,
65+
# DBClusterIdentifier=TestEnvironment.get_current().get_cluster_name(),
66+
# EndpointType="ANY",
67+
# StaticMembers=instance_ids
68+
# )
69+
70+
# self._wait_until_endpoint_available(rds_client)
71+
# yield self.endpoint_info["Endpoint"]
72+
# finally:
73+
# try:
74+
# rds_client.delete_db_cluster_endpoint(DBClusterEndpointIdentifier=self.endpoint_id)
75+
# self._wait_until_endpoint_deleted(rds_client)
76+
# except ClientError as e:
77+
# if e.response['Error']['Code'] != 'DBClusterEndpointNotFoundFault':
78+
# pass # Ignore if endpoint doesn't exist
79+
# rds_client.close()
80+
81+
# def _wait_until_endpoint_available(self, rds_client):
82+
# """Wait for the custom endpoint to become available."""
83+
# end_ns = perf_counter_ns() + 5 * 60 * 1_000_000_000 # 5 minutes
84+
# available = False
85+
86+
# while perf_counter_ns() < end_ns:
87+
# response = rds_client.describe_db_cluster_endpoints(
88+
# DBClusterEndpointIdentifier=self.endpoint_id,
89+
# Filters=[
90+
# {
91+
# "Name": "db-cluster-endpoint-type",
92+
# "Values": ["custom"]
93+
# }
94+
# ]
95+
# )
96+
97+
# response_endpoints = response["DBClusterEndpoints"]
98+
# if len(response_endpoints) != 1:
99+
# sleep(3)
100+
# continue
101+
102+
# response_endpoint = response_endpoints[0]
103+
# TestTortoiseCustomEndpoint.endpoint_info = response_endpoint
104+
# available = "available" == response_endpoint["Status"]
105+
# if available:
106+
# break
107+
108+
# sleep(3)
109+
110+
# if not available:
111+
# pytest.fail(f"Timed out waiting for custom endpoint to become available: {self.endpoint_id}")
112+
113+
# def _wait_until_endpoint_deleted(self, rds_client):
114+
# """Wait for the custom endpoint to be deleted."""
115+
# end_ns = perf_counter_ns() + 5 * 60 * 1_000_000_000 # 5 minutes
116+
117+
# while perf_counter_ns() < end_ns:
118+
# try:
119+
# rds_client.describe_db_cluster_endpoints(DBClusterEndpointIdentifier=self.endpoint_id)
120+
# sleep(5) # Still exists, keep waiting
121+
# except ClientError as e:
122+
# if e.response['Error']['Code'] == 'DBClusterEndpointNotFoundFault':
123+
# return # Successfully deleted
124+
# raise # Other error, re-raise
125+
126+
# @pytest_asyncio.fixture
127+
# async def setup_tortoise_custom_endpoint(self, conn_utils, create_custom_endpoint, request):
128+
# """Setup Tortoise with custom endpoint plugin."""
129+
# plugins, user = request.param
130+
# user_value = getattr(conn_utils, user) if user != "default" else None
131+
132+
# kwargs = {}
133+
# if "fastest_response_strategy" in plugins:
134+
# kwargs["reader_host_selector_strategy"] = "fastest_response"
135+
136+
# async for result in setup_tortoise(conn_utils, plugins=plugins, host=create_custom_endpoint, user=user_value, **kwargs):
137+
# yield result
138+
139+
# @pytest.mark.parametrize("setup_tortoise_custom_endpoint", [
140+
# ("custom_endpoint,aurora_connection_tracker", "default"),
141+
# ("failover,iam,aurora_connection_tracker,custom_endpoint,fastest_response_strategy", "iam_user")
142+
# ], indirect=True)
143+
# @pytest.mark.asyncio
144+
# async def test_basic_read_operations(self, setup_tortoise_custom_endpoint):
145+
# """Test basic read operations with custom endpoint plugin."""
146+
# await run_basic_read_operations("Custom Test", "custom")
147+
148+
# @pytest.mark.parametrize("setup_tortoise_custom_endpoint", [
149+
# ("custom_endpoint,aurora_connection_tracker", "default"),
150+
# ("failover,iam,aurora_connection_tracker,custom_endpoint,fastest_response_strategy", "iam_user")
151+
# ], indirect=True)
152+
# @pytest.mark.asyncio
153+
# async def test_basic_write_operations(self, setup_tortoise_custom_endpoint):
154+
# """Test basic write operations with custom endpoint plugin."""
155+
# await run_basic_write_operations("Custom", "customwrite")

0 commit comments

Comments
 (0)