Skip to content
23 changes: 22 additions & 1 deletion google-cloud-bigquery-jdbc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,25 @@ docker-integration-test: .check-env

docker-coverage:
$(MAKE) .docker-run args="make unit-test-coverage"
$(MAKE) .docker-run args="make full-coverage"
$(MAKE) .docker-run args="make full-coverage"

# Standalone Tests Commands
DRIVER_JAR ?= target/google-cloud-bigquery-jdbc-0.4.0.jar
STANDALONE_JAR = target-it/google-cloud-bigquery-jdbc-it-0.4.0-standalone.jar
Comment on lines +133 to +134
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The versions for DRIVER_JAR and STANDALONE_JAR are hardcoded. This will require manual updates whenever the project version changes, making it brittle. It would be more robust to determine these versions dynamically from the pom.xml files. You can use mvn help:evaluate for this, similar to how BUILD_DIR is determined elsewhere in this file.


build-standalone-tests:
mvn clean install -DskipTests
mvn -f pom-it.xml clean package

run-standalone-tests: .check-env
@if [ ! -f "$(STANDALONE_JAR)" ]; then \
echo "Standalone test JAR not found. Run 'make build-standalone-tests' first."; \
exit 1; \
fi
@if [ ! -f "$(DRIVER_JAR)" ]; then \
echo "Driver JAR not found at $(DRIVER_JAR). Provide it using DRIVER_JAR=/path/to/driver.jar make run-standalone-tests"; \
exit 1; \
fi
@echo "Running standalone tests with driver: $(DRIVER_JAR)"
java -cp "$(STANDALONE_JAR):$(DRIVER_JAR)" \
org.junit.runner.JUnitCore com.google.cloud.bigquery.jdbc.it.ITDriverAgnosticTest
91 changes: 91 additions & 0 deletions google-cloud-bigquery-jdbc/pom-it.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?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>
<parent>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery-parent</artifactId>
<version>2.60.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
Comment on lines +4 to +9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The parent POM configuration has a couple of issues:

  1. The version 2.60.0 is different from the parent version in the main google-cloud-bigquery-jdbc/pom.xml (2.60.1-SNAPSHOT). These should be consistent to ensure dependencies are managed correctly.
  2. The relativePath is set to ../pom.xml. The main module's POM resolves its parent from a remote repository. This inconsistency in parent resolution can cause unexpected build behavior.

It's recommended to align the parent configuration with the main pom.xml by using the same version and removing the relativePath.

    <parent>
        <groupId>com.google.cloud</groupId>
        <artifactId>google-cloud-bigquery-parent</artifactId>
        <version>2.60.1-SNAPSHOT</version>
    </parent>


<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery-jdbc-it</artifactId>
<version>0.4.0</version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The version 0.4.0 is hardcoded and inconsistent with the main module's version (0.4.1-SNAPSHOT). To ensure consistency and ease maintenance, this module should have the same version as the google-cloud-bigquery-jdbc module.

    <version>0.4.1-SNAPSHOT</version>

<name>BigQuery JDBC IT Assembly</name>
<packaging>pom</packaging>

<properties>
<animal.sniffer.skip>true</animal.sniffer.skip>
<checkstyle.skip>true</checkstyle.skip>
<enforcer.skip>true</enforcer.skip>
</properties>

<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery-jdbc</artifactId>
<version>0.4.0</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery-jdbc</artifactId>
<version>0.4.0</version>
<scope>test</scope>
</dependency>
Comment on lines +24 to +36
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

There are a couple of issues with these dependencies:

  1. The dependency on google-cloud-bigquery-jdbc (lines 31-36) is redundant. The test-jar dependency is sufficient for packaging the test classes, and the main JAR is correctly excluded in test-assembly.xml.
  2. The version 0.4.0 is hardcoded. This should use ${project.version} to ensure the test classes from the currently built artifact are used.
        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-bigquery-jdbc</artifactId>
            <version>${project.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>

<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquerystorage</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>1.1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.11.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<directory>target-it</directory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<id>make-test-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/assembly/test-assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
29 changes: 29 additions & 0 deletions google-cloud-bigquery-jdbc/src/assembly/test-assembly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.1 http://maven.apache.org/xsd/assembly-2.1.1.xsd">
<id>standalone</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>

<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>false</useProjectArtifact>
<unpack>true</unpack>
<scope>test</scope>
<excludes>
<exclude>com.google.cloud:google-cloud-bigquery-jdbc:jar</exclude>
</excludes>
<unpackOptions>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
<exclude>META-INF/*.MF</exclude>
</excludes>
</unpackOptions>
</dependencySet>
</dependencySets>
</assembly>
Loading
Loading