Skip to content

Commit 8f70bdd

Browse files
committed
manage package based workers
1 parent 237486c commit 8f70bdd

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

.kokoro/system.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,22 @@ run_package_test() {
7676
export PROJECT_ID GOOGLE_APPLICATION_CREDENTIALS NOX_FILE NOX_SESSION
7777
export GOOGLE_CLOUD_PROJECT="${PROJECT_ID}"
7878

79+
# Limit pytest-xdist to 4 workers per package. When 3 packages run in parallel,
80+
# if each uses -n=auto they will spawn 16 workers each (48 total threads),
81+
# completely thrashing the CPU and causing all tests to hang/timeout.
82+
export PYTEST_ADDOPTS="-n 4"
83+
7984
# Isolate PIP cache to prevent concurrent pip file lock deadlocks
8085
export PIP_CACHE_DIR="/tmpfs/.pip_cache_$(basename ${package_name})"
8186
mkdir -p "$PIP_CACHE_DIR"
8287

8388
# Isolate gcloud state to prevent SQLite lock deadlocks and project race conditions
8489
export CLOUDSDK_CONFIG="/tmpfs/.gcloud_config_$(basename ${package_name})"
8590
mkdir -p "$CLOUDSDK_CONFIG"
91+
92+
# Isolate boto config (used by storage/bigquery) to prevent lock contention
93+
export BOTO_CONFIG="/tmpfs/.boto_$(basename ${package_name})"
94+
touch "$BOTO_CONFIG"
8695

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

0 commit comments

Comments
 (0)