Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ case ${JOB_TYPE} in
[[ "$(basename "${dir}")" != "dependency-analyzer" ]] && \
[[ "$(basename "${dir}")" != "dependency-convergence-check" ]] && \
[[ "$(basename "${dir}")" != "unmanaged-dependency-check" ]] && \
[[ "$(basename "${dir}")" != "bigquery-external-jdbc-tests" ]] && \
[[ "$(basename "${dir}")" != "google-cloud-jar-parent" ]]; then

changed_modules+=("${dir}")
Expand Down
28 changes: 28 additions & 0 deletions java-bigquery/.cloudbuild/jdbc_external.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Github action job to test core java library features on
# downstream client libraries before they are released.

steps:
- name: 'gcr.io/cloud-devrel-public-resources/java11'
entrypoint: 'bash'
args: ['java-bigquery/.cloudbuild/scripts/jdbc-external.sh', "${_VERSION}"]
secretEnv: ['SA_SECRET']
availableSecrets:
secretManager:
- versionName: projects/$PROJECT_ID/secrets/GoogleJDBCServiceAccountSecret/versions/latest
env: 'SA_SECRET'
options:
workerPool: 'projects/bigquery-devtools-drivers/locations/us-east1/workerPools/java-bigquery-jdbc-pool'
logging: CLOUD_LOGGING_ONLY
20 changes: 20 additions & 0 deletions java-bigquery/.cloudbuild/scripts/jdbc-external.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ROOT_FOLDER=$(git rev-parse --show-toplevel)

cd ${ROOT_FOLDER}
source .kokoro/common.sh
install_modules java-bigquery

cd ${ROOT_FOLDER}/java-bigquery/google-cloud-bigquery-jdbc/bigquery-external-jdbc-tests

# This pom.xml is using export vars for install
export JDBC_VERSION=$1;
JDBC_FOLDER=jdbc-driver
JDBC_ZIP_NAME="SimbaJDBCDriverforGoogleBigQuery42_${JDBC_VERSION}.zip"
JDBC_JAR_NAME=GoogleBigQueryJDBC42.jar
export JDBC_JAR_PATH="$(pwd)/${JDBC_FOLDER}/${JDBC_JAR_NAME}"

mkdir -p ${JDBC_FOLDER}
gsutil -m cp gs://bq-dev-tools-simba-drivers-testing/simba-jdbc/${JDBC_ZIP_NAME} ${JDBC_FOLDER}
unzip -p ./${JDBC_FOLDER}/${JDBC_ZIP_NAME} ${JDBC_JAR_NAME} > ${JDBC_JAR_PATH}

mvn -B -V -fae -q install
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM gcr.io/cloud-devrel-public-resources/java11

ARG JDBC_VERSION
ARG JDBC_JAR_PATH

ENV container_jdbc_jar_path=/jdbc/simba/GoogleBigQueryJDBC42.jar

COPY ./pom.xml /src/pom.xml
COPY ${JDBC_JAR_PATH} ${container_jdbc_jar_path}

# Override SIMBA_JDBC_JAR_PATH with path inside the container
ENV JDBC_VERSION=${JDBC_VERSION}
ENV JDBC_JAR_PATH=${container_jdbc_jar_path}
ENV JDBC_DOCKER_ENV=true

WORKDIR /src
RUN mvn install

ENTRYPOINT []
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# GOOGLE_APPLICATION_CREDENTIALS is required when running certain tests
SECRET=`cat $(GOOGLE_APPLICATION_CREDENTIALS)`

SIMBA_JDBC_VERSION=${_VERSION}
SIMBA_ZIP_FILE="SimbaJDBCDriverforGoogleBigQuery42_$(SIMBA_JDBC_VERSION).zip"

# Driver under test configuration
JDBC_FOLDER=drivers
JDBC_JAR_NAME=GoogleBigQueryJDBC42.jar
JDBC_JAR_PATH="$(JDBC_FOLDER)/$(JDBC_JAR_NAME)"
JDBC_VERSION=$(SIMBA_JDBC_VERSION)

skipSurefire ?= true

# Container name used during this test
CONTAINER_NAME=jdbc_test

# no indentation for ifndef\endif due to their evaluation before execution
.check-env: |
ifndef GOOGLE_APPLICATION_CREDENTIALS
$(error GOOGLE_APPLICATION_CREDENTIALS is required to run tests)
endif

# Important: By default, this command will skip unittests.
# To include unit tests, run: make integration-test skipSurefire=false
integration-test:
mvn -B -ntp \
-Penable-integration-tests \
-DtrimStackTrace=false \
-DskipSurefire=$(skipSurefire) \
-Dclirr.skip=true \
-Denforcer.skip=true \
-Dit.failIfNoSpecifiedTests=true \
-Dit.test=$(test) \
integration-test

.docker-run: |
docker run -it \
-v $(GOOGLE_APPLICATION_CREDENTIALS):/auth/application_creds.json \
-e "GOOGLE_APPLICATION_CREDENTIALS=/auth/application_creds.json" \
-v "$(GOOGLE_APPLICATION_CREDENTIALS).p12":/auth/application_creds.p12 \
-v $(PWD):/src \
-e "SA_SECRET=$(SECRET)" \
-e "SA_SECRET_P12=/auth/application_creds.p12" \
$(CONTAINER_NAME) $(args)

download-simba:
mkdir -p $(JDBC_FOLDER)
gsutil -m cp gs://bq-dev-tools-simba-drivers-testing/simba-jdbc/$(SIMBA_ZIP_FILE) $(JDBC_FOLDER)
unzip -p ./$(JDBC_FOLDER)/$(SIMBA_ZIP_FILE) $(JDBC_JAR_NAME) > $(JDBC_JAR_PATH)

docker-build: |
docker build --build-arg JDBC_JAR_PATH=$(JDBC_JAR_PATH) --build-arg JDBC_VERSION=$(JDBC_VERSION) -t $(CONTAINER_NAME) .

docker-test-authentication: .check-env |
$(MAKE) .docker-run args="mvn -Dtest=ITJdbcAuthenticationTest test"

docker-test test: .check-env |
$(MAKE) .docker-run args="mvn test -Dtest=$(test)"

docker-test-all: .check-env |
$(MAKE) .docker-run args="mvn test"
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.google.cloud</groupId>
<artifactId>bigquery-external-jdbc-tests</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdbc.version>${env.JDBC_VERSION}</jdbc.version>
<jdbc.jarPath>${env.JDBC_JAR_PATH}</jdbc.jarPath>
</properties>

<!-- <parent>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery-parent</artifactId>
<version>2.63.0-SNAPSHOT</version>&lt;!&ndash; {x-version-update:google-cloud-bigquery:current} &ndash;&gt;
<relativePath>../../pom.xml</relativePath>
</parent>-->

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.58.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
</dependency>

<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>JDBC</artifactId>
<version>${jdbc.version}</version>
<scope>system</scope>
<systemPath>${jdbc.jarPath}</systemPath>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>1.11.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>4.13.2</version>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<scope>test</scope>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
<version>1.10.19</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<scope>test</scope>
<version>2.14.0</version>
</dependency>
</dependencies>

<profiles>
<!-- Profile used inside docker -->
<profile>
<id>docker</id>
<activation>
<property>
<name>env.JDBC_DOCKER_ENV</name>
</property>
</activation>
<build>
<!-- Ensure it doesn't conflict with local build directories -->
<directory>/mvn/test-target</directory>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import com.google.cloud.ServiceOptions;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class JdbcStarter {

public static void main(String[] args) throws SQLException {
final String DEFAULT_CATALOG = ServiceOptions.getDefaultProjectId();
final String oauthType = "3"; // Google Application Credentials

String connectionUrl =
"jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId="
+ DEFAULT_CATALOG
+ ";OAuthType="
+ oauthType
+ ";Timeout=3600;";
try(Connection connection = DriverManager.getConnection(connectionUrl);
Statement statement = connection.createStatement()) {
statement.execute("SELECT 1;");
}
}
}
Loading
Loading