2022-04-08 20:48:48 +05:30
|
|
|
from datahub.ingestion.source.sql.clickhouse import ClickHouseConfig
|
2022-02-21 17:36:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_clickhouse_uri_https():
|
|
|
|
config = ClickHouseConfig.parse_obj(
|
|
|
|
{
|
|
|
|
"username": "user",
|
|
|
|
"password": "password",
|
|
|
|
"host_port": "host:1111",
|
|
|
|
"database": "db",
|
2023-08-12 00:11:40 +04:00
|
|
|
"uri_opts": {"protocol": "https"},
|
2022-02-21 17:36:08 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
config.get_sql_alchemy_url()
|
|
|
|
== "clickhouse://user:password@host:1111/db?protocol=https"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def test_clickhouse_uri_native():
|
|
|
|
config = ClickHouseConfig.parse_obj(
|
|
|
|
{
|
|
|
|
"username": "user",
|
|
|
|
"password": "password",
|
|
|
|
"host_port": "host:1111",
|
|
|
|
"scheme": "clickhouse+native",
|
|
|
|
}
|
|
|
|
)
|
2023-10-18 11:34:45 -04:00
|
|
|
assert config.get_sql_alchemy_url() == "clickhouse+native://user:password@host:1111"
|
2022-02-21 17:36:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_clickhouse_uri_native_secure():
|
|
|
|
config = ClickHouseConfig.parse_obj(
|
|
|
|
{
|
|
|
|
"username": "user",
|
|
|
|
"password": "password",
|
|
|
|
"host_port": "host:1111",
|
|
|
|
"database": "db",
|
|
|
|
"scheme": "clickhouse+native",
|
2023-08-12 00:11:40 +04:00
|
|
|
"uri_opts": {"secure": True},
|
2022-02-21 17:36:08 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
config.get_sql_alchemy_url()
|
2023-08-12 00:11:40 +04:00
|
|
|
== "clickhouse+native://user:password@host:1111/db?secure=True"
|
2022-02-21 17:36:08 +02:00
|
|
|
)
|
2022-08-10 01:30:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
def test_clickhouse_uri_default_password():
|
|
|
|
config = ClickHouseConfig.parse_obj(
|
|
|
|
{
|
|
|
|
"username": "user",
|
|
|
|
"host_port": "host:1111",
|
|
|
|
"database": "db",
|
|
|
|
"scheme": "clickhouse+native",
|
|
|
|
}
|
|
|
|
)
|
2023-08-12 00:11:40 +04:00
|
|
|
assert config.get_sql_alchemy_url() == "clickhouse+native://user@host:1111/db"
|
|
|
|
|
|
|
|
|
|
|
|
def test_clickhouse_uri_native_secure_backward_compatibility():
|
|
|
|
config = ClickHouseConfig.parse_obj(
|
|
|
|
{
|
|
|
|
"username": "user",
|
|
|
|
"password": "password",
|
|
|
|
"host_port": "host:1111",
|
|
|
|
"database": "db",
|
|
|
|
"scheme": "clickhouse+native",
|
|
|
|
"secure": True,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
config.get_sql_alchemy_url()
|
|
|
|
== "clickhouse+native://user:password@host:1111/db?secure=True"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def test_clickhouse_uri_https_backward_compatibility():
|
|
|
|
config = ClickHouseConfig.parse_obj(
|
|
|
|
{
|
|
|
|
"username": "user",
|
|
|
|
"password": "password",
|
|
|
|
"host_port": "host:1111",
|
|
|
|
"database": "db",
|
|
|
|
"protocol": "https",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
config.get_sql_alchemy_url()
|
|
|
|
== "clickhouse://user:password@host:1111/db?protocol=https"
|
|
|
|
)
|