mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Unfinished test
This commit is contained in:
parent
9c6a75c1dd
commit
fb28c16453
@ -0,0 +1,27 @@
|
||||
services:
|
||||
rest:
|
||||
image: tabulario/iceberg-rest
|
||||
container_name: iceberg-rest
|
||||
ports:
|
||||
- 8181:8181
|
||||
environment:
|
||||
- AWS_ACCESS_KEY_ID=minio
|
||||
- AWS_SECRET_ACCESS_KEY=minio123
|
||||
- AWS_REGION=us-east-1
|
||||
- CATALOG_WAREHOUSE=s3://warehouse/
|
||||
- CATALOG_IO__IMPL=org.apache.iceberg.aws.s3.S3FileIO
|
||||
- CATALOG_S3_ENDPOINT=http://minio:9001
|
||||
|
||||
spark-iceberg:
|
||||
image: tabulario/spark-iceberg
|
||||
container_name: spark-iceberg
|
||||
depends_on:
|
||||
- rest
|
||||
environment:
|
||||
- AWS_ACCESS_KEY_ID=minio
|
||||
- AWS_SECRET_ACCESS_KEY=minio123
|
||||
- AWS_REGION=us-east-1
|
||||
ports:
|
||||
- 8080:8080
|
||||
- 10000:10000
|
||||
- 10001:10001
|
@ -14,6 +14,10 @@ services:
|
||||
depends_on:
|
||||
- proxy1
|
||||
- proxy2
|
||||
networks:
|
||||
default:
|
||||
aliases:
|
||||
- warehouse.minio
|
||||
|
||||
# HTTP proxies for Minio.
|
||||
proxy1:
|
||||
|
@ -440,6 +440,7 @@ class ClickHouseCluster:
|
||||
zookeeper_keyfile=None,
|
||||
zookeeper_certfile=None,
|
||||
with_spark=False,
|
||||
with_iceberg_catalog=False,
|
||||
):
|
||||
for param in list(os.environ.keys()):
|
||||
logging.debug("ENV %40s %s" % (param, os.environ[param]))
|
||||
@ -1462,6 +1463,18 @@ class ClickHouseCluster:
|
||||
)
|
||||
return self.base_minio_cmd
|
||||
|
||||
def setup_iceberg_catalog_cmd(self, instance, env_variables, docker_compose_yml_dir):
|
||||
self.base_cmd.extend(
|
||||
["--file", p.join(docker_compose_yml_dir, "docker_compose_iceberg_rest_catalog.yml")]
|
||||
)
|
||||
self.base_iceberg_catalog_cmd = self.compose_cmd(
|
||||
"--env-file",
|
||||
instance.env_file,
|
||||
"--file",
|
||||
p.join(docker_compose_yml_dir, "docker_compose_iceberg_rest_catalog.yml"),
|
||||
)
|
||||
return self.base_minio_cmd
|
||||
|
||||
def setup_azurite_cmd(self, instance, env_variables, docker_compose_yml_dir):
|
||||
self.with_azurite = True
|
||||
env_variables["AZURITE_PORT"] = str(self.azurite_port)
|
||||
@ -1917,6 +1930,9 @@ class ClickHouseCluster:
|
||||
cmds.append(
|
||||
self.setup_minio_cmd(instance, env_variables, docker_compose_yml_dir)
|
||||
)
|
||||
cmds.append(
|
||||
self.setup_iceberg_catalog_cmd(instance, env_variables, docker_compose_yml_dir)
|
||||
)
|
||||
|
||||
if with_azurite and not self.with_azurite:
|
||||
cmds.append(
|
||||
|
0
tests/integration/test_database_iceberg/__init__.py
Normal file
0
tests/integration/test_database_iceberg/__init__.py
Normal file
118
tests/integration/test_database_iceberg/test.py
Normal file
118
tests/integration/test_database_iceberg/test.py
Normal file
@ -0,0 +1,118 @@
|
||||
import glob
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
import uuid
|
||||
import requests
|
||||
import pytest
|
||||
|
||||
from helpers.cluster import ClickHouseCluster, ClickHouseInstance, is_arm
|
||||
from helpers.s3_tools import (
|
||||
get_file_contents,
|
||||
list_s3_objects,
|
||||
prepare_s3_bucket,
|
||||
)
|
||||
|
||||
BASE_URL = "http://rest:8181/v1"
|
||||
BASE_URL_LOCAL = "http://localhost:8181/v1"
|
||||
|
||||
|
||||
def create_namespace(name):
|
||||
payload = {
|
||||
"namespace": [name],
|
||||
"properties": {"owner": "clickhouse", "description": "test namespace"},
|
||||
}
|
||||
|
||||
headers = {"Content-Type": "application/json"}
|
||||
response = requests.post(
|
||||
f"{BASE_URL_LOCAL}/namespaces", headers=headers, data=json.dumps(payload)
|
||||
)
|
||||
if response.status_code == 200:
|
||||
print(f"Namespace '{name}' created successfully.")
|
||||
else:
|
||||
raise Exception(
|
||||
f"Failed to create namespace. Status code: {response.status_code}, Response: {response.text}"
|
||||
)
|
||||
|
||||
|
||||
def list_namespaces():
|
||||
response = requests.get(f"{BASE_URL_LOCAL}/namespaces")
|
||||
if response.status_code == 200:
|
||||
return response.json()
|
||||
else:
|
||||
raise Exception(f"Failed to list namespaces: {response.status_code}")
|
||||
|
||||
|
||||
def create_table(name, namespace):
|
||||
payload = {
|
||||
"name": name,
|
||||
"schema": {
|
||||
"type": "struct",
|
||||
"fields": [
|
||||
{"id": 1, "name": "name", "type": "String", "required": True},
|
||||
{"id": 2, "name": "age", "type": "Int", "required": False},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
headers = {"Content-Type": "application/json"}
|
||||
response = requests.post(
|
||||
f"{BASE_URL_LOCAL}/namespaces/{namespace}/tables",
|
||||
headers=headers,
|
||||
data=json.dumps(payload),
|
||||
)
|
||||
if response.status_code == 200:
|
||||
print(f"Table '{name}' created successfully.")
|
||||
else:
|
||||
raise Exception(
|
||||
f"Failed to create a table. Status code: {response.status_code}, Response: {response.text}"
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def started_cluster():
|
||||
try:
|
||||
cluster = ClickHouseCluster(__file__, with_spark=True)
|
||||
cluster.add_instance(
|
||||
"node1",
|
||||
main_configs=[],
|
||||
user_configs=[],
|
||||
with_minio=True,
|
||||
stay_alive=True,
|
||||
)
|
||||
|
||||
logging.info("Starting cluster...")
|
||||
cluster.start()
|
||||
|
||||
cluster.minio_client.make_bucket("warehouse")
|
||||
prepare_s3_bucket(cluster)
|
||||
|
||||
yield cluster
|
||||
|
||||
finally:
|
||||
cluster.shutdown()
|
||||
|
||||
|
||||
def test_simple(started_cluster):
|
||||
# TODO: properly wait for container
|
||||
time.sleep(10)
|
||||
|
||||
namespace = "kssenii.test.namespace"
|
||||
root_namespace = "kssenii"
|
||||
|
||||
create_namespace(namespace)
|
||||
assert root_namespace in list_namespaces()["namespaces"][0][0]
|
||||
|
||||
node = started_cluster.instances["node1"]
|
||||
node.query(
|
||||
f"""
|
||||
CREATE DATABASE demo ENGINE = Iceberg('{BASE_URL}', 'minio', 'minio123')
|
||||
SETTINGS catalog_type = 'rest', storage_endpoint = 'http://{started_cluster.minio_ip}:{started_cluster.minio_port}/'
|
||||
"""
|
||||
)
|
||||
|
||||
table_name = "testtable"
|
||||
create_table(table_name, "kssenii")
|
||||
|
||||
assert namespace in node.query("USE demo; SHOW TABLES")
|
Loading…
Reference in New Issue
Block a user