From e2c8b31bb89333ee5793350010b38494e08d29e1 Mon Sep 17 00:00:00 2001 From: Chandra Sirimala Date: Wed, 8 Apr 2026 12:18:12 +0000 Subject: [PATCH 1/4] chore: use sparse checkout and fix paths in zonal tests --- packages/google-cloud-storage/cloudbuild/run_zonal_tests.sh | 6 ++++-- .../cloudbuild/zb-system-tests-cloudbuild.yaml | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/google-cloud-storage/cloudbuild/run_zonal_tests.sh b/packages/google-cloud-storage/cloudbuild/run_zonal_tests.sh index 2d42ce6d5f68..7f619f1a19ef 100644 --- a/packages/google-cloud-storage/cloudbuild/run_zonal_tests.sh +++ b/packages/google-cloud-storage/cloudbuild/run_zonal_tests.sh @@ -4,10 +4,12 @@ echo '--- Installing git and cloning repository on VM ---' sudo apt-get update && sudo apt-get install -y git python3-pip python3-venv # Clone the repository and checkout the specific commit from the build trigger. -git clone https://github.com/googleapis/python-storage.git -cd python-storage +git clone --no-checkout --depth 1 --sparse --filter=blob:none https://github.com/googleapis/google-cloud-python.git +cd google-cloud-python +git sparse-checkout set packages/google-cloud-storage git fetch origin "refs/pull/${_PR_NUMBER}/head" git checkout ${COMMIT_SHA} +cd packages/google-cloud-storage echo '--- Installing Python and dependencies on VM ---' diff --git a/packages/google-cloud-storage/cloudbuild/zb-system-tests-cloudbuild.yaml b/packages/google-cloud-storage/cloudbuild/zb-system-tests-cloudbuild.yaml index 26daa8ae92d9..9064f159b7bb 100644 --- a/packages/google-cloud-storage/cloudbuild/zb-system-tests-cloudbuild.yaml +++ b/packages/google-cloud-storage/cloudbuild/zb-system-tests-cloudbuild.yaml @@ -63,12 +63,12 @@ steps: sleep 15 done # copy the script to the VM - gcloud compute scp cloudbuild/run_zonal_tests.sh ${_VM_NAME}:~ --zone=${_ZONE} --internal-ip --ssh-key-file=/workspace/.ssh/google_compute_engine + gcloud compute scp packages/google-cloud-storage/cloudbuild/run_zonal_tests.sh ${_VM_NAME}:~ --zone=${_ZONE} --internal-ip --ssh-key-file=/workspace/.ssh/google_compute_engine # Execute the script on the VM via SSH. # Capture the exit code to ensure cleanup happens before the build fails. set +e - gcloud compute ssh ${_VM_NAME} --zone=${_ZONE} --internal-ip --ssh-key-file=/workspace/.ssh/google_compute_engine --command="ulimit -n {_ULIMIT}; COMMIT_SHA=${COMMIT_SHA} _ZONAL_BUCKET=${_ZONAL_BUCKET} CROSS_REGION_BUCKET=${_CROSS_REGION_BUCKET} _PR_NUMBER=${_PR_NUMBER} bash run_zonal_tests.sh" + gcloud compute ssh ${_VM_NAME} --zone=${_ZONE} --internal-ip --ssh-key-file=/workspace/.ssh/google_compute_engine --command="ulimit -n ${_ULIMIT}; COMMIT_SHA=${COMMIT_SHA} _ZONAL_BUCKET=${_ZONAL_BUCKET} CROSS_REGION_BUCKET=${_CROSS_REGION_BUCKET} _PR_NUMBER=${_PR_NUMBER} bash run_zonal_tests.sh" EXIT_CODE=$? set -e From a545fc6f01bd79bc91cb1ad6074348d57bed79da Mon Sep 17 00:00:00 2001 From: Chandra Sirimala Date: Wed, 8 Apr 2026 12:18:26 +0000 Subject: [PATCH 2/4] chore: remove snippets test from zonal tests --- packages/google-cloud-storage/cloudbuild/run_zonal_tests.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/google-cloud-storage/cloudbuild/run_zonal_tests.sh b/packages/google-cloud-storage/cloudbuild/run_zonal_tests.sh index 7f619f1a19ef..7baabf888753 100644 --- a/packages/google-cloud-storage/cloudbuild/run_zonal_tests.sh +++ b/packages/google-cloud-storage/cloudbuild/run_zonal_tests.sh @@ -29,4 +29,3 @@ export GCE_METADATA_MTLS_MODE=None CURRENT_ULIMIT=$(ulimit -n) echo '--- Running Zonal tests on VM with ulimit set to ---' $CURRENT_ULIMIT pytest -vv -s --log-format='%(asctime)s %(levelname)s %(message)s' --log-date-format='%H:%M:%S' tests/system/test_zonal.py -pytest -vv -s --log-format='%(asctime)s %(levelname)s %(message)s' --log-date-format='%H:%M:%S' samples/snippets/zonal_buckets/zonal_snippets_test.py From 800e78e33781bbad30581a485bfa11cef2282581 Mon Sep 17 00:00:00 2001 From: Chandra Sirimala Date: Thu, 9 Apr 2026 06:51:20 +0000 Subject: [PATCH 3/4] Add cleanup step for OS Login keys in Cloud Build --- .../zb-system-tests-cloudbuild.yaml | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/packages/google-cloud-storage/cloudbuild/zb-system-tests-cloudbuild.yaml b/packages/google-cloud-storage/cloudbuild/zb-system-tests-cloudbuild.yaml index 9064f159b7bb..0084df12191b 100644 --- a/packages/google-cloud-storage/cloudbuild/zb-system-tests-cloudbuild.yaml +++ b/packages/google-cloud-storage/cloudbuild/zb-system-tests-cloudbuild.yaml @@ -23,6 +23,41 @@ steps: cat /workspace/.ssh/google_compute_engine.pub > /workspace/gcb_ssh_key.pub waitFor: ["-"] + - name: "gcr.io/google.com/cloudsdktool/cloud-sdk" + id: "cleanup-old-keys" + entrypoint: "bash" + args: + - "-c" + - | + #!/bin/bash + set -e + + echo "Fetching OS Login SSH keys..." + echo "Removing all keys." + echo "---------------------------------------------------------------------" + + FINGERPRINTS_TO_DELETE=$(gcloud compute os-login ssh-keys list \ + --format="value(fingerprint)") + + echo "Keys to delete: $FINGERPRINTS_TO_DELETE" + + if [ -z "$FINGERPRINTS_TO_DELETE" ]; then + echo "No keys found to delete. Nothing to do." + exit 0 + fi + + while IFS= read -r FINGERPRINT; do + if [ -n "$FINGERPRINT" ]; then + echo "Deleting key with fingerprint: ${FINGERPRINT}" + gcloud compute os-login ssh-keys remove \ + --key="${FINGERPRINT}" \ + --quiet || true + fi + done <<< "$FINGERPRINTS_TO_DELETE" + + echo "---------------------------------------------------------------------" + echo "Cleanup complete." + # Step 1 Create a GCE VM to run the tests. # The VM is created in the same zone as the buckets to test rapid storage features. # It's given the 'cloud-platform' scope to allow it to access GCS and other services. @@ -80,6 +115,7 @@ steps: waitFor: - "create-vm" - "generate-ssh-key" + - "cleanup-old-keys" - name: "gcr.io/google.com/cloudsdktool/cloud-sdk" id: "cleanup-ssh-key" From de1806995442381f857fcd02d99b36d76b6b3c0f Mon Sep 17 00:00:00 2001 From: Chandra Sirimala Date: Thu, 9 Apr 2026 06:59:42 +0000 Subject: [PATCH 4/4] Fix Cloud Build substitutions by escaping shell variables --- .../cloudbuild/zb-system-tests-cloudbuild.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/google-cloud-storage/cloudbuild/zb-system-tests-cloudbuild.yaml b/packages/google-cloud-storage/cloudbuild/zb-system-tests-cloudbuild.yaml index 0084df12191b..868d13958474 100644 --- a/packages/google-cloud-storage/cloudbuild/zb-system-tests-cloudbuild.yaml +++ b/packages/google-cloud-storage/cloudbuild/zb-system-tests-cloudbuild.yaml @@ -36,24 +36,24 @@ steps: echo "Removing all keys." echo "---------------------------------------------------------------------" - FINGERPRINTS_TO_DELETE=$(gcloud compute os-login ssh-keys list \ + FINGERPRINTS_TO_DELETE=$$(gcloud compute os-login ssh-keys list \ --format="value(fingerprint)") - echo "Keys to delete: $FINGERPRINTS_TO_DELETE" + echo "Keys to delete: $$FINGERPRINTS_TO_DELETE" - if [ -z "$FINGERPRINTS_TO_DELETE" ]; then + if [ -z "$$FINGERPRINTS_TO_DELETE" ]; then echo "No keys found to delete. Nothing to do." exit 0 fi while IFS= read -r FINGERPRINT; do - if [ -n "$FINGERPRINT" ]; then - echo "Deleting key with fingerprint: ${FINGERPRINT}" + if [ -n "$$FINGERPRINT" ]; then + echo "Deleting key with fingerprint: $$FINGERPRINT" gcloud compute os-login ssh-keys remove \ - --key="${FINGERPRINT}" \ + --key="$$FINGERPRINT" \ --quiet || true fi - done <<< "$FINGERPRINTS_TO_DELETE" + done <<< "$$FINGERPRINTS_TO_DELETE" echo "---------------------------------------------------------------------" echo "Cleanup complete."