For building and testing the driver you will need
- Clojure version 1.10.3 or later
To build Metabase itself you will need
On Ubuntu you can install the dependencies by running
sudo apt install nodejs yarnpkg
Fedora:
yum install perl-Digest-SHA nodejs yarnpkg
On macOS you additionally need gnu-sed
:
brew install nodejs yarnpkg clojure gnu-sed
# Then add gnubin to your PATH:
# export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
Run the following commands to check the current versions:
clojure -M --eval "(clojure-version)"
clojure --version
-
Checkout Metabase at
$HOME/git/metabase
(=$METABASE_DIR
) and build it:cd $HOME/git git clone https://github.com/metabase/metabase.git cd metabase git fetch --all --tags export METABASE_VERSION=v0.48.0 git reset --hard rm -vf target/patch_excluded_test_applied git checkout "tags/${METABASE_VERSION}" -b "${METABASE_VERSION}-branch" # Build (this will take ~15min) ./bin/build.sh
-
Download the Exasol JDBC driver from the Download Portal and install it:
cp exajdbc.jar "$METABASE_DIR/plugins"
-
Checkout the Exasol Metabase driver at
$HOME/git/metabase
(=$METABASE_EXASOL_DRIVER
)git clone https://github.com/exasol/metabase-driver.git cd metabase-driver
To ensure compatibility we need to regularly update to the latest Metabase version. You can find the latest Metabase version on the GitHub release page.
Metabase publishes two variants:
- OSS: version numbers v0.x.y
- Enterprise: version numbers v1.x.y
We only use the OSS variant with version numbers v0.x.y.
To upgrade Metabase follow these steps:
- Check the Metabase driver changelog for breaking changes
- Replace the previous version in all files with the new version by searching for
v0.x.y
- Run unit tests
- Run integration tests
The following things can go wrong:
- The patch excluding inapproriate tests cannot be applied. See excluded tests for details.
- Tests fail or abort
- If possible fix the problem in the driver
- If failures are related to Exasol specifics (e.g. missing
TIME
data type etc.) modify the test in Metabase and update the patch file, see excluded tests for details. - If failures are unrelated to Exasol or the driver, you might delete it and update the patch file, see excluded tests for details.
./scripts/run-unit-tests.sh
To start Metabase with the Exasol driver from source:
export METABASE_DIR="$HOME/git/metabase"
export METABASE_EXASOL_DRIVER="$HOME/git/metabase-driver"
cd $METABASE_DIR
clojure -Sdeps '{:deps {metabase/exasol-driver {:local/root "'"$METABASE_EXASOL_DRIVER"'"}}}' -J-Dmb.dev.additional.driver.manifest.paths=$METABASE_EXASOL_DRIVER/resources/metabase-plugin.yaml -M:run
After startup is complete (log message: Metabase Initialization COMPLETE
) you can access Metabase at http://localhost:3000/.
To start Metabase with the built Exasol driver:
export METABASE_DIR="$HOME/git/metabase"
export METABASE_EXASOL_DRIVER="$HOME/git/metabase-driver"
cd $METABASE_EXASOL_DRIVER
# Build driver
clojure -X:build :project-dir "\"$(pwd)\""
# Install driver
cp -v "$METABASE_EXASOL_DRIVER/target/exasol.metabase-driver.jar" "$METABASE_DIR/plugins/"
# Run Metabase
cd $METABASE_DIR
clojure -M:run
You need to have metabase checked out next to this repository.
Start Exasol docker container:
docker run --publish 8563:8563 --publish 2580:2580 --publish 443:443 --detach --privileged --stop-timeout 120 exasol/docker-db:7.1.23
Start integration tests:
EXASOL_HOST=<hostname> EXASOL_PORT=8563 EXASOL_USER=sys EXASOL_PASSWORD=exasol ./scripts/run-integration-tests.sh
This script builds and installs the driver before running the integration tests. The driver must be installed to $METABASE_DIR/plugins/
for running the integration tests.
To run only a single tests or only tests in a namespace add arguments:
./scripts/run-integration-tests.sh :only name.space/single-test
./scripts/run-integration-tests.sh :only name.space
export MB_EXASOL_TEST_HOST=<hostname>
export MB_EXASOL_TEST_PORT=8563
export MB_EXASOL_TEST_USER=sys
export MB_EXASOL_TEST_PASSWORD=exasol
export MB_EXASOL_TEST_CERTIFICATE_FINGERPRINT=<fingerprint>
export DRIVER=exasol
# Command line REPL:
clojure -A:dev:drivers:drivers-dev:test
# Network REPL:
clojure -M:dev:drivers:drivers-dev:test:nrepl # -> Connect with editor
In the REPL you can use the following commands:
(require 'dev) ; this will take some seconds
(dev/start!)
; Run SQL query:
(dev/query-jdbc-db :exasol "SELECT 1")
(dev/query-jdbc-db [:exasol 'test-data] "SELECT * from CAM_179.\"test_data_users\"")
- deps.edn: Dependencies and comments with useful commands for building and testing
dev/src/dev.clj
: Functions for developing with the REPLtest/metabase/test_runner.clj
: Functions for running tests in REPLtest/metabase/test/data/dataset_definitions.clj
: Available test data setstest/metabase/test/data/dataset_definitions/*.edn
: Definitions of test data sets
To increase the log level for integration tests, edit file $METABASE_DIR/test_config/log4j2-test.xml
.
Exasol does not support the TIME
data type. That is why we can't load the following datasets from the Metabase integration tests:
test-data-with-time
attempted-murders
We exclude TIME
related and other broken tests by patching the metabase sources with patch scripts/exclude_tests.diff
.
Script run-integration-tests.sh
automatically applies this patch when file $METABASE_DIR/target/patch_excluded_test_applied
does not exist.
When the patch file has changed or you updated to a new Metabase release, do the following and re-run the integration tests with run-integration-tests.sh
.
cd $METABASE_DIR
git reset --hard && rm -vf target/patch_excluded_test_applied
If applying the patch fails after upgrading to a new Metabase version, follow these steps:
- Run
cd $METABASE_DIR && git reset --hard && rm -vf target/patch_excluded_test_applied
- Remove the failed part from
exclude_tests.diff
- Run integration tests
run-integration-tests.sh
. This will apply the patch. - Modify Metabase tests to adapt them to Exasol
- Update patch by running
cd $METABASE_DIR && git diff > $METABASE_EXASOL_DRIVER/scripts/exclude_tests.diff
clojure -M:clj-kondo --lint src test --debug
FileNotFoundException: Could not locate metabase/test/data/exasol__init.class, metabase/test/data/exasol.clj or metabase/test/data/exasol.cljc on classpath.
Verify that $METABASE_DIR/modules/drivers/exasol
is a symlink to the metabase-driver
directory.
Tests fail on macOS because they expect numbers with a .
as decimal point (e.g. 1000.0 µs
) but get a ,
(e.g. 1000,0 µs
), e.g.:
expected: (thrown-with-msg?
clojure.lang.ExceptionInfo
#"Timed out after 1000\.0 µs\."
(if (instance? Throwable result) (throw result) result))
actual: #<clojure.lang.ExceptionInfo@141971c7 clojure.lang.ExceptionInfo: Timed out after 1000,0 µs. {:status :timed-out, :type :timed-out}>
Solution: run tests under Linux with English locale or pass arguments -J-Duser.country=US -J-Duser.language=en
to clojure when starting the tests (default in run-integration-tests.sh
).
Some Metabase integration tests depend on the current timestamp and will fail when the year changes. See issue #14 for details.