Skip to content

Commit c8ac135

Browse files
chore(tests): break up sqlalchemy system tests (#18239)
Sqlalchemy-spanner and sqlalchemy-bigquery have two sets of integration tests: standard system tests, and "compliance" checks. Each of these can take > 1 hour, which can put strain on our single kokoro system test when run sequentially This PR drops the compliance checks from the `Kokoro System` check, and breaks them out into their own test run --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent f2267bf commit c8ac135

6 files changed

Lines changed: 34 additions & 5 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Only run compliance nox session.
4+
env_vars: {
5+
key: "NOX_SESSION"
6+
value: "compliance"
7+
}

.kokoro/presubmit/system.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ env_vars: {
55
key: "NOX_SESSION"
66
value: "system-3.12"
77
}
8+
9+
# Skip compliance tests in system job since they run in dedicated compliance job
10+
env_vars: {
11+
key: "RUN_COMPLIANCE_TESTS"
12+
value: "false"
13+
}

.kokoro/system.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,12 @@ for path in `find 'packages' \
263263
files_to_check=("${package_path}")
264264
fi
265265

266+
# When running compliance tests, only test packages that have compliance suites
267+
if [[ "${NOX_SESSION:-}" == "compliance"* && "${package_name:-}" != "sqlalchemy-"* ]]; then
268+
printf "SKIP %-20s %-40s %s\n" "[not_applicable]" "${package_name}" "${commit_hash:-HEAD}"
269+
continue
270+
fi
271+
266272
set +e
267273
# Passing the array expanded as arguments to git diff.
268274
package_modified=$(git diff "${KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH}...${KOKORO_GITHUB_PULL_REQUEST_COMMIT}" -- "${files_to_check[@]}" | wc -l)

packages/sqlalchemy-bigquery/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ SQLAlchemy Dialect for BigQuery
33

44
|GA| |pypi| |versions|
55

6-
`SQLALchemy Dialects`_
6+
`SQLAlchemy Dialects`_
77

88
- `Dialect Documentation`_
99
- `Product Documentation`_

packages/sqlalchemy-spanner/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Spanner dialect for SQLAlchemy
44
Spanner dialect for SQLAlchemy represents an interface API designed to
55
make it possible to control Cloud Spanner databases with SQLAlchemy API.
66
The dialect is built on top of `the Spanner DB
7-
API <https://github.com/googleapis/python-spanner/tree/master/google/cloud/spanner_dbapi>`__,
7+
API <https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-spanner/google/cloud/spanner_dbapi>`__,
88
which is designed in accordance with
99
`PEP-249 <https://www.python.org/dev/peps/pep-0249/>`__.
1010

packages/sqlalchemy-spanner/noxfile.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def lint_setup_py(session):
188188
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
189189

190190

191-
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS[0])
191+
@nox.session(python=SYSTEM_COMPLIANCE_MIGRATION_TEST_PYTHON_VERSIONS[0])
192192
def compliance_test_14(session):
193193
"""Run SQLAlchemy dialect compliance test suite."""
194194
config_file = f"test_compliance_14_{session.python}_{uuid.uuid4().hex[:6]}.cfg"
@@ -495,10 +495,10 @@ def system(session, test_type):
495495
"Credentials or emulator host must be set via environment variable"
496496
)
497497

498-
if os.environ.get("RUN_COMPLIANCE_TESTS", "true") == "false" and not os.environ.get(
498+
if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false" and not os.environ.get(
499499
"SPANNER_EMULATOR_HOST", ""
500500
):
501-
session.skip("RUN_COMPLIANCE_TESTS is set to false, skipping")
501+
session.skip("RUN_SYSTEM_TESTS is set to false, skipping")
502502

503503
if test_type == "system" and session.python not in SYSTEM_TEST_PYTHON_VERSIONS:
504504
session.skip("Standard system tests configured to run exclusively on 3.12")
@@ -535,6 +535,16 @@ def system(session, test_type):
535535
)
536536

537537

538+
@nox.session(python=SYSTEM_COMPLIANCE_MIGRATION_TEST_PYTHON_VERSIONS)
539+
@nox.parametrize(
540+
"test_type",
541+
["compliance_14", "compliance_20"],
542+
)
543+
def compliance(session, test_type):
544+
"""Run SQLAlchemy dialect compliance test suite."""
545+
system(session, test_type=test_type)
546+
547+
538548
@nox.session(python=DEFAULT_PYTHON_VERSION)
539549
def mypy(session):
540550
"""Run the type checker."""

0 commit comments

Comments
 (0)