Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 70 additions & 2 deletions .kokoro/system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ run_package_test() {
export PROJECT_ID GOOGLE_APPLICATION_CREDENTIALS NOX_FILE NOX_SESSION
export GOOGLE_CLOUD_PROJECT="${PROJECT_ID}"

# Isolate PIP cache to prevent concurrent pip file lock deadlocks
export PIP_CACHE_DIR="/tmpfs/.pip_cache_$(basename ${package_name})"
mkdir -p "$PIP_CACHE_DIR"

# Isolate gcloud state to prevent SQLite lock deadlocks and project race conditions
export CLOUDSDK_CONFIG="/tmpfs/.gcloud_config_$(basename ${package_name})"
mkdir -p "$CLOUDSDK_CONFIG"

# Isolate boto config (used by storage/bigquery) to prevent lock contention
export BOTO_CONFIG="/tmpfs/.boto_$(basename ${package_name})"
touch "$BOTO_CONFIG"

gcloud auth activate-service-account --key-file="$GOOGLE_APPLICATION_CREDENTIALS"
gcloud config set project "$PROJECT_ID"

Expand Down Expand Up @@ -140,10 +152,66 @@ for path in `find 'packages' \
set -e

if [[ "${package_modified}" -gt 0 || "$KOKORO_BUILD_ARTIFACTS_SUBDIR" == *"continuous"* ]]; then
# Call the function - its internal exports won't affect the next loop
run_package_test "$package_name" || RETVAL=$?
PACKAGES_TO_TEST="${PACKAGES_TO_TEST} ${package_name}"
else
echo "No changes in ${package_name} and not a continuous build, skipping."
fi
done

if [ -n "$PACKAGES_TO_TEST" ]; then
export -f run_package_test
export system_test_script PROJECT_ROOT KOKORO_GFILE_DIR

# 1. DYNAMIC ROUTING: Automatically detect which packages are CPU hogs by checking if they install pytest-xdist or hardcode workers
LIGHT_TO_TEST=""
HEAVY_TO_TEST=""
for pkg in $PACKAGES_TO_TEST; do
if grep -qE "pytest-xdist|-n=auto|-n=[0-9]+" "packages/$pkg/noxfile.py" "packages/$pkg/setup.py" 2>/dev/null; then
HEAVY_TO_TEST="$HEAVY_TO_TEST $pkg"
else
LIGHT_TO_TEST="$LIGHT_TO_TEST $pkg"
fi
done

# 2. PARALLEL LANE (Live Streaming): Run light packages with a parallel job queue.
# We prefix every line with the package name so output streams LIVE and remains readable.
if [ -n "$LIGHT_TO_TEST" ]; then
echo "============================================================"
echo "Running Lightweight Packages in Parallel (4 workers max)"
echo "============================================================"
for pkg in $LIGHT_TO_TEST; do
(
timeout 15m bash -c "run_package_test \"$pkg\" < /dev/null" 2>&1 | awk -v prefix="[$pkg]" '{print prefix, $0}'
if [ ${PIPESTATUS[0]} -ne 0 ]; then touch ".failed_$pkg"; fi
) &
# Limit parallel background jobs to 4
while [ $(jobs -r | wc -l) -ge 4 ]; do sleep 1; done
done
wait # Wait for all parallel jobs to finish
fi

# 3. SEQUENTIAL VIP LANE: Run heavy packages one-by-one so they have 100% of the VM resources.
if [ -n "$HEAVY_TO_TEST" ]; then
echo "============================================================"
echo "Running CPU-Intensive Packages Sequentially"
echo "============================================================"
for pkg in $HEAVY_TO_TEST; do
if [ -n "$pkg" ]; then
echo "[$pkg] Starting sequential execution..."
timeout 25m bash -c "run_package_test \"$pkg\" < /dev/null" 2>&1 | awk -v prefix="[$pkg]" '{print prefix, $0}'
if [ ${PIPESTATUS[0]} -ne 0 ]; then touch ".failed_$pkg"; fi
fi
done
fi

# 4. FAIL STATE EVALUATION
for failed_marker in .failed_*; do
if [ -f "$failed_marker" ]; then
failed_pkg="${failed_marker#.failed_}"
echo "--- FAILED: $failed_pkg ---"
RETVAL=1
fi
done
fi

exit ${RETVAL}
2 changes: 2 additions & 0 deletions packages/bigframes/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/bigquery-magics/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/django-google-spanner/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,5 @@
extras_require=extras,
python_requires=">=3.10",
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/gapic-generator/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-auth/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,5 @@
"Topic :: Internet :: WWW/HTTP",
],
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-access-approval/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-automl/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-bigquery-connection/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-bigquery-datatransfer/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-bigquery-reservation/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-bigquery-storage/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-bigquery/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
import setuptools # type: ignore

setuptools.setup()

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-bigtable/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-compute/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-container/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-dataproc/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-datastore/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-dlp/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-dns/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-error-reporting/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-firestore/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-kms/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-logging/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-monitoring/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-ndb/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ def main():

if __name__ == "__main__":
main()

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-os-config/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-pubsub/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-scheduler/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-spanner-dbapi-driver/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-spanner/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-speech/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-storage/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-tasks/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-testutils/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,5 @@
],
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-texttospeech/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-translate/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-videointelligence/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-cloud-vision/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/google-resumable-media/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,5 @@
'Topic :: Internet',
],
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/pandas-gbq/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/sqlalchemy-bigquery/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,5 @@ def readme():
# obsolete legitimate ones.
obsoletes=["pybigquery"],
)

# trigger system test
2 changes: 2 additions & 0 deletions packages/sqlalchemy-spanner/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,5 @@
include_package_data=True,
zip_safe=False,
)

# trigger system test
Loading