From eba2228cf419827ca62162ab9be4d5c89f2dd0c2 Mon Sep 17 00:00:00 2001 From: kgala2 Date: Fri, 28 Mar 2025 10:50:17 -0700 Subject: [PATCH 1/4] feat: update ip type for connectors --- tests/system/test_asyncpg_connection.py | 8 ++++++-- tests/system/test_asyncpg_iam_auth.py | 4 +++- tests/system/test_pg8000_connection.py | 4 +++- tests/system/test_pg8000_iam_auth.py | 4 +++- tests/system/test_pymysql_connection.py | 4 +++- tests/system/test_pymysql_iam_auth.py | 4 +++- tests/system/test_pytds_connection.py | 4 +++- 7 files changed, 24 insertions(+), 8 deletions(-) diff --git a/tests/system/test_asyncpg_connection.py b/tests/system/test_asyncpg_connection.py index e64bbc90..48eb40be 100644 --- a/tests/system/test_asyncpg_connection.py +++ b/tests/system/test_asyncpg_connection.py @@ -87,7 +87,9 @@ async def create_sqlalchemy_engine( user=user, password=password, db=db, - ip_type="public", # can also be "private" or "psc" + ip_type=os.environ.get( + "IP_TYPE", "public" + ), # can also be "private" or "psc" ), execution_options={"isolation_level": "AUTOCOMMIT"}, ) @@ -145,7 +147,9 @@ async def getconn( user=user, password=password, db=db, - ip_type="public", # can also be "private" or "psc", + ip_type=os.environ.get( + "IP_TYPE", "public" + ), # can also be "private" or "psc", **kwargs, ) return conn diff --git a/tests/system/test_asyncpg_iam_auth.py b/tests/system/test_asyncpg_iam_auth.py index ddf6b5e6..803796e9 100644 --- a/tests/system/test_asyncpg_iam_auth.py +++ b/tests/system/test_asyncpg_iam_auth.py @@ -71,7 +71,9 @@ async def create_sqlalchemy_engine( "asyncpg", user=user, db=db, - ip_type="public", # can also be "private" or "psc" + ip_type=os.environ.get( + "IP_TYPE", "public" + ), # can also be "private" or "psc" enable_iam_auth=True, ), execution_options={"isolation_level": "AUTOCOMMIT"}, diff --git a/tests/system/test_pg8000_connection.py b/tests/system/test_pg8000_connection.py index f5d161cc..d6c72d71 100644 --- a/tests/system/test_pg8000_connection.py +++ b/tests/system/test_pg8000_connection.py @@ -85,7 +85,9 @@ def create_sqlalchemy_engine( user=user, password=password, db=db, - ip_type="public", # can also be "private" or "psc" + ip_type=os.environ.get( + "IP_TYPE", "public" + ), # can also be "private" or "psc" ), ) return engine, connector diff --git a/tests/system/test_pg8000_iam_auth.py b/tests/system/test_pg8000_iam_auth.py index 902d9eb9..9734ed57 100644 --- a/tests/system/test_pg8000_iam_auth.py +++ b/tests/system/test_pg8000_iam_auth.py @@ -70,7 +70,9 @@ def create_sqlalchemy_engine( "pg8000", user=user, db=db, - ip_type="public", # can also be "private" or "psc" + ip_type=os.environ.get( + "IP_TYPE", "public" + ), # can also be "private" or "psc" enable_iam_auth=True, ), ) diff --git a/tests/system/test_pymysql_connection.py b/tests/system/test_pymysql_connection.py index 7d7edadc..5dcade0d 100644 --- a/tests/system/test_pymysql_connection.py +++ b/tests/system/test_pymysql_connection.py @@ -75,7 +75,9 @@ def create_sqlalchemy_engine( user=user, password=password, db=db, - ip_type="public", # can also be "private" or "psc" + ip_type=os.environ.get( + "IP_TYPE", "public" + ), # can also be "private" or "psc" ), ) return engine, connector diff --git a/tests/system/test_pymysql_iam_auth.py b/tests/system/test_pymysql_iam_auth.py index 56e26d2b..3b289241 100644 --- a/tests/system/test_pymysql_iam_auth.py +++ b/tests/system/test_pymysql_iam_auth.py @@ -70,7 +70,9 @@ def create_sqlalchemy_engine( "pymysql", user=user, db=db, - ip_type="public", # can also be "private" or "psc" + ip_type=os.environ.get( + "IP_TYPE", "public" + ), # can also be "private" or "psc" enable_iam_auth=True, ), ) diff --git a/tests/system/test_pytds_connection.py b/tests/system/test_pytds_connection.py index a75b3da4..ba93d7b9 100644 --- a/tests/system/test_pytds_connection.py +++ b/tests/system/test_pytds_connection.py @@ -73,7 +73,9 @@ def create_sqlalchemy_engine( user=user, password=password, db=db, - ip_type="public", # can also be "private" or "psc" + ip_type=os.environ.get( + "IP_TYPE", "public" + ), # can also be "private" or "psc" ), ) return engine, connector From def858d27fe64739e104055499b8bb2f5ad4a7c2 Mon Sep 17 00:00:00 2001 From: kgala2 Date: Fri, 28 Mar 2025 12:21:55 -0700 Subject: [PATCH 2/4] test: add private ip tests for python connectors --- .cl/cloudbuild.yaml | 88 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .cl/cloudbuild.yaml diff --git a/.cl/cloudbuild.yaml b/.cl/cloudbuild.yaml new file mode 100644 index 00000000..026c0ef6 --- /dev/null +++ b/.cl/cloudbuild.yaml @@ -0,0 +1,88 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +steps: + - id: run integration tests for python version 3.9 + name: python:${_PYTHON_3.9} + entrypoint: bash + env: + - "IP_TYPE=private" + secretEnv: ["MYSQL_CONNECTION_NAME", "MYSQL_USER", "MYSQL_IAM_USER", "MYSQL_PASS", "MYSQL_DB", "POSTGRES_CONNECTION_NAME", "POSTGRES_USER", "POSTGRES_IAM_USER", "POSTGRES_PASS", "POSTGRES_DB", "POSTGRES_CAS_CONNECTION_NAME", "POSTGRES_CAS_PASS", "POSTGRES_CUSTOMER_CAS_CONNECTION_NAME", "POSTGRES_CUSTOMER_CAS_PASS", "POSTGRES_CUSTOMER_CAS_PASS_VALID_DOMAIN_NAME","SQLSERVER_CONNECTION_NAME", "SQLSERVER_USER", "SQLSERVER_PASS", "SQLSERVER_DB"] + args: + - "-c" + - | + pip install nox + nox -s system-${_PYTHON_3.9} + waitFor: ["-"] + - id: run integration tests for python version 3.13 + name: python:${_PYTHON_3.13} + entrypoint: bash + env: + - "IP_TYPE=private" + secretEnv: ["MYSQL_CONNECTION_NAME", "MYSQL_USER", "MYSQL_IAM_USER", "MYSQL_PASS", "MYSQL_DB", "POSTGRES_CONNECTION_NAME", "POSTGRES_USER", "POSTGRES_IAM_USER", "POSTGRES_PASS", "POSTGRES_DB", "POSTGRES_CAS_CONNECTION_NAME", "POSTGRES_CAS_PASS", "POSTGRES_CUSTOMER_CAS_CONNECTION_NAME", "POSTGRES_CUSTOMER_CAS_PASS", "POSTGRES_CUSTOMER_CAS_PASS_VALID_DOMAIN_NAME","SQLSERVER_CONNECTION_NAME", "SQLSERVER_USER", "SQLSERVER_PASS", "SQLSERVER_DB"] + args: + - "-c" + - | + pip install nox + nox -s system-${_PYTHON_3.13} + waitFor: ["-"] +availableSecrets: + secretManager: + - versionName: 'projects/$PROJECT_ID/secrets/MYSQL_CONNECTION_NAME/versions/latest' + env: 'MYSQL_CONNECTION_NAME' + - versionName: 'projects/$PROJECT_ID/secrets/MYSQL_USER/versions/latest' + env: 'MYSQL_USER' + - versionName: 'projects/$PROJECT_ID/secrets/CLOUD_BUILD_MYSQL_IAM_USER/versions/latest' + env: 'MYSQL_IAM_USER' + - versionName: 'projects/$PROJECT_ID/secrets/MYSQL_PASS/versions/latest' + env: 'MYSQL_PASS' + - versionName: 'projects/$PROJECT_ID/secrets/MYSQL_DB/versions/latest' + env: 'MYSQL_DB' + - versionName: 'projects/$PROJECT_ID/secrets/POSTGRES_CONNECTION_NAME/versions/latest' + env: 'POSTGRES_CONNECTION_NAME' + - versionName: 'projects/$PROJECT_ID/secrets/POSTGRES_USER/versions/latest' + env: 'POSTGRES_USER' + - versionName: 'projects/$PROJECT_ID/secrets/CLOUD_BUILD_POSTGRES_IAM_USER/versions/latest' + env: 'POSTGRES_IAM_USER' + - versionName: 'projects/$PROJECT_ID/secrets/POSTGRES_PASS/versions/latest' + env: 'POSTGRES_PASS' + - versionName: 'projects/$PROJECT_ID/secrets/POSTGRES_DB/versions/latest' + env: 'POSTGRES_DB' + - versionName: 'projects/$PROJECT_ID/secrets/POSTGRES_CAS_CONNECTION_NAME/versions/latest' + env: 'POSTGRES_CAS_CONNECTION_NAME' + - versionName: 'projects/$PROJECT_ID/secrets/POSTGRES_CAS_PASS/versions/latest' + env: 'POSTGRES_CAS_PASS' + - versionName: 'projects/$PROJECT_ID/secrets/POSTGRES_CUSTOMER_CAS_CONNECTION_NAME/versions/latest' + env: 'POSTGRES_CUSTOMER_CAS_CONNECTION_NAME' + - versionName: 'projects/$PROJECT_ID/secrets/POSTGRES_CUSTOMER_CAS_PASS/versions/latest' + env: 'POSTGRES_CUSTOMER_CAS_PASS' + - versionName: 'projects/$PROJECT_ID/secrets/POSTGRES_CUSTOMER_CAS_PASS_VALID_DOMAIN_NAME/versions/latest' + env: 'POSTGRES_CUSTOMER_CAS_PASS_VALID_DOMAIN_NAME' + - versionName: 'projects/$PROJECT_ID/secrets/SQLSERVER_CONNECTION_NAME/versions/latest' + env: 'SQLSERVER_CONNECTION_NAME' + - versionName: 'projects/$PROJECT_ID/secrets/SQLSERVER_USER/versions/latest' + env: 'SQLSERVER_USER' + - versionName: 'projects/$PROJECT_ID/secrets/SQLSERVER_PASS/versions/latest' + env: 'SQLSERVER_PASS' + - versionName: 'projects/$PROJECT_ID/secrets/SQLSERVER_DB/versions/latest' + env: 'SQLSERVER_DB' +substitutions: + _PYTHON_3.13: '3.13' + _PYTHON_3.9: '3.9' + +options: + dynamicSubstitutions: true + pool: + name: ${_POOL_NAME} + logging: CLOUD_LOGGING_ONLY From d2e98dc4f3005bf972b18f1ef2183a0b4bb8d5ff Mon Sep 17 00:00:00 2001 From: kgala2 Date: Mon, 31 Mar 2025 14:12:34 -0700 Subject: [PATCH 3/4] Update cloudbuild.yaml --- .cl/cloudbuild.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.cl/cloudbuild.yaml b/.cl/cloudbuild.yaml index 026c0ef6..7c941a79 100644 --- a/.cl/cloudbuild.yaml +++ b/.cl/cloudbuild.yaml @@ -14,7 +14,7 @@ steps: - id: run integration tests for python version 3.9 - name: python:${_PYTHON_3.9} + name: python:${_PYTHON_3_9} entrypoint: bash env: - "IP_TYPE=private" @@ -23,10 +23,10 @@ steps: - "-c" - | pip install nox - nox -s system-${_PYTHON_3.9} + nox -s system-${_PYTHON_3_9} waitFor: ["-"] - id: run integration tests for python version 3.13 - name: python:${_PYTHON_3.13} + name: python:${_PYTHON_3_13} entrypoint: bash env: - "IP_TYPE=private" @@ -35,7 +35,7 @@ steps: - "-c" - | pip install nox - nox -s system-${_PYTHON_3.13} + nox -s system-${_PYTHON_3_13} waitFor: ["-"] availableSecrets: secretManager: @@ -78,8 +78,8 @@ availableSecrets: - versionName: 'projects/$PROJECT_ID/secrets/SQLSERVER_DB/versions/latest' env: 'SQLSERVER_DB' substitutions: - _PYTHON_3.13: '3.13' - _PYTHON_3.9: '3.9' + _PYTHON_3_13: '3.13' + _PYTHON_3_9: '3.9' options: dynamicSubstitutions: true From 14898b05f516231a19557e011bb4f80784f73cca Mon Sep 17 00:00:00 2001 From: kgala2 Date: Mon, 31 Mar 2025 15:24:13 -0700 Subject: [PATCH 4/4] Update cloudbuild.yaml --- .cl/cloudbuild.yaml | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/.cl/cloudbuild.yaml b/.cl/cloudbuild.yaml index 7c941a79..9ed3add5 100644 --- a/.cl/cloudbuild.yaml +++ b/.cl/cloudbuild.yaml @@ -13,30 +13,17 @@ # limitations under the License. steps: - - id: run integration tests for python version 3.9 - name: python:${_PYTHON_3_9} + - id: run integration tests + name: python:${_VERSION} entrypoint: bash env: - - "IP_TYPE=private" + - "IP_TYPE=${_IP_TYPE}" secretEnv: ["MYSQL_CONNECTION_NAME", "MYSQL_USER", "MYSQL_IAM_USER", "MYSQL_PASS", "MYSQL_DB", "POSTGRES_CONNECTION_NAME", "POSTGRES_USER", "POSTGRES_IAM_USER", "POSTGRES_PASS", "POSTGRES_DB", "POSTGRES_CAS_CONNECTION_NAME", "POSTGRES_CAS_PASS", "POSTGRES_CUSTOMER_CAS_CONNECTION_NAME", "POSTGRES_CUSTOMER_CAS_PASS", "POSTGRES_CUSTOMER_CAS_PASS_VALID_DOMAIN_NAME","SQLSERVER_CONNECTION_NAME", "SQLSERVER_USER", "SQLSERVER_PASS", "SQLSERVER_DB"] args: - "-c" - | pip install nox - nox -s system-${_PYTHON_3_9} - waitFor: ["-"] - - id: run integration tests for python version 3.13 - name: python:${_PYTHON_3_13} - entrypoint: bash - env: - - "IP_TYPE=private" - secretEnv: ["MYSQL_CONNECTION_NAME", "MYSQL_USER", "MYSQL_IAM_USER", "MYSQL_PASS", "MYSQL_DB", "POSTGRES_CONNECTION_NAME", "POSTGRES_USER", "POSTGRES_IAM_USER", "POSTGRES_PASS", "POSTGRES_DB", "POSTGRES_CAS_CONNECTION_NAME", "POSTGRES_CAS_PASS", "POSTGRES_CUSTOMER_CAS_CONNECTION_NAME", "POSTGRES_CUSTOMER_CAS_PASS", "POSTGRES_CUSTOMER_CAS_PASS_VALID_DOMAIN_NAME","SQLSERVER_CONNECTION_NAME", "SQLSERVER_USER", "SQLSERVER_PASS", "SQLSERVER_DB"] - args: - - "-c" - - | - pip install nox - nox -s system-${_PYTHON_3_13} - waitFor: ["-"] + nox -s system-${_VERSION} availableSecrets: secretManager: - versionName: 'projects/$PROJECT_ID/secrets/MYSQL_CONNECTION_NAME/versions/latest' @@ -78,8 +65,8 @@ availableSecrets: - versionName: 'projects/$PROJECT_ID/secrets/SQLSERVER_DB/versions/latest' env: 'SQLSERVER_DB' substitutions: - _PYTHON_3_13: '3.13' - _PYTHON_3_9: '3.9' + _VERSION: ${_VERSION} + _IP_TYPE: ${_IP_TYPE} options: dynamicSubstitutions: true