@@ -10,128 +10,128 @@ substitutions:
1010steps :
1111 - name : ' bash'
1212 args : ['echo', 'This job is currently disabled. See https://github.com/googleapis/google-cloud-python/issues/16487. Skipping tests...']
13- # # Step 0: Generate a persistent SSH key for this build run.
14- # # This prevents gcloud from adding a new key to the OS Login profile on every ssh/scp command.
15- # - name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
16- # id: "generate-ssh-key"
17- # entrypoint: "bash"
18- # args:
19- # - "-c"
20- # - |
21- # mkdir -p /workspace/.ssh
22- # # Generate the SSH key
23- # ssh-keygen -t rsa -f /workspace/.ssh/google_compute_engine -N '' -C gcb
24- # # Save the public key content to a file for the cleanup step
25- # cat /workspace/.ssh/google_compute_engine.pub > /workspace/gcb_ssh_key.pub
26- # waitFor: ["-"]
27-
28- # - name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
29- # id: "cleanup-old-keys"
30- # entrypoint: "bash"
31- # args:
32- # - "-c"
33- # - |
34- # #!/bin/bash
35- # set -e
36-
37- # echo "Fetching OS Login SSH keys..."
38- # echo "Removing all keys."
39- # echo "---------------------------------------------------------------------"
40-
41- # FINGERPRINTS_TO_DELETE=$$(gcloud compute os-login ssh-keys list \
42- # --format="value(fingerprint)")
43-
44- # echo "Keys to delete: $$FINGERPRINTS_TO_DELETE"
45-
46- # if [ -z "$$FINGERPRINTS_TO_DELETE" ]; then
47- # echo "No keys found to delete. Nothing to do."
48- # exit 0
49- # fi
50-
51- # while IFS= read -r FINGERPRINT; do
52- # if [ -n "$$FINGERPRINT" ]; then
53- # echo "Deleting key with fingerprint: $$FINGERPRINT"
54- # gcloud compute os-login ssh-keys remove \
55- # --key="$$FINGERPRINT" \
56- # --quiet || true
57- # fi
58- # done <<< "$$FINGERPRINTS_TO_DELETE"
59-
60- # echo "---------------------------------------------------------------------"
61- # echo "Cleanup complete."
62-
63- # # Step 1 Create a GCE VM to run the tests.
64- # # The VM is created in the same zone as the buckets to test rapid storage features.
65- # # It's given the 'cloud-platform' scope to allow it to access GCS and other services.
66- # - name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
67- # id: "create-vm"
68- # entrypoint: "gcloud"
69- # args:
70- # - "compute"
71- # - "instances"
72- # - "create"
73- # - "${_VM_NAME}"
74- # - "--project=${PROJECT_ID}"
75- # - "--zone=${_ZONE}"
76- # - "--machine-type=e2-medium"
77- # - "--image-family=debian-13"
78- # - "--image-project=debian-cloud"
79- # - "--service-account=${_ZONAL_VM_SERVICE_ACCOUNT}"
80- # - "--scopes=https://www.googleapis.com/auth/devstorage.full_control,https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/devstorage.read_write,https://www.googleapis.com/auth/cloudkms"
81- # - "--metadata=enable-oslogin=TRUE"
82- # waitFor: ["-"]
83-
84- # # Step 2: Run the integration tests inside the newly created VM and cleanup.
85- # # This step uses 'gcloud compute ssh' to execute a remote script.
86- # # The VM is deleted after tests are run, regardless of success.
87- # - name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
88- # id: "run-tests-and-delete-vm"
89- # entrypoint: "bash"
90- # args:
91- # - "-c"
92- # - |
93- # set -e
94- # # Wait for the VM to be fully initialized and SSH to be ready.
95- # for i in {1..10}; do
96- # if gcloud compute ssh ${_VM_NAME} --zone=${_ZONE} --internal-ip --ssh-key-file=/workspace/.ssh/google_compute_engine --command="echo VM is ready"; then
97- # break
98- # fi
99- # echo "Waiting for VM to become available... (attempt $i/10)"
100- # sleep 15
101- # done
102- # # copy the script to the VM
103- # 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
104-
105- # # Execute the script on the VM via SSH.
106- # # Capture the exit code to ensure cleanup happens before the build fails.
107- # set +e
108- # 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"
109- # EXIT_CODE=$?
110- # set -e
111-
112- # echo "--- Deleting GCE VM ---"
113- # gcloud compute instances delete "${_VM_NAME}" --zone=${_ZONE} --quiet
114-
115- # # Exit with the original exit code from the test script.
116- # exit $$EXIT_CODE
117- # waitFor:
118- # - "create-vm"
119- # - "generate-ssh-key"
120- # - "cleanup-old-keys"
121-
122- # - name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
123- # id: "cleanup-ssh-key"
124- # entrypoint: "bash"
125- # args:
126- # - "-c"
127- # - |
128- # echo "--- Removing SSH key from OS Login profile to prevent accumulation ---"
129- # gcloud compute os-login ssh-keys remove \
130- # --key-file=/workspace/gcb_ssh_key.pub || true
131- # waitFor:
132- # - "run-tests-and-delete-vm"
133-
134- # timeout: "3600s" # 60 minutes
13+ # Step 0: Generate a persistent SSH key for this build run.
14+ # This prevents gcloud from adding a new key to the OS Login profile on every ssh/scp command.
15+ - name : " gcr.io/google.com/cloudsdktool/cloud-sdk"
16+ id : " generate-ssh-key"
17+ entrypoint : " bash"
18+ args :
19+ - " -c"
20+ - |
21+ mkdir -p /workspace/.ssh
22+ # Generate the SSH key
23+ ssh-keygen -t rsa -f /workspace/.ssh/google_compute_engine -N '' -C gcb
24+ # Save the public key content to a file for the cleanup step
25+ cat /workspace/.ssh/google_compute_engine.pub > /workspace/gcb_ssh_key.pub
26+ waitFor : ["-"]
27+
28+ - name : " gcr.io/google.com/cloudsdktool/cloud-sdk"
29+ id : " cleanup-old-keys"
30+ entrypoint : " bash"
31+ args :
32+ - " -c"
33+ - |
34+ #!/bin/bash
35+ set -e
36+
37+ echo "Fetching OS Login SSH keys..."
38+ echo "Removing all keys."
39+ echo "---------------------------------------------------------------------"
40+
41+ FINGERPRINTS_TO_DELETE=$$(gcloud compute os-login ssh-keys list \
42+ --format="value(fingerprint)")
43+
44+ echo "Keys to delete: $$FINGERPRINTS_TO_DELETE"
45+
46+ if [ -z "$$FINGERPRINTS_TO_DELETE" ]; then
47+ echo "No keys found to delete. Nothing to do."
48+ exit 0
49+ fi
50+
51+ while IFS= read -r FINGERPRINT; do
52+ if [ -n "$$FINGERPRINT" ]; then
53+ echo "Deleting key with fingerprint: $$FINGERPRINT"
54+ gcloud compute os-login ssh-keys remove \
55+ --key="$$FINGERPRINT" \
56+ --quiet || true
57+ fi
58+ done <<< "$$FINGERPRINTS_TO_DELETE"
59+
60+ echo "---------------------------------------------------------------------"
61+ echo "Cleanup complete."
62+
63+ # Step 1 Create a GCE VM to run the tests.
64+ # The VM is created in the same zone as the buckets to test rapid storage features.
65+ # It's given the 'cloud-platform' scope to allow it to access GCS and other services.
66+ - name : " gcr.io/google.com/cloudsdktool/cloud-sdk"
67+ id : " create-vm"
68+ entrypoint : " gcloud"
69+ args :
70+ - " compute"
71+ - " instances"
72+ - " create"
73+ - " ${_VM_NAME}"
74+ - " --project=${PROJECT_ID}"
75+ - " --zone=${_ZONE}"
76+ - " --machine-type=e2-medium"
77+ - " --image-family=debian-13"
78+ - " --image-project=debian-cloud"
79+ - " --service-account=${_ZONAL_VM_SERVICE_ACCOUNT}"
80+ - " --scopes=https://www.googleapis.com/auth/devstorage.full_control,https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/devstorage.read_write,https://www.googleapis.com/auth/cloudkms"
81+ - " --metadata=enable-oslogin=TRUE"
82+ waitFor : ["-"]
83+
84+ # Step 2: Run the integration tests inside the newly created VM and cleanup.
85+ # This step uses 'gcloud compute ssh' to execute a remote script.
86+ # The VM is deleted after tests are run, regardless of success.
87+ - name : " gcr.io/google.com/cloudsdktool/cloud-sdk"
88+ id : " run-tests-and-delete-vm"
89+ entrypoint : " bash"
90+ args :
91+ - " -c"
92+ - |
93+ set -e
94+ # Wait for the VM to be fully initialized and SSH to be ready.
95+ for i in {1..10}; do
96+ if gcloud compute ssh ${_VM_NAME} --zone=${_ZONE} --internal-ip --ssh-key-file=/workspace/.ssh/google_compute_engine --command="echo VM is ready"; then
97+ break
98+ fi
99+ echo "Waiting for VM to become available... (attempt $i/10)"
100+ sleep 15
101+ done
102+ # copy the script to the VM
103+ 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
104+
105+ # Execute the script on the VM via SSH.
106+ # Capture the exit code to ensure cleanup happens before the build fails.
107+ set +e
108+ 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"
109+ EXIT_CODE=$?
110+ set -e
111+
112+ echo "--- Deleting GCE VM ---"
113+ gcloud compute instances delete "${_VM_NAME}" --zone=${_ZONE} --quiet
114+
115+ # Exit with the original exit code from the test script.
116+ exit $$EXIT_CODE
117+ waitFor :
118+ - " create-vm"
119+ - " generate-ssh-key"
120+ - " cleanup-old-keys"
121+
122+ - name : " gcr.io/google.com/cloudsdktool/cloud-sdk"
123+ id : " cleanup-ssh-key"
124+ entrypoint : " bash"
125+ args :
126+ - " -c"
127+ - |
128+ echo "--- Removing SSH key from OS Login profile to prevent accumulation ---"
129+ gcloud compute os-login ssh-keys remove \
130+ --key-file=/workspace/gcb_ssh_key.pub || true
131+ waitFor :
132+ - " run-tests-and-delete-vm"
133+
134+ timeout : " 3600s" # 60 minutes
135135
136136options :
137137 logging : CLOUD_LOGGING_ONLY
0 commit comments