From 94fa00b5026de5fded946608913a48f10e355768 Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Thu, 19 Nov 2026 19:18:37 +0000 Subject: [PATCH 1/2] test(bigquerystorage): read private table in testSimpleReadWithBackgroundExecutorProvider Re-enable v1.it.ITBigQueryStorageReadClientTest.testSimpleReadWithBackgroundExecutorProvider and switch it from reading all 164,656 rows of bigquery-public-data.samples.shakespeare to reading a 1-row private table in the test dataset. This test only needs to verify that a custom InstantiatingExecutorProvider is wired onto BigQueryReadClient and can read rows end-to-end. Reading a small private table removes shared public-dataset CreateReadSession load and eliminates the regional endpoint override. Also document in the v1beta1 and v1beta2 @Disabled annotations why duplicate public-table read tests stay disabled on non-GA versions (avoiding shared CreateReadSession quota overload across versions while keeping coverage on v1). Fixes b/575539309. --- .../it/ITBigQueryStorageReadClientTest.java | 47 +++++-------------- .../v1beta1/it/ITBigQueryStorageTest.java | 8 +++- .../v1beta2/it/ITBigQueryStorageTest.java | 8 +++- 3 files changed, 24 insertions(+), 39 deletions(-) diff --git a/java-bigquerystorage/google-cloud-bigquerystorage-it/src/test/java/com/google/cloud/bigquery/storage/v1/it/ITBigQueryStorageReadClientTest.java b/java-bigquerystorage/google-cloud-bigquerystorage-it/src/test/java/com/google/cloud/bigquery/storage/v1/it/ITBigQueryStorageReadClientTest.java index a595ba281ed6..c73db5b64998 100644 --- a/java-bigquerystorage/google-cloud-bigquerystorage-it/src/test/java/com/google/cloud/bigquery/storage/v1/it/ITBigQueryStorageReadClientTest.java +++ b/java-bigquerystorage/google-cloud-bigquerystorage-it/src/test/java/com/google/cloud/bigquery/storage/v1/it/ITBigQueryStorageReadClientTest.java @@ -118,7 +118,6 @@ import org.json.JSONObject; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; /** Integration tests for BigQuery Storage API. */ @@ -1629,16 +1628,19 @@ void testStructAndArraySqlTypes() throws InterruptedException, IOException { assertEquals(new Utf8("abc"), structRecord.get("str_field"), rowAssertMessage); } - @Disabled("Flaky test: b/575539309") @Test - void testSimpleReadWithBackgroundExecutorProvider() throws IOException { + void testSimpleReadWithBackgroundExecutorProvider() throws InterruptedException, IOException { + String tableName = + "test_simple_read_background_executor_" + UUID.randomUUID().toString().substring(0, 8); + String createTableStatement = + String.format( + "CREATE TABLE %s.%s AS SELECT 1 AS int_field, 'abc' AS str_field", DATASET, tableName); + runQueryJobAndExpectSuccess(QueryJobConfiguration.newBuilder(createTableStatement).build()); + BigQueryReadSettings.Builder settingsBuilder = Helper.createBigQueryReadSettingsBuilder() .setBackgroundExecutorProvider( InstantiatingExecutorProvider.newBuilder().setExecutorThreadCount(14).build()); - if (Helper.isRegionalEndpoint()) { - settingsBuilder.setEndpoint(BigQueryReadSettings.getDefaultEndpoint()); - } BigQueryReadClient localClient = BigQueryReadClient.create(settingsBuilder.build()); try { assertTrue( @@ -1651,36 +1653,11 @@ void testSimpleReadWithBackgroundExecutorProvider() throws IOException { .getExecutorThreadCount()); String table = BigQueryResource.formatTableResource( - /* projectId= */ "bigquery-public-data", - /* datasetId= */ "samples", - /* tableId= */ "shakespeare"); - - ReadSession session = - localClient.createReadSession( - /* parent= */ parentProjectId, - /* readSession= */ ReadSession.newBuilder() - .setTable(table) - .setDataFormat(DataFormat.AVRO) - .build(), - /* maxStreamCount= */ 1); - assertEquals( - 1, - session.getStreamsCount(), - String.format( - "Did not receive expected number of streams for table '%s' CreateReadSession" - + " response:%n%s", - table, session.toString())); - - ReadRowsRequest readRowsRequest = - ReadRowsRequest.newBuilder().setReadStream(session.getStreams(0).getName()).build(); + /* projectId= */ projectName, /* datasetId= */ DATASET, /* tableId= */ tableName); - long rowCount = 0; - ServerStream stream = localClient.readRowsCallable().call(readRowsRequest); - for (ReadRowsResponse response : stream) { - rowCount += response.getRowCount(); - } - - assertEquals(SHAKESPEARE_SAMPLE_ROW_COUNT, rowCount); + List rows = + Helper.readAllRows(localClient, parentProjectId, /* table= */ table, /* filter= */ null); + assertEquals(1, rows.size(), "Actual rows read: " + rows); } finally { localClient.close(); } diff --git a/java-bigquerystorage/google-cloud-bigquerystorage-it/src/test/java/com/google/cloud/bigquery/storage/v1beta1/it/ITBigQueryStorageTest.java b/java-bigquerystorage/google-cloud-bigquerystorage-it/src/test/java/com/google/cloud/bigquery/storage/v1beta1/it/ITBigQueryStorageTest.java index 558012bb1074..3bc091e05b4f 100644 --- a/java-bigquerystorage/google-cloud-bigquerystorage-it/src/test/java/com/google/cloud/bigquery/storage/v1beta1/it/ITBigQueryStorageTest.java +++ b/java-bigquerystorage/google-cloud-bigquerystorage-it/src/test/java/com/google/cloud/bigquery/storage/v1beta1/it/ITBigQueryStorageTest.java @@ -458,7 +458,9 @@ public void accept(GenericData.Record record) { assertEquals(1_333, rowCount); } - @Disabled("Flaky test: b/576746567") + @Disabled( + "Disabled on non-GA v1beta1 to avoid overloading BigQuery Storage CreateReadSession quota" + + " across versions; covered on v1 (b/576746567)") @Test void testColumnSelection() throws IOException { TableReference tableReference = @@ -1088,7 +1090,9 @@ void testInvalidUniverseDomainWithMismatchCredentials() throws IOException { localClient.close(); } - @Disabled("Flaky test: b/575538723") + @Disabled( + "Disabled on non-GA v1beta1 to avoid overloading BigQuery Storage CreateReadSession quota" + + " across versions; covered on v1 (b/575538723)") @Test void testUniverseDomainWithMatchingDomain() throws IOException { // Test a valid domain using the default credentials and Google default universe domain. diff --git a/java-bigquerystorage/google-cloud-bigquerystorage-it/src/test/java/com/google/cloud/bigquery/storage/v1beta2/it/ITBigQueryStorageTest.java b/java-bigquerystorage/google-cloud-bigquerystorage-it/src/test/java/com/google/cloud/bigquery/storage/v1beta2/it/ITBigQueryStorageTest.java index 689cb644f7a7..8781636550b4 100644 --- a/java-bigquerystorage/google-cloud-bigquerystorage-it/src/test/java/com/google/cloud/bigquery/storage/v1beta2/it/ITBigQueryStorageTest.java +++ b/java-bigquerystorage/google-cloud-bigquerystorage-it/src/test/java/com/google/cloud/bigquery/storage/v1beta2/it/ITBigQueryStorageTest.java @@ -462,7 +462,9 @@ public void accept(GenericData.Record record) { assertEquals(1_333, rowCount); } - @Disabled("Flaky test: b/576747708") + @Disabled( + "Disabled on non-GA v1beta2 to avoid overloading BigQuery Storage CreateReadSession quota" + + " across versions; covered on v1 (b/576747708)") @Test void testColumnSelection() throws IOException { String table = @@ -1077,7 +1079,9 @@ void testInvalidUniverseDomainWithMismatchCredentials() throws IOException { localClient.close(); } - @Disabled("Flaky test: b/575538593") + @Disabled( + "Disabled on non-GA v1beta2 to avoid overloading BigQuery Storage CreateReadSession quota" + + " across versions; covered on v1 (b/575538593)") @Test void testUniverseDomainWithMatchingDomain() throws IOException { // Test a valid domain using the default credentials and Google default universe domain. From 541819ed5b28a3e4d4001e43985e3391e74bafbe Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Thu, 19 Nov 2026 19:30:34 +0000 Subject: [PATCH 2/2] test(bigquerystorage): clean up temporary table in finally block Delete the temporary table created in testSimpleReadWithBackgroundExecutorProvider inside the finally block, catching BigQueryException specifically to log cleanup failures without masking test errors or swallowing unrelated exceptions. --- .../it/ITBigQueryStorageReadClientTest.java | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/java-bigquerystorage/google-cloud-bigquerystorage-it/src/test/java/com/google/cloud/bigquery/storage/v1/it/ITBigQueryStorageReadClientTest.java b/java-bigquerystorage/google-cloud-bigquerystorage-it/src/test/java/com/google/cloud/bigquery/storage/v1/it/ITBigQueryStorageReadClientTest.java index c73db5b64998..51a86db43d28 100644 --- a/java-bigquerystorage/google-cloud-bigquerystorage-it/src/test/java/com/google/cloud/bigquery/storage/v1/it/ITBigQueryStorageReadClientTest.java +++ b/java-bigquerystorage/google-cloud-bigquerystorage-it/src/test/java/com/google/cloud/bigquery/storage/v1/it/ITBigQueryStorageReadClientTest.java @@ -37,6 +37,7 @@ import com.google.cloud.RetryOption; import com.google.cloud.ServiceOptions; import com.google.cloud.bigquery.BigQuery; +import com.google.cloud.bigquery.BigQueryException; import com.google.cloud.bigquery.DatasetId; import com.google.cloud.bigquery.DatasetInfo; import com.google.cloud.bigquery.Field; @@ -107,6 +108,7 @@ import java.util.Map; import java.util.UUID; import java.util.concurrent.TimeUnit; +import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; import org.apache.avro.Conversions; @@ -1632,17 +1634,19 @@ void testStructAndArraySqlTypes() throws InterruptedException, IOException { void testSimpleReadWithBackgroundExecutorProvider() throws InterruptedException, IOException { String tableName = "test_simple_read_background_executor_" + UUID.randomUUID().toString().substring(0, 8); + TableId tableId = TableId.of(DATASET, tableName); String createTableStatement = String.format( "CREATE TABLE %s.%s AS SELECT 1 AS int_field, 'abc' AS str_field", DATASET, tableName); - runQueryJobAndExpectSuccess(QueryJobConfiguration.newBuilder(createTableStatement).build()); - - BigQueryReadSettings.Builder settingsBuilder = - Helper.createBigQueryReadSettingsBuilder() - .setBackgroundExecutorProvider( - InstantiatingExecutorProvider.newBuilder().setExecutorThreadCount(14).build()); - BigQueryReadClient localClient = BigQueryReadClient.create(settingsBuilder.build()); + BigQueryReadClient localClient = null; try { + runQueryJobAndExpectSuccess(QueryJobConfiguration.newBuilder(createTableStatement).build()); + + BigQueryReadSettings.Builder settingsBuilder = + Helper.createBigQueryReadSettingsBuilder() + .setBackgroundExecutorProvider( + InstantiatingExecutorProvider.newBuilder().setExecutorThreadCount(14).build()); + localClient = BigQueryReadClient.create(settingsBuilder.build()); assertTrue( localClient.getStub().getStubSettings().getBackgroundExecutorProvider() instanceof InstantiatingExecutorProvider); @@ -1659,7 +1663,14 @@ void testSimpleReadWithBackgroundExecutorProvider() throws InterruptedException, Helper.readAllRows(localClient, parentProjectId, /* table= */ table, /* filter= */ null); assertEquals(1, rows.size(), "Actual rows read: " + rows); } finally { - localClient.close(); + if (localClient != null) { + localClient.close(); + } + try { + bigquery.delete(tableId); + } catch (BigQueryException e) { + LOG.log(Level.WARNING, "Failed to delete temporary table: " + tableId, e); + } } }