Skip to content

Commit 842e5e2

Browse files
committed
Merge branch 'configurable_flush_interval' of github.com:googleapis/python-storage into helpers
2 parents 2fbe83d + 8f3c2be commit 842e5e2

File tree

4 files changed

+52
-11
lines changed

4 files changed

+52
-11
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
@@ -24,7 +24,6 @@
2424
from io import BufferedReader
2525
from typing import Optional, Union
2626

27-
from google.api_core import exceptions
2827
from google_crc32c import Checksum
2928

3029
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: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import pytest
1717
from unittest import mock
1818

19+
from google_crc32c import Checksum
20+
1921
from google.api_core import exceptions
2022
from google.cloud.storage._experimental.asyncio.async_appendable_object_writer import (
2123
AsyncAppendableObjectWriter,
@@ -32,7 +34,7 @@
3234
GENERATION = 123
3335
WRITE_HANDLE = b"test-write-handle"
3436
PERSISTED_SIZE = 456
35-
_ONE_MIB = 1024 * 1024
37+
EIGHT_MIB = 8 * 1024 * 1024
3638

3739

3840
@pytest.fixture
@@ -103,10 +105,10 @@ def test_init_with_writer_options(mock_write_object_stream, mock_client):
103105
mock_client,
104106
BUCKET,
105107
OBJECT,
106-
writer_options={"FLUSH_INTERVAL_BYTES": 8 * _ONE_MIB},
108+
writer_options={"FLUSH_INTERVAL_BYTES": EIGHT_MIB},
107109
)
108110

109-
assert writer.flush_interval == 8 * _ONE_MIB
111+
assert writer.flush_interval == EIGHT_MIB
110112
assert writer.bytes_appended_since_last_flush == 0
111113

112114
mock_write_object_stream.assert_called_once_with(
@@ -511,10 +513,15 @@ async def test_append_sends_data_in_chunks(mock_write_object_stream, mock_client
511513
# First chunk
512514
assert first_call[0][0].write_offset == 100
513515
assert len(first_call[0][0].checksummed_data.content) == _MAX_CHUNK_SIZE_BYTES
514-
516+
assert first_call[0][0].checksummed_data.crc32c == int.from_bytes(
517+
Checksum(data[:_MAX_CHUNK_SIZE_BYTES]).digest(), byteorder="big"
518+
)
515519
# Second chunk
516520
assert second_call[0][0].write_offset == 100 + _MAX_CHUNK_SIZE_BYTES
517521
assert len(second_call[0][0].checksummed_data.content) == 1
522+
assert second_call[0][0].checksummed_data.crc32c == int.from_bytes(
523+
Checksum(data[_MAX_CHUNK_SIZE_BYTES:]).digest(), byteorder="big"
524+
)
518525

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

0 commit comments

Comments
 (0)