mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Add tests
This commit is contained in:
parent
4734d416a5
commit
0fc0a89f80
@ -1,10 +1,12 @@
|
||||
import inspect
|
||||
from contextlib import nullcontext as does_not_raise
|
||||
|
||||
import pytest
|
||||
import time
|
||||
import os.path
|
||||
|
||||
from helpers.cluster import ClickHouseCluster
|
||||
from helpers.client import QueryRuntimeException
|
||||
from helpers.test_tools import assert_eq_with_retry, TSV
|
||||
|
||||
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
@ -83,6 +85,33 @@ def test_create_and_drop():
|
||||
node1.query("DROP FUNCTION f1")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ignore, expected_raise",
|
||||
[("true", does_not_raise()), ("false", pytest.raises(QueryRuntimeException))],
|
||||
)
|
||||
def test_create_and_drop_udf_on_cluster(ignore, expected_raise):
|
||||
node1.replace_config(
|
||||
"/etc/clickhouse-server/users.d/users.xml",
|
||||
inspect.cleandoc(
|
||||
f"""
|
||||
<clickhouse>
|
||||
<profiles>
|
||||
<default>
|
||||
<ignore_on_cluster_for_replicated_udf_queries>{ignore}</ignore_on_cluster_for_replicated_udf_queries>
|
||||
</default>
|
||||
</profiles>
|
||||
</clickhouse>
|
||||
"""
|
||||
),
|
||||
)
|
||||
node1.query("SYSTEM RELOAD CONFIG")
|
||||
|
||||
with expected_raise:
|
||||
node1.query("CREATE FUNCTION f1 ON CLUSTER default AS (x, y) -> x + y")
|
||||
assert node1.query("SELECT f1(12, 3)") == "15\n"
|
||||
node1.query("DROP FUNCTION f1 ON CLUSTER default")
|
||||
|
||||
|
||||
def test_create_and_replace():
|
||||
node1.query("CREATE FUNCTION f1 AS (x, y) -> x + y")
|
||||
assert node1.query("SELECT f1(12, 3)") == "15\n"
|
||||
|
@ -1,3 +1,4 @@
|
||||
import inspect
|
||||
import pytest
|
||||
import time
|
||||
|
||||
@ -82,6 +83,37 @@ def test_create_replicated_on_cluster(started_cluster, entity):
|
||||
node1.query(f"DROP {entity.keyword} {entity.name} {entity.options}")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("entity", entities, ids=get_entity_id)
|
||||
def test_create_replicated_on_cluster_ignore(started_cluster, entity):
|
||||
node1.replace_config(
|
||||
"/etc/clickhouse-server/users.d/users.xml",
|
||||
inspect.cleandoc(
|
||||
f"""
|
||||
<clickhouse>
|
||||
<profiles>
|
||||
<default>
|
||||
<ignore_on_cluster_for_replicated_access_entities_queries>true</ignore_on_cluster_for_replicated_access_entities_queries>
|
||||
</default>
|
||||
</profiles>
|
||||
</clickhouse>
|
||||
"""
|
||||
),
|
||||
)
|
||||
node1.query("SYSTEM RELOAD CONFIG")
|
||||
|
||||
node1.query(
|
||||
f"CREATE {entity.keyword} {entity.name} ON CLUSTER default {entity.options}"
|
||||
)
|
||||
assert (
|
||||
f"cannot insert because {entity.keyword.lower()} `{entity.name}{entity.options}` already exists in replicated"
|
||||
in node2.query_and_get_error_with_retry(
|
||||
f"CREATE {entity.keyword} {entity.name} {entity.options}"
|
||||
)
|
||||
)
|
||||
|
||||
node1.query(f"DROP {entity.keyword} {entity.name} {entity.options}")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("entity", entities, ids=get_entity_id)
|
||||
def test_create_replicated_if_not_exists_on_cluster(started_cluster, entity):
|
||||
node1.query(
|
||||
|
Loading…
Reference in New Issue
Block a user