Skip to content

Commit d673781

Browse files
authored
ci(bigquery): configure us-east7 endpoint overrides in Kokoro integration tests (#13971)
Configures `BIGQUERY_ENDPOINT` and `BIGQUERY_STORAGE_ENDPOINT` environment variables in Kokoro presubmit configs to test against `us-east7` regional endpoints. ### Key Changes * **Kokoro CI**: Added `us-east7` endpoint overrides to BigQuery integration and GraalVM presubmit configurations. * **Two-Client Test Setup**: Introduced static global fallback clients (`globalBigQuery`, `globalReadClient`, `globalWriteClient`) for tests querying public datasets (`bigquery-public-data`) or cross-region resources, while standard clients target `us-east7`. b/472499857
1 parent 1b8f9e3 commit d673781

13 files changed

Lines changed: 590 additions & 326 deletions

File tree

.kokoro/presubmit/bigquery-graalvm-native-presubmit.cfg

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ env_vars: {
2222
value: "gcloud-devel"
2323
}
2424

25+
env_vars: {
26+
key: "INTEGRATION_TEST_ARGS"
27+
value: "-Dbigquery.endpoint=https://us-east7-bigquery.googleapis.com -Dbigquery.storage.endpoint=us-east7-bigquerystorage.googleapis.com:443"
28+
}
29+
2530
env_vars: {
2631
key: "GOOGLE_APPLICATION_CREDENTIALS"
2732
value: "secret_manager/java-it-service-account"
@@ -40,5 +45,3 @@ env_vars: {
4045
key: "BUILD_SUBDIR"
4146
value: "java-bigquery"
4247
}
43-
44-

.kokoro/presubmit/bigquery-integration.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ env_vars: {
2222
value: "gcloud-devel"
2323
}
2424

25+
env_vars: {
26+
key: "INTEGRATION_TEST_ARGS"
27+
value: "-Dbigquery.endpoint=https://us-east7-bigquery.googleapis.com -Dbigquery.storage.endpoint=us-east7-bigquerystorage.googleapis.com:443"
28+
}
29+
2530
env_vars: {
2631
key: "GOOGLE_APPLICATION_CREDENTIALS"
2732
value: "secret_manager/java-it-service-account"

.kokoro/presubmit/bigquerystorage-graalvm-native-presubmit.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ env_vars: {
4444

4545
env_vars: {
4646
key: "INTEGRATION_TEST_ARGS"
47-
value: "-Dit.test=!ITBigQueryWrite*RetryTest -Dsurefire.failIfNoSpecifiedTests=false -Dfailsafe.failIfNoSpecifiedTests=false"
47+
value: "-Dit.test=!ITBigQueryWrite*RetryTest -Dsurefire.failIfNoSpecifiedTests=false -Dfailsafe.failIfNoSpecifiedTests=false -Dbigquery.storage.endpoint=us-east7-bigquerystorage.googleapis.com:443 -Dbigquery.endpoint=https://us-east7-bigquery.googleapis.com"
4848
}

.kokoro/presubmit/bigquerystorage-integration.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ env_vars: {
3939

4040
env_vars: {
4141
key: "INTEGRATION_TEST_ARGS"
42-
value: "-Dit.test=!ITBigQueryWrite*RetryTest -Dsurefire.failIfNoSpecifiedTests=false -Dfailsafe.failIfNoSpecifiedTests=false"
42+
value: "-Dit.test=!ITBigQueryWrite*RetryTest -Dsurefire.failIfNoSpecifiedTests=false -Dfailsafe.failIfNoSpecifiedTests=false -Dbigquery.storage.endpoint=us-east7-bigquerystorage.googleapis.com:443 -Dbigquery.endpoint=https://us-east7-bigquery.googleapis.com"
4343
}

java-bigquery/google-cloud-bigquery/pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
</parent>
1616
<properties>
1717
<site.installationModule>google-cloud-bigquery</site.installationModule>
18+
<bigquery.endpoint>https://us-east7-bigquery.googleapis.com</bigquery.endpoint>
19+
<bigquery.storage.endpoint>us-east7-bigquerystorage.googleapis.com:443</bigquery.storage.endpoint>
1820
</properties>
1921
<dependencies>
2022
<dependency>
@@ -330,5 +332,22 @@
330332
</build>
331333

332334
</profile>
335+
<profile>
336+
<id>native</id>
337+
<build>
338+
<plugins>
339+
<plugin>
340+
<groupId>org.graalvm.buildtools</groupId>
341+
<artifactId>native-maven-plugin</artifactId>
342+
<configuration>
343+
<environmentVariables>
344+
<BIGQUERY_ENDPOINT>${bigquery.endpoint}</BIGQUERY_ENDPOINT>
345+
<BIGQUERY_STORAGE_ENDPOINT>${bigquery.storage.endpoint}</BIGQUERY_STORAGE_ENDPOINT>
346+
</environmentVariables>
347+
</configuration>
348+
</plugin>
349+
</plugins>
350+
</build>
351+
</profile>
333352
</profiles>
334353
</project>

java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/testing/RemoteBigQueryHelper.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static RemoteBigQueryHelper create(String projectId, InputStream keyStrea
105105
.setProjectId(projectId)
106106
.setRetrySettings(retrySettings())
107107
.setTransportOptions(transportOptions);
108-
String endpoint = System.getenv("BIGQUERY_ENDPOINT");
108+
String endpoint = System.getProperty("bigquery.endpoint", System.getenv("BIGQUERY_ENDPOINT"));
109109
if (endpoint != null) {
110110
builder.setHost(endpoint);
111111
}
@@ -143,7 +143,7 @@ public static RemoteBigQueryHelper create(BigQueryOptions.Builder bigqueryOption
143143
bigqueryOptionsBuilder
144144
.setRetrySettings(retrySettings())
145145
.setTransportOptions(transportOptions);
146-
String endpoint = System.getenv("BIGQUERY_ENDPOINT");
146+
String endpoint = System.getProperty("bigquery.endpoint", System.getenv("BIGQUERY_ENDPOINT"));
147147
if (endpoint != null) {
148148
builder.setHost(endpoint);
149149
}
@@ -184,4 +184,16 @@ public static BigQueryHelperException translate(Exception ex) {
184184
return new BigQueryHelperException(ex.getMessage(), ex);
185185
}
186186
}
187+
188+
/**
189+
* Helper to check if the provided BigQuery client is configured to target a regional endpoint.
190+
*/
191+
public static boolean isRegionalEndpoint(BigQuery bigquery) {
192+
if (bigquery == null || bigquery.getOptions() == null) {
193+
return false;
194+
}
195+
String host = bigquery.getOptions().getHost();
196+
return host != null
197+
&& (host.contains("-bigquery.googleapis.com") || host.contains(".rep.googleapis.com"));
198+
}
187199
}

0 commit comments

Comments
 (0)