Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Commit dc33ecb

Browse files
authored
Merge branch 'main' into bidi_writes_checksum
2 parents c79b2e2 + d6b8f55 commit dc33ecb

1 file changed

Lines changed: 36 additions & 6 deletions

File tree

cloudbuild/zb-system-tests-cloudbuild.yaml

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,25 @@ substitutions:
22
_REGION: "us-central1"
33
_ZONE: "us-central1-a"
44
_SHORT_BUILD_ID: ${BUILD_ID:0:8}
5+
_VM_NAME: "py-sdk-sys-test-${_SHORT_BUILD_ID}"
6+
7+
58

69
steps:
10+
# Step 0: Generate a persistent SSH key for this build run.
11+
# This prevents gcloud from adding a new key to the OS Login profile on every ssh/scp command.
12+
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
13+
id: "generate-ssh-key"
14+
entrypoint: "bash"
15+
args:
16+
- "-c"
17+
- |
18+
mkdir -p /workspace/.ssh
19+
# Generate the SSH key
20+
ssh-keygen -t rsa -f /workspace/.ssh/google_compute_engine -N '' -C gcb
21+
# Save the public key content to a file for the cleanup step
22+
cat /workspace/.ssh/google_compute_engine.pub > /workspace/gcb_ssh_key.pub
23+
waitFor: ["-"]
724

825
# Step 1 Create a GCE VM to run the tests.
926
# The VM is created in the same zone as the buckets to test rapid storage features.
@@ -15,7 +32,7 @@ steps:
1532
- "compute"
1633
- "instances"
1734
- "create"
18-
- "gcsfs-test-vm-${_SHORT_BUILD_ID}"
35+
- "${_VM_NAME}"
1936
- "--project=${PROJECT_ID}"
2037
- "--zone=${_ZONE}"
2138
- "--machine-type=e2-medium"
@@ -38,33 +55,46 @@ steps:
3855
set -e
3956
# Wait for the VM to be fully initialized and SSH to be ready.
4057
for i in {1..10}; do
41-
if gcloud compute ssh gcsfs-test-vm-${_SHORT_BUILD_ID} --zone=${_ZONE} --internal-ip --command="echo VM is ready"; then
58+
if gcloud compute ssh ${_VM_NAME} --zone=${_ZONE} --internal-ip --ssh-key-file=/workspace/.ssh/google_compute_engine --command="echo VM is ready"; then
4259
break
4360
fi
4461
echo "Waiting for VM to become available... (attempt $i/10)"
4562
sleep 15
4663
done
4764
# copy the script to the VM
48-
gcloud compute scp cloudbuild/run_zonal_tests.sh gcsfs-test-vm-${_SHORT_BUILD_ID}:~ --zone=${_ZONE} --internal-ip
65+
gcloud compute scp cloudbuild/run_zonal_tests.sh ${_VM_NAME}:~ --zone=${_ZONE} --internal-ip --ssh-key-file=/workspace/.ssh/google_compute_engine
4966
5067
# Execute the script on the VM via SSH.
5168
# Capture the exit code to ensure cleanup happens before the build fails.
5269
set +e
53-
gcloud compute ssh gcsfs-test-vm-${_SHORT_BUILD_ID} --zone=${_ZONE} --internal-ip --command="COMMIT_SHA=${COMMIT_SHA} _ZONAL_BUCKET=${_ZONAL_BUCKET} bash run_zonal_tests.sh"
70+
gcloud compute ssh ${_VM_NAME} --zone=${_ZONE} --internal-ip --ssh-key-file=/workspace/.ssh/google_compute_engine --command="COMMIT_SHA=${COMMIT_SHA} _ZONAL_BUCKET=${_ZONAL_BUCKET} bash run_zonal_tests.sh"
5471
EXIT_CODE=$?
5572
set -e
5673
5774
echo "--- Deleting GCE VM ---"
58-
gcloud compute instances delete "gcsfs-test-vm-${_SHORT_BUILD_ID}" --zone=${_ZONE} --quiet
75+
gcloud compute instances delete "${_VM_NAME}" --zone=${_ZONE} --quiet
5976
6077
# Exit with the original exit code from the test script.
6178
exit $$EXIT_CODE
6279
waitFor:
6380
- "create-vm"
81+
- "generate-ssh-key"
82+
83+
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
84+
id: "cleanup-ssh-key"
85+
entrypoint: "bash"
86+
args:
87+
- "-c"
88+
- |
89+
echo "--- Removing SSH key from OS Login profile to prevent accumulation ---"
90+
gcloud compute os-login ssh-keys remove \
91+
--key-file=/workspace/gcb_ssh_key.pub || true
92+
waitFor:
93+
- "run-tests-and-delete-vm"
6494

6595
timeout: "3600s" # 60 minutes
6696

6797
options:
6898
logging: CLOUD_LOGGING_ONLY
6999
pool:
70-
name: "projects/${PROJECT_ID}/locations/us-central1/workerPools/cloud-build-worker-pool"
100+
name: "projects/${PROJECT_ID}/locations/us-central1/workerPools/cloud-build-worker-pool"

0 commit comments

Comments
 (0)