From e69980d874371464501ebc2c71011012a2c55972 Mon Sep 17 00:00:00 2001 From: kgala2 Date: Tue, 22 Apr 2025 22:57:18 -0700 Subject: [PATCH 01/10] chore: update mysql ip types --- .ci/cloudbuild.yaml | 6 +++--- tests/system/test_pymysql_connection.py | 6 ++++++ tests/system/test_pymysql_iam_auth.py | 6 ++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.ci/cloudbuild.yaml b/.ci/cloudbuild.yaml index e31e8bebb..e56cc75b0 100644 --- a/.ci/cloudbuild.yaml +++ b/.ci/cloudbuild.yaml @@ -51,13 +51,13 @@ steps: nox -s system-${_VERSION} availableSecrets: secretManager: - - versionName: "projects/$PROJECT_ID/secrets/MYSQL_CONNECTION_NAME/versions/latest" + - versionName: "projects/$PROJECT_ID/secrets/MYSQL_PSA_CONNECTION_NAME/versions/latest" env: "MYSQL_CONNECTION_NAME" - - versionName: "projects/$PROJECT_ID/secrets/MYSQL_USER/versions/latest" + - versionName: "projects/$PROJECT_ID/secrets/MYSQL_PSA_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" + - versionName: "projects/$PROJECT_ID/secrets/MYSQL_PSA_PASS/versions/latest" env: "MYSQL_PASS" - versionName: "projects/$PROJECT_ID/secrets/MYSQL_DB/versions/latest" env: "MYSQL_DB" diff --git a/tests/system/test_pymysql_connection.py b/tests/system/test_pymysql_connection.py index f5dd8a1eb..6e17b4c26 100644 --- a/tests/system/test_pymysql_connection.py +++ b/tests/system/test_pymysql_connection.py @@ -96,6 +96,9 @@ def test_pymysql_connection() -> None: db = os.environ["MYSQL_DB"] ip_type = os.environ.get("IP_TYPE", "public") + if ip_type == "private": + ip_type = "psc" + engine, connector = create_sqlalchemy_engine( inst_conn_name, user, password, db, ip_type ) @@ -115,6 +118,9 @@ def test_lazy_pymysql_connection() -> None: db = os.environ["MYSQL_DB"] ip_type = os.environ.get("IP_TYPE", "public") + if ip_type == "private": + ip_type = "psc" + engine, connector = create_sqlalchemy_engine( inst_conn_name, user, password, db, ip_type, "lazy" ) diff --git a/tests/system/test_pymysql_iam_auth.py b/tests/system/test_pymysql_iam_auth.py index da676e66c..08c286086 100644 --- a/tests/system/test_pymysql_iam_auth.py +++ b/tests/system/test_pymysql_iam_auth.py @@ -88,6 +88,9 @@ def test_pymysql_iam_authn_connection() -> None: db = os.environ["MYSQL_DB"] ip_type = os.environ.get("IP_TYPE", "public") + if ip_type == "private": + ip_type = "psc" + engine, connector = create_sqlalchemy_engine(inst_conn_name, user, db, ip_type) with engine.connect() as conn: time = conn.execute(sqlalchemy.text("SELECT NOW()")).fetchone() @@ -104,6 +107,9 @@ def test_lazy_pymysql_iam_authn_connection() -> None: db = os.environ["MYSQL_DB"] ip_type = os.environ.get("IP_TYPE", "public") + if ip_type == "private": + ip_type = "psc" + engine, connector = create_sqlalchemy_engine( inst_conn_name, user, db, ip_type, "lazy" ) From 0ca0653db56044d3036bb801d30a5866eff7a41e Mon Sep 17 00:00:00 2001 From: kgala2 Date: Tue, 22 Apr 2025 23:07:08 -0700 Subject: [PATCH 02/10] chore: test psa on psc instance --- tests/system/test_pymysql_connection.py | 6 ------ tests/system/test_pymysql_iam_auth.py | 6 ------ 2 files changed, 12 deletions(-) diff --git a/tests/system/test_pymysql_connection.py b/tests/system/test_pymysql_connection.py index 6e17b4c26..f5dd8a1eb 100644 --- a/tests/system/test_pymysql_connection.py +++ b/tests/system/test_pymysql_connection.py @@ -96,9 +96,6 @@ def test_pymysql_connection() -> None: db = os.environ["MYSQL_DB"] ip_type = os.environ.get("IP_TYPE", "public") - if ip_type == "private": - ip_type = "psc" - engine, connector = create_sqlalchemy_engine( inst_conn_name, user, password, db, ip_type ) @@ -118,9 +115,6 @@ def test_lazy_pymysql_connection() -> None: db = os.environ["MYSQL_DB"] ip_type = os.environ.get("IP_TYPE", "public") - if ip_type == "private": - ip_type = "psc" - engine, connector = create_sqlalchemy_engine( inst_conn_name, user, password, db, ip_type, "lazy" ) diff --git a/tests/system/test_pymysql_iam_auth.py b/tests/system/test_pymysql_iam_auth.py index 08c286086..da676e66c 100644 --- a/tests/system/test_pymysql_iam_auth.py +++ b/tests/system/test_pymysql_iam_auth.py @@ -88,9 +88,6 @@ def test_pymysql_iam_authn_connection() -> None: db = os.environ["MYSQL_DB"] ip_type = os.environ.get("IP_TYPE", "public") - if ip_type == "private": - ip_type = "psc" - engine, connector = create_sqlalchemy_engine(inst_conn_name, user, db, ip_type) with engine.connect() as conn: time = conn.execute(sqlalchemy.text("SELECT NOW()")).fetchone() @@ -107,9 +104,6 @@ def test_lazy_pymysql_iam_authn_connection() -> None: db = os.environ["MYSQL_DB"] ip_type = os.environ.get("IP_TYPE", "public") - if ip_type == "private": - ip_type = "psc" - engine, connector = create_sqlalchemy_engine( inst_conn_name, user, db, ip_type, "lazy" ) From 06da368e4709714d3776f809901ae841e77ec719 Mon Sep 17 00:00:00 2001 From: kgala2 Date: Wed, 23 Apr 2025 00:13:41 -0700 Subject: [PATCH 03/10] chore: update test_pymysql_conn to psc ip type --- tests/system/test_pymysql_connection.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/system/test_pymysql_connection.py b/tests/system/test_pymysql_connection.py index f5dd8a1eb..b695b3a10 100644 --- a/tests/system/test_pymysql_connection.py +++ b/tests/system/test_pymysql_connection.py @@ -96,6 +96,9 @@ def test_pymysql_connection() -> None: db = os.environ["MYSQL_DB"] ip_type = os.environ.get("IP_TYPE", "public") + if ip_type == "private": + ip_type = "PSC" + engine, connector = create_sqlalchemy_engine( inst_conn_name, user, password, db, ip_type ) From 83fbfcadd043da48aedfa9f6561bba55bf7a5cf1 Mon Sep 17 00:00:00 2001 From: kgala2 Date: Wed, 23 Apr 2025 09:22:01 -0700 Subject: [PATCH 04/10] chore: test PSC enabled instance --- .ci/cloudbuild.yaml | 12 +++++++++--- tests/system/test_pymysql_connection.py | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.ci/cloudbuild.yaml b/.ci/cloudbuild.yaml index e56cc75b0..8b9662987 100644 --- a/.ci/cloudbuild.yaml +++ b/.ci/cloudbuild.yaml @@ -51,14 +51,20 @@ steps: nox -s system-${_VERSION} availableSecrets: secretManager: - - versionName: "projects/$PROJECT_ID/secrets/MYSQL_PSA_CONNECTION_NAME/versions/latest" + - versionName: "projects/$PROJECT_ID/secrets/MYSQL_CONNECTION_NAME/versions/latest" env: "MYSQL_CONNECTION_NAME" - - versionName: "projects/$PROJECT_ID/secrets/MYSQL_PSA_USER/versions/latest" + - 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_PSA_PASS/versions/latest" + - versionName: "projects/$PROJECT_ID/secrets/MYSQL_PASS/versions/latest" env: "MYSQL_PASS" + - versionName: "projects/$PROJECT_ID/secrets/MYSQL_PSA_CONNECTION_NAME/versions/latest" + env: "MYSQL_PSA_CONNECTION_NAME" + - versionName: "projects/$PROJECT_ID/secrets/MYSQL_PSA_USER/versions/latest" + env: "MYSQL_PSA_USER" + - versionName: "projects/$PROJECT_ID/secrets/MYSQL_PSA_PASS/versions/latest" + env: "MYSQL_PSA_PASS" - versionName: "projects/$PROJECT_ID/secrets/MYSQL_DB/versions/latest" env: "MYSQL_DB" - versionName: "projects/$PROJECT_ID/secrets/MYSQL_MCP_CONNECTION_NAME/versions/latest" diff --git a/tests/system/test_pymysql_connection.py b/tests/system/test_pymysql_connection.py index b695b3a10..b00421354 100644 --- a/tests/system/test_pymysql_connection.py +++ b/tests/system/test_pymysql_connection.py @@ -90,9 +90,9 @@ def create_sqlalchemy_engine( def test_pymysql_connection() -> None: """Basic test to get time from database.""" - inst_conn_name = os.environ["MYSQL_CONNECTION_NAME"] - user = os.environ["MYSQL_USER"] - password = os.environ["MYSQL_PASS"] + inst_conn_name = os.environ["MYSQL_PSA_CONNECTION_NAME"] + user = os.environ["MYSQL_PSA_USER"] + password = os.environ["MYSQL_PSA_PASS"] db = os.environ["MYSQL_DB"] ip_type = os.environ.get("IP_TYPE", "public") From b70ad04c55891946300ba6a184394a03b6a80057 Mon Sep 17 00:00:00 2001 From: kgala2 Date: Wed, 23 Apr 2025 09:22:48 -0700 Subject: [PATCH 05/10] chore: update cb file --- .ci/cloudbuild.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.ci/cloudbuild.yaml b/.ci/cloudbuild.yaml index 8b9662987..56ba3c2ad 100644 --- a/.ci/cloudbuild.yaml +++ b/.ci/cloudbuild.yaml @@ -20,6 +20,9 @@ steps: - "IP_TYPE=${_IP_TYPE}" secretEnv: [ + "MYSQL_PSA_CONNECTION_NAME", + "MYSQL_PSA_USER", + "MYSQL_PSA_PASS", "MYSQL_CONNECTION_NAME", "MYSQL_USER", "MYSQL_IAM_USER", From 322d17c72290758c0c249948b93e634b68caf5e0 Mon Sep 17 00:00:00 2001 From: kgala2 Date: Thu, 24 Apr 2025 13:28:14 -0700 Subject: [PATCH 06/10] chore: update substitutions --- .ci/cloudbuild.yaml | 12 ++++++++++++ tests/system/test_pymysql_connection.py | 8 +++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.ci/cloudbuild.yaml b/.ci/cloudbuild.yaml index 56ba3c2ad..b06aa0038 100644 --- a/.ci/cloudbuild.yaml +++ b/.ci/cloudbuild.yaml @@ -13,6 +13,17 @@ # limitations under the License. steps: + - id: check the private DNS zone and the private connection + name: gcr.io/cloud-builders/git + entrypoint: bash + args: + - '-c' + - | + apt-get update + apt-get install dnsutils -y + echo "dig ${_DNS_NAME} ..." + dig ${_DNS_NAME} + - id: run integration tests name: python:${_VERSION} entrypoint: bash @@ -109,6 +120,7 @@ availableSecrets: substitutions: _VERSION: ${_VERSION} _IP_TYPE: ${_IP_TYPE} + _DNS_NAME: ${_DNS_NAME} options: dynamicSubstitutions: true diff --git a/tests/system/test_pymysql_connection.py b/tests/system/test_pymysql_connection.py index b00421354..ac8bd342f 100644 --- a/tests/system/test_pymysql_connection.py +++ b/tests/system/test_pymysql_connection.py @@ -90,9 +90,11 @@ def create_sqlalchemy_engine( def test_pymysql_connection() -> None: """Basic test to get time from database.""" - inst_conn_name = os.environ["MYSQL_PSA_CONNECTION_NAME"] - user = os.environ["MYSQL_PSA_USER"] - password = os.environ["MYSQL_PSA_PASS"] + inst_conn_name = os.environ.get( + "MYSQL_PSA_CONNECTION_NAME", os.environ["MYSQL_CONNECTION_NAME"] + ) + user = os.environ.get("MYSQL_PSA_USER", os.environ["MYSQL_USER"]) + password = os.environ.get("MYSQL_PSA_PASS", os.environ["MYSQL_PASS"]) db = os.environ["MYSQL_DB"] ip_type = os.environ.get("IP_TYPE", "public") From b28a045a81355523203f4580969d8c759b122629 Mon Sep 17 00:00:00 2001 From: kgala2 Date: Thu, 24 Apr 2025 15:52:07 -0700 Subject: [PATCH 07/10] chore: add more comments in 'dig command' --- .ci/cloudbuild.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.ci/cloudbuild.yaml b/.ci/cloudbuild.yaml index b06aa0038..45afa74a3 100644 --- a/.ci/cloudbuild.yaml +++ b/.ci/cloudbuild.yaml @@ -21,8 +21,14 @@ steps: - | apt-get update apt-get install dnsutils -y - echo "dig ${_DNS_NAME} ..." + echo "dig ${_DNS_NAME} ... (with +trace)" + dig +trace ${_DNS_NAME} + echo "dig ${_DNS_NAME} ... (without +trace)" dig ${_DNS_NAME} + echo "cat /etc/resolv.conf" + cat /etc/resolv.conf + echo "ip route" + ip route - id: run integration tests name: python:${_VERSION} From a836016e3e37768e82f64cc7d4a7e79c35322dbd Mon Sep 17 00:00:00 2001 From: kgala2 Date: Thu, 24 Apr 2025 17:31:59 -0700 Subject: [PATCH 08/10] chore: update DNS zone steps --- .ci/cloudbuild.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.ci/cloudbuild.yaml b/.ci/cloudbuild.yaml index 45afa74a3..5550058eb 100644 --- a/.ci/cloudbuild.yaml +++ b/.ci/cloudbuild.yaml @@ -27,8 +27,6 @@ steps: dig ${_DNS_NAME} echo "cat /etc/resolv.conf" cat /etc/resolv.conf - echo "ip route" - ip route - id: run integration tests name: python:${_VERSION} From 5e29b765a02ff15e20bae389e9f8f6b8723bca39 Mon Sep 17 00:00:00 2001 From: kgala2 Date: Wed, 3 Sep 2025 08:20:09 -0700 Subject: [PATCH 09/10] chore: update test psc instance credentials --- .ci/cloudbuild.yaml | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/.ci/cloudbuild.yaml b/.ci/cloudbuild.yaml index 5550058eb..8517ff647 100644 --- a/.ci/cloudbuild.yaml +++ b/.ci/cloudbuild.yaml @@ -13,21 +13,6 @@ # limitations under the License. steps: - - id: check the private DNS zone and the private connection - name: gcr.io/cloud-builders/git - entrypoint: bash - args: - - '-c' - - | - apt-get update - apt-get install dnsutils -y - echo "dig ${_DNS_NAME} ... (with +trace)" - dig +trace ${_DNS_NAME} - echo "dig ${_DNS_NAME} ... (without +trace)" - dig ${_DNS_NAME} - echo "cat /etc/resolv.conf" - cat /etc/resolv.conf - - id: run integration tests name: python:${_VERSION} entrypoint: bash @@ -124,10 +109,9 @@ availableSecrets: substitutions: _VERSION: ${_VERSION} _IP_TYPE: ${_IP_TYPE} - _DNS_NAME: ${_DNS_NAME} options: dynamicSubstitutions: true pool: name: ${_POOL_NAME} - logging: CLOUD_LOGGING_ONLY + logging: CLOUD_LOGGING_ONLY \ No newline at end of file From 84fd3fba85c266eea2d3357e7d951ca4b9028917 Mon Sep 17 00:00:00 2001 From: kgala2 Date: Wed, 3 Sep 2025 08:25:43 -0700 Subject: [PATCH 10/10] chore: update pool and python version for test --- .ci/cloudbuild.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.ci/cloudbuild.yaml b/.ci/cloudbuild.yaml index 8517ff647..37b12b1e0 100644 --- a/.ci/cloudbuild.yaml +++ b/.ci/cloudbuild.yaml @@ -14,7 +14,7 @@ steps: - id: run integration tests - name: python:${_VERSION} + name: python:3.13 entrypoint: bash env: - "IP_TYPE=${_IP_TYPE}" @@ -107,11 +107,10 @@ availableSecrets: - versionName: "projects/$PROJECT_ID/secrets/SQLSERVER_DB/versions/latest" env: "SQLSERVER_DB" substitutions: - _VERSION: ${_VERSION} _IP_TYPE: ${_IP_TYPE} options: dynamicSubstitutions: true pool: - name: ${_POOL_NAME} + name: ${_POOL_NAME_2} logging: CLOUD_LOGGING_ONLY \ No newline at end of file