use keeper-client in integration tests

This commit is contained in:
pufit 2023-03-14 17:50:09 -04:00 committed by Nikita Mikhaylov
parent bfdc2b58b4
commit 7dc6ff02c3
2 changed files with 11 additions and 18 deletions

View File

@ -113,6 +113,11 @@ void KeeperClient::defineOptions(Poco::Util::OptionSet & options)
Poco::Util::Option("history-file", "", "set path of history file. default `~/.keeper-client-history`")
.argument("history-file")
.binding("history-file"));
options.addOption(
Poco::Util::Option("log-level", "", "set log level")
.argument("log-level")
.binding("log-level"));
}
void KeeperClient::initialize(Poco::Util::Application & /* self */)
@ -198,6 +203,8 @@ void KeeperClient::initialize(Poco::Util::Application & /* self */)
}
}
Poco::Logger::root().setLevel(config().getString("log-level", "error"));
EventNotifier::init();
}

View File

@ -1,26 +1,12 @@
import socket
import time
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
from helper.client import CommandRequest
def send_4lw_cmd(cluster, node, cmd="ruok", port=9181):
client = None
try:
client = get_keeper_socket(cluster, node, port)
client.send(cmd.encode())
data = client.recv(100_000)
data = data.decode()
return data
finally:
if client is not None:
client.close()
return CommandRequest(
["cluster.server_bin_path", "keeper-client", f"{cluster.get_instance_ip(node.name)}:{port}", "-q", cmd]
).get_answer()
NOT_SERVING_REQUESTS_ERROR_MSG = "This instance is not currently serving requests"