Skip to content

Commit

Permalink
#41 Remove jdbc driver from jar (#42)
Browse files Browse the repository at this point in the history
* Configure manifest to run tests without installing the driver

See https://discourse.metabase.com/t/running-integration-tests-with-deps-edn-build-without-symlink/20157/7

* #41: Remove JDBC driver from uberjar

* Add note about removed version logging

* Implement review findings
  • Loading branch information
kaklakariada authored May 27, 2022
1 parent daf3259 commit 1bc5ede
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('metabase-driver/deps.edn', 'metabase/**/deps.edn') }}
key: ${{ runner.os }}-maven-${{ hashFiles('metabase-driver/deps.edn', 'metabase-driver/scripts/run-integration-tests.sh', 'metabase/**/deps.edn') }}
restore-keys: |
${{ runner.os }}-maven-
Expand Down
14 changes: 1 addition & 13 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{:paths
["src" "resources"]

:mvn/repos
{"Exasol" {:url "https://maven.exasol.com/artifactory/exasol-releases"}}

:deps
{com.exasol/exasol-jdbc {:mvn/version "7.1.10"}}

;; Build the driver with clojure -X:build
:aliases
{:build
Expand All @@ -20,10 +14,4 @@
; clojure -M:clj-kondo --lint src test --debug
:clj-kondo
{:replace-deps {clj-kondo/clj-kondo {:mvn/version "2022.04.25"}}
:main-opts ["-m" "clj-kondo.main"]}}

:oss
;; JDBC driver isn't GPL-compatible
{:replace-deps {}}
:ee
{}}
:main-opts ["-m" "clj-kondo.main"]}}}
3 changes: 3 additions & 0 deletions doc/changes/changes_1.0.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ Code name: Adapt to Metabase 0.43.1

In this release we adapted the driver to Metabase version 0.43.1 and migrated the build system to deps.edn. This release was only tested with Metabase 0.43.1. If you use an older version of Metabase please use metabase-driver 1.0.0.

Note: During implementation of #35 and #41 the logging of the version for the driver and the Exasol JDBC driver was removed. These features will be added again in [#40](https://github.com/exasol/metabase-driver/issues/40) and [#43](https://github.com/exasol/metabase-driver/issues/43).

## Features

* #38: Adapted driver to Metabase version 0.43.0
* #35: Migrated build system to deps.edn and adapted driver to Metabase version 0.43.1
* #41: Removed Exasol JDBC driver from built driver jar
43 changes: 27 additions & 16 deletions scripts/run-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ set -o errexit
set -o nounset
set -o pipefail

readonly jdbc_driver_version=7.1.10

exasol_driver_dir="$( cd "$(dirname "$0")/.." >/dev/null 2>&1 ; pwd -P )"
readonly exasol_driver_dir
metabase_dir=$(cd "$exasol_driver_dir/../metabase"; pwd)
readonly metabase_dir
readonly metabase_plugin_dir="$metabase_dir/plugins"
readonly skip_build=${skip_build:-false}
readonly driver_jar="$exasol_driver_dir/target/exasol.metabase-driver.jar"

log_color() {
local color="$1"
Expand Down Expand Up @@ -66,15 +68,28 @@ patch_excluded_tests() {
fi
}

build_and_install_driver() {
log_info "Building exasol driver $driver_jar..."
local plugin_dir="$metabase_dir/plugins"
cd "$exasol_driver_dir"
clojure -X:build :project-dir "\"$(pwd)\""
ls -lah "$driver_jar"
log_info "Installing exasol driver $driver_jar to $plugin_dir"
mkdir -p "$plugin_dir"
cp -v "$driver_jar" "$plugin_dir"
install_jdbc_driver() {
if [ -f "$metabase_plugin_dir" ]; then
log_error "$metabase_plugin_dir exists but is a file, it should be a directory. Please delete it."
exit 1
fi

if [ ! -d "$metabase_plugin_dir" ]; then
log_info "Creating directory $metabase_plugin_dir"
mkdir -p "$metabase_plugin_dir"
fi

local exasol_driver_filename="exasol-jdbc.jar"
local exasol_driver_path="$metabase_plugin_dir/$exasol_driver_filename"
if [ ! -f "$exasol_driver_path" ]; then
mvn org.apache.maven.plugins:maven-dependency-plugin:3.2.0:get --batch-mode \
-DremoteRepositories=https://maven.exasol.com/artifactory/exasol-releases \
-Dartifact=com.exasol:exasol-jdbc:$jdbc_driver_version
log_info "Installing Exasol JDBC driver to $exasol_driver_path"
cp -v "$HOME/.m2/repository/com/exasol/exasol-jdbc/$jdbc_driver_version/exasol-jdbc-$jdbc_driver_version.jar" "$exasol_driver_path"
else
log_trace "Exasol JDBC driver already exists in $exasol_driver_path"
fi
}

get_exasol_certificate_fingerprint() {
Expand Down Expand Up @@ -107,12 +122,7 @@ get_exasol_certificate_fingerprint() {

check_preconditions
patch_excluded_tests

if [ "$skip_build" == "true" ]; then
log_error "Skipping driver build"
else
build_and_install_driver
fi
install_jdbc_driver

if [[ -z "${EXASOL_FINGERPRINT+x}" ]] ; then
log_info "Getting certificate fingerprint from $EXASOL_HOST..."
Expand All @@ -137,6 +147,7 @@ MB_EXASOL_TEST_HOST=$EXASOL_HOST \
MB_EXASOL_TEST_CERTIFICATE_FINGERPRINT=$fingerprint \
MB_EXASOL_TEST_USER=$EXASOL_USER \
MB_EXASOL_TEST_PASSWORD=$EXASOL_PASSWORD \
MB_DEV_ADDITIONAL_DRIVER_MANIFEST_PATHS="$exasol_driver_dir/resources/metabase-plugin.yaml" \
MB_ENCRYPTION_SECRET_KEY=$(openssl rand -base64 32) \
DRIVERS=exasol \
clojure -J-Duser.country=US -J-Duser.language=en -J-Duser.timezone=UTC \
Expand Down
2 changes: 1 addition & 1 deletion src/metabase/driver/exasol.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
[metabase.util.i18n :refer [trs]]))

(defn get-jdbc-driver-version []
(com.exasol.jdbc.EXADriver/getVersionInfo))
"(unknown)") ; Will be implemented in https://github.com/exasol/metabase-driver/issues/43

(defn get-driver-version
([]
Expand Down

0 comments on commit 1bc5ede

Please sign in to comment.