Commit 3e434475 authored by Georgios Bitzes's avatar Georgios Bitzes
Browse files

Allow showing just the current leader in raft-info

parent 8b6a10e7
Pipeline #341143 passed with stages
in 26 minutes and 11 seconds
......@@ -43,6 +43,10 @@ LinkStatus RaftDispatcher::dispatch(Connection *conn, RedisRequest &req) {
switch(req.getCommand()) {
case RedisCommand::RAFT_INFO: {
// safe, read-only request, does not need authorization
if(req.size() == 2 && caseInsensitiveEquals(req[1], "leader")) {
return conn->string(state.getSnapshot()->leader.toString());
}
return conn->statusVector(this->info().toVector());
}
case RedisCommand::RAFT_FETCH_LAST: {
......
......@@ -425,6 +425,7 @@ TEST_F(Raft_e2e, test_many_redis_commands) {
futures.emplace_back(tunnel(leaderID)->exec("bad_command"));
futures.emplace_back(tunnel(leaderID)->exec("exists", "hash"));
futures.emplace_back(tunnel(leaderID)->exec("exists", "hash2"));
futures.emplace_back(tunnel(leaderID)->exec("raft_info", "leader"));
ASSERT_REPLY(futures[0], 1);
ASSERT_REPLY(futures[1], 1);
......@@ -434,6 +435,7 @@ TEST_F(Raft_e2e, test_many_redis_commands) {
ASSERT_REPLY(futures[5], "ERR unknown command 'bad_command'");
ASSERT_REPLY(futures[6], 0);
ASSERT_REPLY(futures[7], 1);
ASSERT_REPLY(futures[8], myself(leaderID).toString() );
futures.clear();
futures.emplace_back(tunnel(leaderID)->exec("hmset", "hmset_test", "f1", "v1", "f2", "v2"));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment