Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metabase: Add test harness for validating Metabase against CrateDB #750

Merged
merged 3 commits into from
Nov 25, 2024
Merged
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
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ updates:
schedule:
interval: "daily"

- directory: "/application/metabase"
package-ecosystem: "pip"
schedule:
interval: "daily"

- directory: "/application/metabase"
package-ecosystem: "docker"
schedule:
interval: "daily"

# Frameworks.

- directory: "/framework/dbt/basic"
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/application-metabase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Metabase

on:
pull_request:
branches: ~
paths:
- '.github/workflows/application-metabase.yml'
- 'application/metabase/**'
- '/requirements.txt'
push:
branches: [ main ]
paths:
- '.github/workflows/application-metabase.yml'
- 'application/metabase/**'
- '/requirements.txt'

# Allow job to be triggered manually.
workflow_dispatch:

# Run job each night after CrateDB nightly has been published.
schedule:
- cron: '0 3 * * *'

# Cancel in-progress jobs when pushing to the same branch.
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}

jobs:

test:
name: "
CrateDB: ${{ matrix.cratedb-version }}
on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ "ubuntu-22.04" ]
python-version: [ "3.12" ]
cratedb-version: [ "nightly" ]

steps:

- name: Acquire sources
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
cache: "pip"
cache-dependency-path: |
pyproject.toml
requirements.txt
requirements-test.txt

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"

- name: Install utilities
run: |
uv pip install --system -r requirements.txt

- name: Validate application/metabase
run: |
ngr test --accept-no-venv application/metabase
38 changes: 38 additions & 0 deletions application/metabase/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Verify Metabase with CrateDB

## About

This folder includes software integration tests for verifying
that Metabase works well together with CrateDB.
The test harness is based on Docker Compose.

## What's Inside

A basic test case that reads CrateDB's `sys.summit` table through
Metabase, after connecting CrateDB as a PostgreSQL database.

## Setup

Setup sandbox and install packages.
```bash
pip install uv
uv venv .venv
source .venv/bin/activate
uv pip install -r requirements.txt -r requirements-test.txt
```

## Usage

Run integration tests.
```bash
pytest
```

Watch service logs.
```shell
docker compose logs -f
```

Note that the setup is configured to keep the containers alive after starting
them. If you want to actively recycle them, invoke `docker compose down` before
running `pytest`.
81 changes: 81 additions & 0 deletions application/metabase/backlog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# CrateDB <-> Metabase backlog


## metabase/metabase:v0.48.4
Starts tripping with a hard error.
```
metabase | 2024-11-23 16:34:33,843 WARN sync.util :: Error in sync step Sync postgres Database 2 'cratedb-testdrive'
metabase | org.postgresql.util.PSQLException: ERROR: line 5:20: no viable alternative at input 'select\n NULL as role,\n t.schemaname as schema,\n t.objectname as table'
```
```sql
with table_privileges as (
select
NULL as role,
t.schemaname as schema,
t.objectname as table,
pg_catalog.has_table_privilege(current_user, '"' || t.schemaname || '"' || '.' || '"' || t.objectname || '"', 'UPDATE') as update,
pg_catalog.has_table_privilege(current_user, '"' || t.schemaname || '"' || '.' || '"' || t.objectname || '"', 'SELECT') as select,
pg_catalog.has_table_privilege(current_user, '"' || t.schemaname || '"' || '.' || '"' || t.objectname || '"', 'INSERT') as insert,
pg_catalog.has_table_privilege(current_user, '"' || t.schemaname || '"' || '.' || '"' || t.objectname || '"', 'DELETE') as delete
from (
select schemaname, tablename as objectname from pg_catalog.pg_tables
union
select schemaname, viewname as objectname from pg_catalog.pg_views
union
select schemaname, matviewname as objectname from pg_catalog.pg_matviews
) t
where t.schemaname !~ '^pg_'
and t.schemaname <> 'information_schema'
and pg_catalog.has_schema_privilege(current_user, t.schemaname, 'USAGE')
)
select t.*
from table_privileges t;
```
```
SQLParseException[line 5:17: no viable alternative at input 'select\nNULL as role,\nt.schemaname as schema,\nt.objectname as table']
```


## metabase/metabase:v0.45.4.3

```
2024-11-22 23:22:07,139 ERROR driver.util :: Failed to connect to Database
org.postgresql.util.PSQLException: The server does not support SSL.
```

```
2024-11-22 23:22:07,290 WARN metabase.email :: Failed to send email
clojure.lang.ExceptionInfo: SMTP host is not set. {:cause :smtp-host-not-set}
```

```
2024-11-22 23:22:08,189 WARN sync.util :: Error running step 'sync-timezone' for postgres Database 2 'cratedb-testdrive'
java.lang.Exception: Unable to parse date string '2024-11-22 23:22:08.175 ' for database engine 'postgres'
```

```
2024-11-22 23:22:08,724 WARN sync.describe-table :: Don't know how to map column type '_int4' to a Field base_type, falling back to :type/*.
2024-11-22 23:22:08,724 WARN sync.describe-table :: Don't know how to map column type '_int4' to a Field base_type, falling back to :type/*.
2024-11-22 23:22:08,725 WARN sync.describe-table :: Don't know how to map column type 'regclass' to a Field base_type, falling back to :type/*.
2024-11-22 23:22:08,725 WARN sync.describe-table :: Don't know how to map column type '_int4' to a Field base_type, falling back to :type/*.
2024-11-22 23:22:08,726 WARN sync.describe-table :: Don't know how to map column type '_int2' to a Field base_type, falling back to :type/*.
...
```

```
2024-11-22 23:22:13,900 WARN sync.util :: Error fingerprinting Table 12 'sys.jobs'
clojure.lang.ExceptionInfo: Error executing query: ERROR: line 2:359: no viable alternative at input 'SELECT "source"."substring531" AS "substring531", "source"."substring532" AS "substring532", "source"."substring533" AS "substring533", "source"."started" AS "started", "source"."substring534" AS "substring534", "source"."substring535" AS "substring535", "source"."substring536" AS "substring536" FROM (SELECT "sys"."jobs"."id" AS "id", ("sys"."jobs"."node"#>'
```

```
2024-11-22 23:22:14,390 WARN sync.util :: Error fingerprinting Table 13 'sys.nodes'
clojure.lang.ExceptionInfo: Error executing query: ERROR: line 2:97: no viable alternative at input 'SELECT "source"."load['probe_timestamp']" AS "load['probe_timestamp']", ("source"."fs['total']"#>'
```

```
2024-11-22 23:22:23,588 ERROR models.field-values :: Error fetching field values
clojure.lang.ExceptionInfo: Error executing query: ERROR: Cannot ORDER BY 'conffeqop': invalid data type 'integer_array'.

2024-11-22 23:22:23,599 ERROR models.field-values :: Error fetching field values
clojure.lang.ExceptionInfo: Error executing query: ERROR: Cannot ORDER BY 'conkey': invalid data type 'smallint_array'.
```
51 changes: 51 additions & 0 deletions application/metabase/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
networks:
metanet-demo:
driver: bridge

services:

# Metabase
# https://www.metabase.com/docs/latest/installation-and-operation/running-metabase-on-docker#example-docker-compose-yaml-file
metabase:
image: metabase/metabase:v0.48.3
container_name: metabase
hostname: metabase
volumes:
- /dev/urandom:/dev/random:ro
ports:
- 3000:3000
networks:
- metanet-demo
healthcheck:
test: curl --fail -I http://localhost:3000/api/health || exit 1
interval: 15s
timeout: 5s
retries: 5

# CrateDB
# https://github.com/crate/crate
cratedb:
image: crate/crate:nightly
container_name: cratedb
hostname: cratedb
ports:
- 4200:4200
- 5432:5432
networks:
- metanet-demo
healthcheck:
# https://github.com/crate/docker-crate/pull/151/files
test: curl --max-time 25 http://localhost:4200 || exit 1
interval: 30s
timeout: 30s

# Wait for all defined services to be fully available by probing their health
# status, even when using `docker compose up --detach`.
# https://marcopeg.com/2019/docker-compose-healthcheck/
wait:
image: dadarek/wait-for-dependencies
depends_on:
metabase:
condition: service_healthy
cratedb:
condition: service_healthy
Loading