2023-03-16 19:37:06 +00:00
|
|
|
import pytest
|
|
|
|
from helpers.client import CommandRequest
|
|
|
|
from helpers.cluster import ClickHouseCluster
|
|
|
|
|
|
|
|
|
|
|
|
cluster = ClickHouseCluster(__file__)
|
|
|
|
|
|
|
|
node = cluster.add_instance(
|
|
|
|
"node",
|
|
|
|
main_configs=["configs/keeper_config.xml"],
|
|
|
|
with_zookeeper=True,
|
|
|
|
stay_alive=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def started_cluster():
|
|
|
|
try:
|
|
|
|
cluster.start()
|
|
|
|
yield cluster
|
|
|
|
|
|
|
|
finally:
|
|
|
|
cluster.shutdown()
|
|
|
|
|
|
|
|
|
|
|
|
def test_base_commands(started_cluster):
|
|
|
|
_ = started_cluster
|
|
|
|
|
|
|
|
command = CommandRequest(
|
|
|
|
[
|
|
|
|
started_cluster.server_bin_path,
|
|
|
|
"keeper-client",
|
2023-04-28 02:51:52 +00:00
|
|
|
"--host",
|
2023-04-28 18:11:45 +00:00
|
|
|
str(cluster.get_instance_ip("zoo1")),
|
2023-04-28 02:51:52 +00:00
|
|
|
"--port",
|
2023-04-28 18:09:24 +00:00
|
|
|
str(cluster.zookeeper_port),
|
2023-03-16 19:37:06 +00:00
|
|
|
"-q",
|
|
|
|
"create test_create_zk_node1 testvalue1;create test_create_zk_node_2 testvalue2;get test_create_zk_node1;",
|
|
|
|
],
|
|
|
|
stdin="",
|
|
|
|
)
|
|
|
|
|
|
|
|
assert command.get_answer() == "testvalue1\n"
|
|
|
|
|
|
|
|
|
|
|
|
def test_four_letter_word_commands(started_cluster):
|
|
|
|
_ = started_cluster
|
|
|
|
|
|
|
|
command = CommandRequest(
|
|
|
|
[
|
|
|
|
started_cluster.server_bin_path,
|
|
|
|
"keeper-client",
|
2023-04-28 02:51:52 +00:00
|
|
|
"--host",
|
2023-04-28 18:11:45 +00:00
|
|
|
str(cluster.get_instance_ip("zoo1")),
|
2023-04-28 02:51:52 +00:00
|
|
|
"--port",
|
2023-04-28 18:09:24 +00:00
|
|
|
str(cluster.zookeeper_port),
|
2023-03-16 19:37:06 +00:00
|
|
|
"-q",
|
|
|
|
"ruok",
|
|
|
|
],
|
|
|
|
stdin="",
|
|
|
|
)
|
|
|
|
|
|
|
|
assert command.get_answer() == "imok\n"
|