From b20c1fbfb85f349143ab4e1a070c0210b554fe3e Mon Sep 17 00:00:00 2001 From: Chandra Sirimala Date: Fri, 20 Mar 2026 12:49:06 +0000 Subject: [PATCH 1/6] fix: run bidi_tests independently --- noxfile.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/noxfile.py b/noxfile.py index 6bce85327..8664eb381 100644 --- a/noxfile.py +++ b/noxfile.py @@ -221,10 +221,9 @@ def system(session): @nox.session(python=CONFORMANCE_TEST_PYTHON_VERSIONS) def conftest_retry(session): """Run the retry conformance test suite.""" - conformance_test_folder_path = os.path.join("tests", "conformance") - conformance_test_folder_exists = os.path.exists(conformance_test_folder_path) + json_conformance_tests = "tests/conformance/test_conformance.py" # Environment check: only run tests if found. - if not conformance_test_folder_exists: + if not os.path.exists(json_conformance_tests): session.skip("Conformance tests were not found") constraints_path = str( @@ -252,14 +251,30 @@ def conftest_retry(session): "-vv", "-s", # "--quiet", - conformance_test_folder_path, + json_conformance_tests, *session.posargs, ] else: - test_cmd = ["pytest", "-vv", "-s", "-n", "auto", conformance_test_folder_path] + test_cmd = ["pytest", "-vv", "-s", "-n", "auto", json_conformance_tests] - # Run py.test against the conformance tests. + bidi_reads_retries_test = [ + "pytest", + "-vv", + "-s", + "tests/conformance/test_bidi_reads.py", + ] + + bidi_writes_retries_test = [ + "pytest", + "-vv", + "-s", + "tests/conformance/test_bidi_writes.py", + ] + + # # Run pytest against the conformance tests. session.run(*test_cmd, env={"DOCKER_API_VERSION": "1.39"}) + session.run(*bidi_reads_retries_test, env={"DOCKER_API_VERSION": "1.39"}) + session.run(*bidi_writes_retries_test, env={"DOCKER_API_VERSION": "1.39"}) @nox.session(python=DEFAULT_PYTHON_VERSION) From 94defacc544f6f1c5576763af880a35fb52e17aa Mon Sep 17 00:00:00 2001 From: Chandra Shekhar Sirimala Date: Fri, 20 Mar 2026 18:51:05 +0530 Subject: [PATCH 2/6] Apply suggestions from code review Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- noxfile.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/noxfile.py b/noxfile.py index 8664eb381..66191d1b0 100644 --- a/noxfile.py +++ b/noxfile.py @@ -257,24 +257,21 @@ def conftest_retry(session): else: test_cmd = ["pytest", "-vv", "-s", "-n", "auto", json_conformance_tests] - bidi_reads_retries_test = [ - "pytest", - "-vv", - "-s", - "tests/conformance/test_bidi_reads.py", - ] + # # Run pytest against the conformance tests. + session.run(*test_cmd, env={"DOCKER_API_VERSION": "1.39"}) - bidi_writes_retries_test = [ - "pytest", - "-vv", - "-s", + bidi_tests = [ + "tests/conformance/test_bidi_reads.py", "tests/conformance/test_bidi_writes.py", ] - - # # Run pytest against the conformance tests. - session.run(*test_cmd, env={"DOCKER_API_VERSION": "1.39"}) - session.run(*bidi_reads_retries_test, env={"DOCKER_API_VERSION": "1.39"}) - session.run(*bidi_writes_retries_test, env={"DOCKER_API_VERSION": "1.39"}) + for test_file in bidi_tests: + session.run( + "pytest", + "-vv", + "-s", + test_file, + env={"DOCKER_API_VERSION": "1.39"}, + ) @nox.session(python=DEFAULT_PYTHON_VERSION) From 5b12374193d58e600118f85c28c36058f148fbe0 Mon Sep 17 00:00:00 2001 From: Chandra Sirimala Date: Fri, 20 Mar 2026 13:49:54 +0000 Subject: [PATCH 3/6] separate bidi tests into different nox session --- noxfile.py | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/noxfile.py b/noxfile.py index 66191d1b0..8d3cb660a 100644 --- a/noxfile.py +++ b/noxfile.py @@ -235,10 +235,6 @@ def conftest_retry(session): session.install( "pytest", "pytest-xdist", - "pytest-asyncio", - "grpcio", - "grpcio-status", - "grpc-google-iam-v1", "-c", constraints_path, ) @@ -250,16 +246,37 @@ def conftest_retry(session): "pytest", "-vv", "-s", - # "--quiet", json_conformance_tests, *session.posargs, ] else: test_cmd = ["pytest", "-vv", "-s", "-n", "auto", json_conformance_tests] - # # Run pytest against the conformance tests. + # Run pytest against the conformance tests. session.run(*test_cmd, env={"DOCKER_API_VERSION": "1.39"}) +@nox.session(python=CONFORMANCE_TEST_PYTHON_VERSIONS) +def conftest_retry_bidi(session): + """Run the retry conformance test suite.""" + + constraints_path = str( + CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" + ) + + # Install all test dependencies and pytest plugin to run tests in parallel. + # Then install this package in-place. + session.install( + "pytest", + "pytest-xdist", + "pytest-asyncio", + "grpcio", + "grpcio-status", + "grpc-google-iam-v1", + "-c", + constraints_path, + ) + session.install("-e", ".", "-c", constraints_path) + bidi_tests = [ "tests/conformance/test_bidi_reads.py", "tests/conformance/test_bidi_writes.py", From 9b39526a22252c580d8e72836746600190086492 Mon Sep 17 00:00:00 2001 From: Chandra Sirimala Date: Fri, 20 Mar 2026 14:22:28 +0000 Subject: [PATCH 4/6] add conftest_retry_bidi in sessions --- noxfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/noxfile.py b/noxfile.py index 8d3cb660a..886adfd1c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -44,6 +44,7 @@ nox.options.sessions = [ "blacken", "conftest_retry", + "conftest_retry_bidi", "docfx", "docs", "lint", From c79a70635ca873e2ebb7cd463b919fb0227da586 Mon Sep 17 00:00:00 2001 From: Chandra Sirimala Date: Fri, 20 Mar 2026 17:16:30 +0000 Subject: [PATCH 5/6] use bidiwrites instead of simple write --- tests/conformance/test_bidi_reads.py | 33 ++++++++++------------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/tests/conformance/test_bidi_reads.py b/tests/conformance/test_bidi_reads.py index efb9671a3..0705027e1 100644 --- a/tests/conformance/test_bidi_reads.py +++ b/tests/conformance/test_bidi_reads.py @@ -15,6 +15,9 @@ from google.cloud.storage.asyncio.async_grpc_client import AsyncGrpcClient from google.cloud.storage.asyncio.async_multi_range_downloader import \ AsyncMultiRangeDownloader +from google.cloud.storage.asyncio.async_appendable_object_writer import ( + AsyncAppendableObjectWriter, +) from tests.conformance._utils import start_grpc_server # --- Configuration --- @@ -138,12 +141,11 @@ async def test_bidi_reads(testbench): start_grpc_server( grpc_endpoint, test_bench_endpoint ) # Ensure the testbench gRPC server is running before this test executes. - channel = grpc.aio.insecure_channel(GRPC_ENDPOINT) - creds = auth_credentials.AnonymousCredentials() - transport = storage_v2.services.storage.transports.StorageGrpcAsyncIOTransport( - channel=channel, credentials=creds + + grpc_client = AsyncGrpcClient._create_insecure_grpc_client( + client_options=client_options.ClientOptions(api_endpoint=GRPC_ENDPOINT), ) - gapic_client = storage_v2.StorageAsyncClient(transport=transport) + gapic_client = grpc_client.grpc_client http_client = requests.Session() bucket_name = f"grpc-test-bucket-{uuid.uuid4().hex[:8]}" @@ -166,22 +168,11 @@ async def test_bidi_reads(testbench): create_bucket_request = storage_v2.CreateBucketRequest( parent="projects/_", bucket_id=bucket_name, bucket=bucket_resource ) - await gapic_client.create_bucket(request=create_bucket_request) - - write_spec = storage_v2.WriteObjectSpec( - resource=storage_v2.Object( - bucket=f"projects/_/buckets/{bucket_name}", name=object_name - ) - ) - - async def write_req_gen(): - yield storage_v2.WriteObjectRequest( - write_object_spec=write_spec, - checksummed_data={"content": content}, - finish_write=True, - ) - - await gapic_client.write_object(requests=write_req_gen()) + _ = await gapic_client.create_bucket(request=create_bucket_request) + w = AsyncAppendableObjectWriter(grpc_client, bucket_name, object_name) + await w.open() + await w.append(content) + _ = await w.close(finalize_on_close=True) # Run all defined test scenarios. for scenario in test_scenarios: From 7baa895e2e886b60386fa66d88f360fe77377e04 Mon Sep 17 00:00:00 2001 From: Chandra Sirimala Date: Fri, 20 Mar 2026 18:02:02 +0000 Subject: [PATCH 6/6] style: apply black formatting --- noxfile.py | 3 ++- tests/conformance/test_bidi_reads.py | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/noxfile.py b/noxfile.py index 886adfd1c..77823d28d 100644 --- a/noxfile.py +++ b/noxfile.py @@ -256,6 +256,7 @@ def conftest_retry(session): # Run pytest against the conformance tests. session.run(*test_cmd, env={"DOCKER_API_VERSION": "1.39"}) + @nox.session(python=CONFORMANCE_TEST_PYTHON_VERSIONS) def conftest_retry_bidi(session): """Run the retry conformance test suite.""" @@ -277,7 +278,7 @@ def conftest_retry_bidi(session): constraints_path, ) session.install("-e", ".", "-c", constraints_path) - + bidi_tests = [ "tests/conformance/test_bidi_reads.py", "tests/conformance/test_bidi_writes.py", diff --git a/tests/conformance/test_bidi_reads.py b/tests/conformance/test_bidi_reads.py index 0705027e1..8f0c43c4a 100644 --- a/tests/conformance/test_bidi_reads.py +++ b/tests/conformance/test_bidi_reads.py @@ -5,16 +5,15 @@ import urllib import uuid -import grpc import pytest import requests from google.api_core import client_options, exceptions -from google.auth import credentials as auth_credentials from google.cloud import _storage_v2 as storage_v2 from google.cloud.storage.asyncio.async_grpc_client import AsyncGrpcClient -from google.cloud.storage.asyncio.async_multi_range_downloader import \ - AsyncMultiRangeDownloader +from google.cloud.storage.asyncio.async_multi_range_downloader import ( + AsyncMultiRangeDownloader, +) from google.cloud.storage.asyncio.async_appendable_object_writer import ( AsyncAppendableObjectWriter, )