-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update clickhouse_qp.clj * MB v0.50.0 * Address breaking changes * Add setup scripts, disable offset feature for now * Merge main, bump versions, address 0.50 changes * Bump versions; update CHANGELOG, README * Remove a redundant override * Disable cards test for now * Disable one more unrelated test
- Loading branch information
Showing
20 changed files
with
292 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM python:3.11.9-alpine | ||
COPY . /app/ | ||
RUN pip install -r /app/requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
requests==2.32.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
import copy | ||
import logging | ||
import os | ||
import pprint | ||
|
||
import requests | ||
|
||
host = os.environ.get('host') if os.environ.get('host') else 'http://localhost' | ||
port = os.environ.get('port') if os.environ.get('port') else '3000' | ||
admin_email = os.environ.get('admin_email') if os.environ.get('admin_email') else '[email protected]' | ||
user_email = os.environ.get('user_email') if os.environ.get('user_email') else '[email protected]' | ||
password = os.environ.get('password') if os.environ.get('password') else 'metabot1' | ||
site_name = 'ClickHouse test' | ||
|
||
endpoints = { | ||
'health_check': '/api/health', | ||
'properties': '/api/session/properties', | ||
'setup': '/api/setup', | ||
'database': '/api/database', | ||
'login': '/api/session', | ||
'user': '/api/user', | ||
} | ||
for k, v in endpoints.items(): | ||
endpoints[k] = f"{host}:{port}{v}" | ||
|
||
db_base_payload = { | ||
"is_on_demand": False, | ||
"is_full_sync": True, | ||
"is_sample": False, | ||
"cache_ttl": None, | ||
"refingerprint": False, | ||
"auto_run_queries": True, | ||
"schedules": {}, | ||
"details": { | ||
"host": "clickhouse", | ||
"port": 8123, | ||
"user": "default", | ||
"password": None, | ||
"dbname": "default", | ||
"scan-all-databases": False, | ||
"ssl": False, | ||
"tunnel-enabled": False, | ||
"advanced-options": False | ||
}, | ||
"name": "Our ClickHouse", | ||
"engine": "clickhouse" | ||
} | ||
|
||
|
||
def health(): | ||
response = requests.get(endpoints['health_check'], verify=False) | ||
if response.json()['status'] == 'ok': | ||
return 'healthy' | ||
else: | ||
health() | ||
|
||
|
||
def check_response(response, op): | ||
if response.status_code >= 300: | ||
print(f'Unexpected status {response.status_code} for {op}', response.text) | ||
exit(1) | ||
|
||
|
||
if __name__ == '__main__': | ||
print("Checking health") | ||
|
||
if health() == 'healthy' and os.environ.get('retry') is None: | ||
print("Healthy, setting up Metabase") | ||
|
||
session = requests.Session() | ||
session_token = None | ||
try: | ||
token = session.get(endpoints['properties'], verify=False).json()['setup-token'] | ||
setup_payload = { | ||
'token': f'{token}', | ||
'user': { | ||
'first_name': 'Admin', | ||
'last_name': 'Admin', | ||
'email': admin_email, | ||
'site_name': site_name, | ||
'password': password, | ||
'password_confirm': password | ||
}, | ||
'database': None, | ||
'invite': None, | ||
'prefs': { | ||
'site_name': site_name, | ||
'site_locale': 'en', | ||
'allow_tracking': False | ||
} | ||
} | ||
print("Getting the setup token") | ||
session_token = session.post(endpoints['setup'], verify=False, json=setup_payload).json()['id'] | ||
except Exception as e: | ||
print("The admin user was already created") | ||
|
||
try: | ||
if session_token is None: | ||
session_token = session.post(endpoints['login'], verify=False, | ||
json={"username": admin_email, "password": password}) | ||
|
||
dbs = session.get(endpoints['database'], verify=False).json() | ||
print("Current databases:") | ||
pprint.pprint(dbs['data']) | ||
|
||
sample_db = next((x for x in dbs['data'] if x['id'] == 1), None) | ||
if sample_db is not None: | ||
print("Deleting the sample database") | ||
res = session.delete(f"{endpoints['database']}/{sample_db['id']}") | ||
check_response(res, 'delete sample db') | ||
else: | ||
print("The sample database was already deleted") | ||
|
||
single_node_db = next((x for x in dbs['data'] | ||
if x['engine'] == 'clickhouse' | ||
and x['details']['host'] == 'clickhouse'), None) | ||
if single_node_db is None: | ||
print("Creating ClickHouse single node db") | ||
single_node_payload = copy.deepcopy(db_base_payload) | ||
single_node_payload['name'] = 'ClickHouse (single node)' | ||
res = session.post(endpoints['database'], verify=False, json=single_node_payload) | ||
check_response(res, 'create single node db') | ||
else: | ||
print("The single node database was already created") | ||
|
||
# cluster_db = next((x for x in dbs['data'] | ||
# if x['engine'] == 'clickhouse' | ||
# and x['details']['host'] == 'nginx'), None) | ||
# if cluster_db is None: | ||
# print("Creating ClickHouse cluster db") | ||
# cluster_db_payload = copy.deepcopy(db_base_payload) | ||
# cluster_db_payload['details']['host'] = 'nginx' | ||
# cluster_db_payload['name'] = 'ClickHouse (cluster)' | ||
# res = session.post(endpoints['database'], verify=False, json=cluster_db_payload) | ||
# check_response(res) | ||
# else: | ||
# print("The cluster database was already created") | ||
|
||
print("Creating a regular user") | ||
user_payload = {"first_name": "User", "last_name": "User", "email": user_email, "password": password} | ||
res = session.post(endpoints['user'], verify=False, json=user_payload) | ||
check_response(res, 'create user') | ||
|
||
print("Done!") | ||
except Exception as e: | ||
logging.exception("Failed to setup Metabase", e) | ||
exit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ | |
.cpcache | ||
.joyride | ||
.nrepl-port | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
version: '3.8' | ||
services: | ||
|
||
########################################################################################################## | ||
# ClickHouse single node (CH driver + Metabase tests) | ||
########################################################################################################## | ||
|
||
clickhouse: | ||
image: 'clickhouse/clickhouse-server:24.4-alpine' | ||
image: 'clickhouse/clickhouse-server:24.5-alpine' | ||
container_name: 'metabase-driver-clickhouse-server' | ||
ports: | ||
- '8123:8123' | ||
|
@@ -65,7 +64,7 @@ services: | |
########################################################################################################## | ||
|
||
clickhouse_cluster_node1: | ||
image: 'clickhouse/clickhouse-server:${CLICKHOUSE_VERSION-24.4-alpine}' | ||
image: 'clickhouse/clickhouse-server:${CLICKHOUSE_VERSION-24.5-alpine}' | ||
ulimits: | ||
nofile: | ||
soft: 262144 | ||
|
@@ -82,7 +81,7 @@ services: | |
- './.docker/clickhouse/users.xml:/etc/clickhouse-server/users.xml' | ||
|
||
clickhouse_cluster_node2: | ||
image: 'clickhouse/clickhouse-server:${CLICKHOUSE_VERSION-24.4-alpine}' | ||
image: 'clickhouse/clickhouse-server:${CLICKHOUSE_VERSION-24.5-alpine}' | ||
ulimits: | ||
nofile: | ||
soft: 262144 | ||
|
@@ -114,8 +113,9 @@ services: | |
########################################################################################################## | ||
|
||
metabase: | ||
image: metabase/metabase-enterprise:v1.49.14 | ||
image: metabase/metabase-enterprise:v1.50.0 | ||
container_name: metabase-with-clickhouse-driver | ||
hostname: metabase | ||
environment: | ||
'MB_HTTP_TIMEOUT': '5000' | ||
'JAVA_TIMEZONE': 'UTC' | ||
|
@@ -124,3 +124,24 @@ services: | |
volumes: | ||
- '../../../resources/modules/clickhouse.metabase-driver.jar:/plugins/clickhouse.jar' | ||
- './.docker/clickhouse/single_node_tls/certificates/ca.crt:/certs/ca.crt' | ||
healthcheck: | ||
test: curl --fail -X GET -I http://localhost:3000/api/health || exit 1 | ||
interval: 15s | ||
timeout: 5s | ||
retries: 10 | ||
|
||
setup: | ||
build: .docker/setup/. | ||
container_name: metabase-clickhouse-setup | ||
volumes: | ||
- .docker/setup/setup.py:/app/setup.py | ||
depends_on: | ||
metabase: | ||
condition: service_healthy | ||
command: python /app/setup.py | ||
environment: | ||
host: http://metabase | ||
port: 3000 | ||
admin_email: '[email protected]' | ||
user_email: '[email protected]' | ||
password: 'metabot1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.