Skip to content

Commit 8f3c2be

Browse files
committed
Merge branch 'sys_test_large_obj' of github.com:googleapis/python-storage into configurable_flush_interval
2 parents def00f3 + 5bc78db commit 8f3c2be

File tree

4 files changed

+49
-8
lines changed

4 files changed

+49
-8
lines changed

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"

google/cloud/storage/_experimental/asyncio/async_appendable_object_writer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"""
2424
from typing import Optional, Union
2525

26-
from google.api_core import exceptions
2726
from google_crc32c import Checksum
2827

2928
from ._utils import raise_if_no_fast_crc32c

tests/system/test_notification.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def notification_topic(storage_client, publisher_client, topic_path, no_mtls):
6969
publisher_client.set_iam_policy(request={"resource": topic_path, "policy": policy})
7070

7171

72+
@pytest.mark.skip(reason="until b/470069573 is fixed")
7273
def test_notification_create_minimal(
7374
storage_client,
7475
buckets_to_delete,
@@ -94,6 +95,7 @@ def test_notification_create_minimal(
9495
notification.delete()
9596

9697

98+
@pytest.mark.skip(reason="until b/470069573 is fixed")
9799
def test_notification_create_explicit(
98100
storage_client,
99101
buckets_to_delete,
@@ -128,6 +130,7 @@ def test_notification_create_explicit(
128130
notification.delete()
129131

130132

133+
@pytest.mark.skip(reason="until b/470069573 is fixed")
131134
def test_notification_create_w_user_project(
132135
storage_client,
133136
buckets_to_delete,
@@ -156,6 +159,7 @@ def test_notification_create_w_user_project(
156159
notification.delete()
157160

158161

162+
@pytest.mark.skip(reason="until b/470069573 is fixed")
159163
def test_notification_create_wo_topic_name(
160164
storage_client,
161165
buckets_to_delete,
@@ -184,6 +188,7 @@ def test_notification_create_wo_topic_name(
184188
notification.create()
185189

186190

191+
@pytest.mark.skip(reason="until b/470069573 is fixed")
187192
def test_bucket_get_notification(
188193
storage_client,
189194
buckets_to_delete,

tests/unit/asyncio/test_async_appendable_object_writer.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import pytest
1616
from unittest import mock
1717

18+
from google_crc32c import Checksum
19+
1820
from google.api_core import exceptions
1921
from google.cloud.storage._experimental.asyncio.async_appendable_object_writer import (
2022
AsyncAppendableObjectWriter,
@@ -512,10 +514,15 @@ async def test_append_sends_data_in_chunks(mock_write_object_stream, mock_client
512514
# First chunk
513515
assert first_call[0][0].write_offset == 100
514516
assert len(first_call[0][0].checksummed_data.content) == _MAX_CHUNK_SIZE_BYTES
515-
517+
assert first_call[0][0].checksummed_data.crc32c == int.from_bytes(
518+
Checksum(data[:_MAX_CHUNK_SIZE_BYTES]).digest(), byteorder="big"
519+
)
516520
# Second chunk
517521
assert second_call[0][0].write_offset == 100 + _MAX_CHUNK_SIZE_BYTES
518522
assert len(second_call[0][0].checksummed_data.content) == 1
523+
assert second_call[0][0].checksummed_data.crc32c == int.from_bytes(
524+
Checksum(data[_MAX_CHUNK_SIZE_BYTES:]).digest(), byteorder="big"
525+
)
519526

520527
assert writer.offset == 100 + len(data)
521528
writer.simple_flush.assert_not_awaited()

0 commit comments

Comments
 (0)