mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
separate integration tests for keeper-client
This commit is contained in:
parent
ef9f66e36f
commit
65f2516079
@ -1,18 +1,26 @@
|
|||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
from helper.client import CommandRequest
|
|
||||||
|
|
||||||
|
def get_keeper_socket(cluster, node, port=9181):
|
||||||
|
hosts = cluster.get_instance_ip(node.name)
|
||||||
|
client = socket.socket()
|
||||||
|
client.settimeout(10)
|
||||||
|
client.connect((hosts, port))
|
||||||
|
return client
|
||||||
|
|
||||||
|
|
||||||
def send_4lw_cmd(cluster, node, cmd="ruok", port=9181):
|
def send_4lw_cmd(cluster, node, cmd="ruok", port=9181):
|
||||||
return CommandRequest(
|
client = None
|
||||||
[
|
try:
|
||||||
"cluster.server_bin_path",
|
client = get_keeper_socket(cluster, node, port)
|
||||||
"keeper-client",
|
client.send(cmd.encode())
|
||||||
f"{cluster.get_instance_ip(node.name)}:{port}",
|
data = client.recv(100_000)
|
||||||
"-q",
|
data = data.decode()
|
||||||
cmd,
|
return data
|
||||||
]
|
finally:
|
||||||
).get_answer()
|
if client is not None:
|
||||||
|
client.close()
|
||||||
|
|
||||||
|
|
||||||
NOT_SERVING_REQUESTS_ERROR_MSG = "This instance is not currently serving requests"
|
NOT_SERVING_REQUESTS_ERROR_MSG = "This instance is not currently serving requests"
|
||||||
|
0
tests/integration/test_keeper_client/__init__.py
Normal file
0
tests/integration/test_keeper_client/__init__.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<clickhouse>
|
||||||
|
|
||||||
|
</clickhouse>
|
57
tests/integration/test_keeper_client/test.py
Normal file
57
tests/integration/test_keeper_client/test.py
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
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",
|
||||||
|
f"{cluster.get_instance_ip('zoo1')}:{cluster.zookeeper_port}",
|
||||||
|
"-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",
|
||||||
|
f"{cluster.get_instance_ip('zoo1')}:{cluster.zookeeper_port}",
|
||||||
|
"-q",
|
||||||
|
"ruok",
|
||||||
|
],
|
||||||
|
stdin="",
|
||||||
|
)
|
||||||
|
|
||||||
|
assert command.get_answer() == "imok\n"
|
Loading…
Reference in New Issue
Block a user