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,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2023-08-03 12:05:52 +00:00
|
|
|
@pytest.fixture(scope="module")
|
2023-03-16 19:37:06 +00:00
|
|
|
def started_cluster():
|
|
|
|
try:
|
|
|
|
cluster.start()
|
|
|
|
yield cluster
|
|
|
|
|
|
|
|
finally:
|
|
|
|
cluster.shutdown()
|
|
|
|
|
|
|
|
|
2023-08-03 12:05:52 +00:00
|
|
|
def test_base_commands(started_cluster):
|
|
|
|
_ = started_cluster
|
|
|
|
|
|
|
|
command = CommandRequest(
|
2023-07-28 06:09:57 +00:00
|
|
|
[
|
2023-08-03 12:05:52 +00:00
|
|
|
started_cluster.server_bin_path,
|
2023-07-28 06:09:57 +00:00
|
|
|
"keeper-client",
|
|
|
|
"--host",
|
|
|
|
str(cluster.get_instance_ip("zoo1")),
|
|
|
|
"--port",
|
|
|
|
str(cluster.zookeeper_port),
|
|
|
|
"-q",
|
2023-08-03 12:05:52 +00:00
|
|
|
"create test_create_zk_node1 testvalue1;create test_create_zk_node_2 testvalue2;get test_create_zk_node1;",
|
2023-07-28 06:09:57 +00:00
|
|
|
],
|
|
|
|
stdin="",
|
|
|
|
)
|
2023-07-26 15:13:53 +00:00
|
|
|
|
2023-08-03 12:05:52 +00:00
|
|
|
assert command.get_answer() == "testvalue1\n"
|
2023-03-16 19:37:06 +00:00
|
|
|
|
2023-07-26 05:57:16 +00:00
|
|
|
|
2023-08-03 12:05:52 +00:00
|
|
|
def test_four_letter_word_commands(started_cluster):
|
|
|
|
_ = started_cluster
|
2023-07-26 05:57:16 +00:00
|
|
|
|
2023-08-03 12:05:52 +00:00
|
|
|
command = CommandRequest(
|
2023-07-26 05:57:16 +00:00
|
|
|
[
|
2023-08-03 12:05:52 +00:00
|
|
|
started_cluster.server_bin_path,
|
|
|
|
"keeper-client",
|
|
|
|
"--host",
|
|
|
|
str(cluster.get_instance_ip("zoo1")),
|
|
|
|
"--port",
|
|
|
|
str(cluster.zookeeper_port),
|
|
|
|
"-q",
|
|
|
|
"ruok",
|
|
|
|
],
|
|
|
|
stdin="",
|
2023-07-26 05:57:16 +00:00
|
|
|
)
|
|
|
|
|
2023-03-16 19:37:06 +00:00
|
|
|
assert command.get_answer() == "imok\n"
|