Skip to content

Commit 02c587b

Browse files
authored
Replace port_to_expose with port as testcontainers upgrade (#35501)
* Replace port_to_expose with port as the former one is deprecated * Retrigger tests. * Enforce using pymysql as mysql dialect when creating mysql containers. * Apply yapf
1 parent 623e998 commit 02c587b

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"comment": "Modify this file in a trivial way to cause this test suite to run",
3-
"modification": 11
3+
"modification": 12
44
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"comment": "Modify this file in a trivial way to cause this test suite to run",
3-
"modification": 7
3+
"modification": 8
44
}

sdks/python/apache_beam/io/external/xlang_jdbcio_it_test.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ class CrossLanguageJdbcIOTest(unittest.TestCase):
121121
'postgresql',
122122
'org.postgresql.Driver'),
123123
'mysql': DbData(
124-
lambda: MySqlContainer(), ['mysql:mysql-connector-java:8.0.28'],
124+
lambda: MySqlContainer(dialect='pymysql'),
125+
['mysql:mysql-connector-java:8.0.28'],
125126
'mysql',
126127
'com.mysql.cj.jdbc.Driver')
127128
}
@@ -143,13 +144,13 @@ def setUpClass(cls):
143144
'username': 'test',
144145
'password': 'test',
145146
'host': container.get_container_host_ip(),
146-
'port': container.get_exposed_port(container.port_to_expose),
147+
'port': container.get_exposed_port(container.port),
147148
'database_name': 'test',
148149
'driver_class_name': db_data.connector,
149150
'classpath': db_data.classpath,
150151
'jdbc_url': (
151152
f'jdbc:{db_data.db_string}://{container.get_container_host_ip()}:'
152-
f'{container.get_exposed_port(container.port_to_expose)}/test'),
153+
f'{container.get_exposed_port(container.port)}/test'),
153154
'binary_type': POSTGRES_BINARY_TYPE
154155
if db_type == 'postgres' else MYSQL_BINARY_TYPE
155156
}

sdks/python/apache_beam/yaml/integration_tests.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def gcs_temp_dir(bucket):
7878

7979
@contextlib.contextmanager
8080
def temp_spanner_table(project, prefix='temp_spanner_db_'):
81-
"""Context manager to create and clean up a temporary Spanner database and
81+
"""Context manager to create and clean up a temporary Spanner database and
8282
table.
8383
8484
Creates a unique temporary Spanner database within the specified project
@@ -94,7 +94,7 @@ def temp_spanner_table(project, prefix='temp_spanner_db_'):
9494
Yields:
9595
list[str]: A list containing connection details:
9696
[project_id, instance_id, database_id, table_name, list_of_columns].
97-
Example: ['my-project', 'beam-test', 'temp_spanner_db_...', 'tmp_table',
97+
Example: ['my-project', 'beam-test', 'temp_spanner_db_...', 'tmp_table',
9898
['UserId', 'Key']]
9999
"""
100100
spanner_client = SpannerWrapper(project)
@@ -152,7 +152,7 @@ def temp_sqlite_database(prefix='yaml_jdbc_it_'):
152152
This function creates a temporary SQLite database file on the local
153153
filesystem. It establishes a connection using 'sqlite3', creates a predefined
154154
'tmp_table', and then yields a JDBC connection string suitable for use in
155-
tests that require a generic JDBC connection (specifically configured for
155+
tests that require a generic JDBC connection (specifically configured for
156156
SQLite in this case).
157157
158158
The SQLite database file is automatically cleaned up (closed and deleted)
@@ -228,7 +228,7 @@ def temp_mysql_database():
228228
with the MySQL database during setup.
229229
Exception: Any other exception encountered during the setup process.
230230
"""
231-
with MySqlContainer(init=True) as mysql_container:
231+
with MySqlContainer(init=True, dialect='pymysql') as mysql_container:
232232
try:
233233
# Make connection to temp database and create tmp table
234234
engine = sqlalchemy.create_engine(mysql_container.get_connection_url())
@@ -240,7 +240,7 @@ def temp_mysql_database():
240240
# Construct the JDBC url for connections later on by tests
241241
jdbc_url = (
242242
f"jdbc:mysql://{mysql_container.get_container_host_ip()}:"
243-
f"{mysql_container.get_exposed_port(mysql_container.port_to_expose)}/"
243+
f"{mysql_container.get_exposed_port(mysql_container.port)}/"
244244
f"{mysql_container.MYSQL_DATABASE}?"
245245
f"user={mysql_container.MYSQL_USER}&"
246246
f"password={mysql_container.MYSQL_PASSWORD}")
@@ -362,9 +362,9 @@ def temp_sqlserver_database():
362362
class OracleTestContainer(DockerContainer):
363363
"""
364364
OracleTestContainer is an updated version of OracleDBContainer that goes
365-
ahead and sets the oracle password, waits for logs to establish that the
365+
ahead and sets the oracle password, waits for logs to establish that the
366366
container is ready before calling get_exposed_port, and uses a more modern
367-
oracle driver.
367+
oracle driver.
368368
"""
369369
def __init__(self):
370370
super().__init__("gvenzl/oracle-xe:21-slim")

0 commit comments

Comments
 (0)