Skip to content

Commit 64ac5f1

Browse files
authored
chore(librarian): enable generation for google-cloud-storage (#16803)
This PR - Enables code generation for google-cloud-storage - Formats handwritten files using `nox-s format` - Disables presubmit `python-sdk-zb-system-test (gcs-aiml-clients-testing-101) ` which is broken. See #16487. - Fixes the failing `Kokoro Pre-release Tests` seen in #16799 Releases are already blocked for `google-cloud-storage` https://github.com/googleapis/google-cloud-python/blob/81b7fad2bbc450a846c9769959a7c3a62ea844cb/.librarian/config.yaml#L22-L25 Closes #16799
1 parent 6102268 commit 64ac5f1

10 files changed

Lines changed: 143 additions & 145 deletions

File tree

.librarian/generator-input/client-post-processing/storage-integration.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ replacements:
4343
"Credentials must be set via environment variable GOOGLE_APPLICATION_CREDENTIALS"
4444
)
4545
46-
# Install all test dependencies
47-
session.install("mock", "pytest", "pytest-cov", "brotli")
46+
# Install dependencies for the unit test environment
47+
unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
48+
session.install(*unit_deps_all)
4849
4950
# Install dependencies needed for system tests
5051
session.install(
@@ -59,7 +60,8 @@ replacements:
5960
6061
prerel_deps = [
6162
"google-api-core",
62-
"google-auth",
63+
# Exclude google-auth 3.0.0.dev0 which was yanked
64+
"google-auth!=3.0.0.dev0",
6365
"google-cloud-core",
6466
"google-crc32c",
6567
"google-resumable-media",
@@ -88,9 +90,7 @@ replacements:
8890
f"import {version_namespace}; print({version_namespace}.__version__)",
8991
)
9092
# Remaining dependencies
91-
other_deps = [
92-
"requests",
93-
]
93+
other_deps = ["requests", "pyopenssl"]
9494
session.install(*other_deps)
9595
9696
session.run(

librarian.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3442,7 +3442,6 @@ libraries:
34423442
apis:
34433443
- path: google/storage/v2
34443444
description_override: 'is a durable and highly available object storage service. Google Cloud Storage is almost infinitely scalable and guarantees consistency: when a write succeeds, the latest copy of the object will be returned to any GET, globally.'
3445-
skip_generate: true
34463445
python:
34473446
library_type: GAPIC_MANUAL
34483447
opt_args_by_api:

packages/google-cloud-storage/cloudbuild/zb-system-tests-cloudbuild.yaml

Lines changed: 124 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -8,128 +8,130 @@ substitutions:
88

99

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

134136
options:
135137
logging: CLOUD_LOGGING_ONLY

packages/google-cloud-storage/google/cloud/storage/asyncio/async_write_object_stream.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
from google.api_core.bidi_async import AsyncBidiRpc
1919

2020
from google.cloud import _storage_v2
21-
from google.cloud.storage import Blob
22-
from google.cloud.storage import _grpc_conversions
21+
from google.cloud.storage import Blob, _grpc_conversions
2322
from google.cloud.storage.asyncio import _utils
2423
from google.cloud.storage.asyncio.async_abstract_object_stream import (
2524
_AsyncAbstractObjectStream,

packages/google-cloud-storage/noxfile.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,9 @@ def prerelease_deps(session, protobuf_implementation):
567567
"Credentials must be set via environment variable GOOGLE_APPLICATION_CREDENTIALS"
568568
)
569569

570-
# Install all test dependencies
571-
session.install("mock", "pytest", "pytest-cov", "brotli")
570+
# Install dependencies for the unit test environment
571+
unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
572+
session.install(*unit_deps_all)
572573

573574
# Install dependencies needed for system tests
574575
session.install(
@@ -583,7 +584,8 @@ def prerelease_deps(session, protobuf_implementation):
583584

584585
prerel_deps = [
585586
"google-api-core",
586-
"google-auth",
587+
# Exclude google-auth 3.0.0.dev0 which was yanked
588+
"google-auth!=3.0.0.dev0",
587589
"google-cloud-core",
588590
"google-crc32c",
589591
"google-resumable-media",
@@ -612,9 +614,7 @@ def prerelease_deps(session, protobuf_implementation):
612614
f"import {version_namespace}; print({version_namespace}.__version__)",
613615
)
614616
# Remaining dependencies
615-
other_deps = [
616-
"requests",
617-
]
617+
other_deps = ["requests", "pyopenssl"]
618618
session.install(*other_deps)
619619

620620
session.run(

packages/google-cloud-storage/tests/system/test_zonal.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111
import pytest
1212
from google.api_core.exceptions import FailedPrecondition, NotFound, OutOfRange
1313

14+
# current library imports
15+
from google.cloud import kms
1416
from google.cloud.storage.asyncio.async_appendable_object_writer import (
1517
_DEFAULT_FLUSH_INTERVAL_BYTES,
1618
AsyncAppendableObjectWriter,
1719
)
18-
19-
# current library imports
20-
from google.cloud import kms
2120
from google.cloud.storage.asyncio.async_grpc_client import AsyncGrpcClient
2221
from google.cloud.storage.asyncio.async_multi_range_downloader import (
2322
AsyncMultiRangeDownloader,

packages/google-cloud-storage/tests/unit/asyncio/retry/test_reads_resumption_strategy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
import io
1717
import unittest
1818

19-
from google.api_core import exceptions
2019
import google_crc32c
20+
from google.api_core import exceptions
2121

2222
from google.cloud import _storage_v2 as storage_v2
2323
from google.cloud._storage_v2.types.storage import BidiReadObjectRedirectedError

packages/google-cloud-storage/tests/unit/asyncio/test_async_appendable_object_writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
import pytest
2020
from google.api_core import exceptions
2121
from google.rpc import status_pb2
22-
from google.cloud.storage import Blob
2322

2423
from google.cloud._storage_v2.types import storage as storage_type
2524
from google.cloud._storage_v2.types.storage import BidiWriteObjectRedirectedError
25+
from google.cloud.storage import Blob
2626
from google.cloud.storage.asyncio.async_appendable_object_writer import (
2727
_DEFAULT_FLUSH_INTERVAL_BYTES,
2828
_MAX_CHUNK_SIZE_BYTES,

packages/google-cloud-storage/tests/unit/asyncio/test_async_multi_range_downloader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
from unittest import mock
1818
from unittest.mock import AsyncMock
1919

20+
import google_crc32c
2021
import pytest
2122
from google.api_core import exceptions
22-
import google_crc32c
2323

2424
from google.cloud import _storage_v2
2525
from google.cloud.storage.asyncio import async_read_object_stream

packages/google-cloud-storage/tests/unit/asyncio/test_async_write_object_stream.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
import pytest
2020

2121
from google.cloud import _storage_v2
22-
from google.cloud.storage import Blob
23-
from google.cloud.storage import Bucket
22+
from google.cloud.storage import Blob, Bucket
2423
from google.cloud.storage.asyncio.async_write_object_stream import (
2524
_AsyncWriteObjectStream,
2625
)

0 commit comments

Comments
 (0)