Skip to content

Commit f149302

Browse files
committed
chore: move bigquery jdbc external test to monorepo
1 parent ac1f0f4 commit f149302

File tree

15 files changed

+4147
-0
lines changed

15 files changed

+4147
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# Github action job to test core java library features on
15+
# downstream client libraries before they are released.
16+
17+
steps:
18+
- name: 'gcr.io/cloud-devrel-public-resources/java11'
19+
entrypoint: 'bash'
20+
args: ['java-bigquery/.cloudbuild/scripts/jdbc-external.sh'', "${_VERSION}"]
21+
secretEnv: ['SA_SECRET']
22+
availableSecrets:
23+
secretManager:
24+
- versionName: projects/$PROJECT_ID/secrets/GoogleJDBCServiceAccountSecret/versions/latest
25+
env: 'SA_SECRET'
26+
options:
27+
workerPool: 'projects/bigquery-devtools-drivers/locations/us-east1/workerPools/java-bigquery-jdbc-pool'
28+
logging: CLOUD_LOGGING_ONLY
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ROOT_FOLDER=$(git rev-parse --show-toplevel)
2+
3+
cd ${ROOT_FOLDER}
4+
source .kokoro/common.sh
5+
install_modules java-bigquery
6+
7+
cd ${ROOT_FOLDER}/java-bigquery/google-cloud-bigquery-jdbc/bigquery-external-jdbc-tests
8+
make integration-test
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM gcr.io/cloud-devrel-public-resources/java11
2+
3+
ARG JDBC_VERSION
4+
ARG JDBC_JAR_PATH
5+
6+
ENV container_jdbc_jar_path=/jdbc/simba/GoogleBigQueryJDBC42.jar
7+
8+
COPY ./pom.xml /src/pom.xml
9+
COPY ${JDBC_JAR_PATH} ${container_jdbc_jar_path}
10+
11+
# Override SIMBA_JDBC_JAR_PATH with path inside the container
12+
ENV JDBC_VERSION=${JDBC_VERSION}
13+
ENV JDBC_JAR_PATH=${container_jdbc_jar_path}
14+
ENV JDBC_DOCKER_ENV=true
15+
16+
WORKDIR /src
17+
RUN mvn install
18+
19+
ENTRYPOINT []
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# GOOGLE_APPLICATION_CREDENTIALS is required when running certain tests
2+
SECRET=`cat $(GOOGLE_APPLICATION_CREDENTIALS)`
3+
4+
SIMBA_JDBC_VERSION=${_VERSION}
5+
SIMBA_ZIP_FILE="SimbaJDBCDriverforGoogleBigQuery42_$(SIMBA_JDBC_VERSION).zip"
6+
7+
# Driver under test configuration
8+
JDBC_FOLDER=drivers
9+
JDBC_JAR_NAME=GoogleBigQueryJDBC42.jar
10+
JDBC_JAR_PATH="$(JDBC_FOLDER)/$(JDBC_JAR_NAME)"
11+
JDBC_VERSION=$(SIMBA_JDBC_VERSION)
12+
13+
skipSurefire ?= true
14+
15+
# Container name used during this test
16+
CONTAINER_NAME=jdbc_test
17+
18+
# no indentation for ifndef\endif due to their evaluation before execution
19+
.check-env: |
20+
ifndef GOOGLE_APPLICATION_CREDENTIALS
21+
$(error GOOGLE_APPLICATION_CREDENTIALS is required to run tests)
22+
endif
23+
24+
# Important: By default, this command will skip unittests.
25+
# To include unit tests, run: make integration-test skipSurefire=false
26+
integration-test:
27+
mvn -B -ntp \
28+
-Penable-integration-tests \
29+
-DtrimStackTrace=false \
30+
-DskipSurefire=$(skipSurefire) \
31+
-Dclirr.skip=true \
32+
-Denforcer.skip=true \
33+
-Dit.failIfNoSpecifiedTests=true \
34+
-Dit.test=$(test) \
35+
integration-test
36+
37+
.docker-run: |
38+
docker run -it \
39+
-v $(GOOGLE_APPLICATION_CREDENTIALS):/auth/application_creds.json \
40+
-e "GOOGLE_APPLICATION_CREDENTIALS=/auth/application_creds.json" \
41+
-v "$(GOOGLE_APPLICATION_CREDENTIALS).p12":/auth/application_creds.p12 \
42+
-v $(PWD):/src \
43+
-e "SA_SECRET=$(SECRET)" \
44+
-e "SA_SECRET_P12=/auth/application_creds.p12" \
45+
$(CONTAINER_NAME) $(args)
46+
47+
download-simba:
48+
mkdir -p $(JDBC_FOLDER)
49+
gsutil -m cp gs://bq-dev-tools-simba-drivers-testing/simba-jdbc/$(SIMBA_ZIP_FILE) $(JDBC_FOLDER)
50+
unzip -p ./$(JDBC_FOLDER)/$(SIMBA_ZIP_FILE) $(JDBC_JAR_NAME) > $(JDBC_JAR_PATH)
51+
52+
docker-build: |
53+
docker build --build-arg JDBC_JAR_PATH=$(JDBC_JAR_PATH) --build-arg JDBC_VERSION=$(JDBC_VERSION) -t $(CONTAINER_NAME) .
54+
55+
docker-test-authentication: .check-env |
56+
$(MAKE) .docker-run args="mvn -Dtest=ITJdbcAuthenticationTest test"
57+
58+
docker-test test: .check-env |
59+
$(MAKE) .docker-run args="mvn test -Dtest=$(test)"
60+
61+
docker-test-all: .check-env |
62+
$(MAKE) .docker-run args="mvn test"
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright 2025 Google LLC
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<project xmlns="http://maven.apache.org/POM/4.0.0"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
<modelVersion>4.0.0</modelVersion>
21+
22+
<groupId>org.example</groupId>
23+
<artifactId>bigquery-external-jdbc-tests</artifactId>
24+
<version>1.0-SNAPSHOT</version>
25+
26+
<properties>
27+
<maven.compiler.source>11</maven.compiler.source>
28+
<maven.compiler.target>11</maven.compiler.target>
29+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
30+
</properties>
31+
<dependencyManagement>
32+
<dependencies>
33+
<dependency>
34+
<groupId>com.google.cloud</groupId>
35+
<artifactId>libraries-bom</artifactId>
36+
<version>26.58.0</version>
37+
<type>pom</type>
38+
<scope>import</scope>
39+
</dependency>
40+
</dependencies>
41+
</dependencyManagement>
42+
<dependencies>
43+
<dependency>
44+
<groupId>com.google.cloud</groupId>
45+
<artifactId>google-cloud-bigquery</artifactId>
46+
</dependency>
47+
48+
<dependency>
49+
<groupId>com.google.cloud</groupId>
50+
<artifactId>JDBC</artifactId>
51+
<version>${env.JDBC_VERSION}</version>
52+
<scope>system</scope>
53+
<systemPath>${env.JDBC_JAR_PATH}</systemPath>
54+
</dependency>
55+
56+
<!-- Test dependencies -->
57+
<dependency>
58+
<groupId>com.google.cloud</groupId>
59+
<artifactId>google-cloud-core</artifactId>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.apache.avro</groupId>
63+
<artifactId>avro</artifactId>
64+
<version>1.11.4</version>
65+
</dependency>
66+
<dependency>
67+
<groupId>junit</groupId>
68+
<artifactId>junit</artifactId>
69+
<scope>test</scope>
70+
<version>4.13.2</version>
71+
</dependency>
72+
<dependency>
73+
<groupId>com.google.truth</groupId>
74+
<artifactId>truth</artifactId>
75+
<scope>test</scope>
76+
<version>1.1.3</version>
77+
</dependency>
78+
<dependency>
79+
<groupId>org.mockito</groupId>
80+
<artifactId>mockito-core</artifactId>
81+
<scope>test</scope>
82+
<version>1.10.19</version>
83+
</dependency>
84+
<dependency>
85+
<groupId>joda-time</groupId>
86+
<artifactId>joda-time</artifactId>
87+
<scope>test</scope>
88+
<version>2.14.0</version>
89+
</dependency>
90+
</dependencies>
91+
92+
<profiles>
93+
<!-- Profile used inside docker -->
94+
<profile>
95+
<id>docker</id>
96+
<activation>
97+
<property>
98+
<name>env.JDBC_DOCKER_ENV</name>
99+
</property>
100+
</activation>
101+
<build>
102+
<!-- Ensure it doesn't conflict with local build directories -->
103+
<directory>/mvn/test-target</directory>
104+
</build>
105+
</profile>
106+
</profiles>
107+
</project>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import com.google.cloud.ServiceOptions;
18+
import java.sql.DriverManager;
19+
import java.sql.Connection;
20+
import java.sql.SQLException;
21+
import java.sql.Statement;
22+
23+
public class JdbcStarter {
24+
25+
public static void main(String[] args) throws SQLException {
26+
final String DEFAULT_CATALOG = ServiceOptions.getDefaultProjectId();
27+
final String oauthType = "3"; // Google Application Credentials
28+
29+
String connectionUrl =
30+
"jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId="
31+
+ DEFAULT_CATALOG
32+
+ ";OAuthType="
33+
+ oauthType
34+
+ ";Timeout=3600;";
35+
Connection connection = DriverManager.getConnection(connectionUrl);
36+
Statement statement = connection.createStatement();
37+
statement.execute("SELECT 1;");
38+
}
39+
}

0 commit comments

Comments
 (0)