Commit ae4adaad authored by Georgios Bitzes's avatar Georgios Bitzes
Browse files

Test that qclient callbacks are able to issue further requests

parent d01be9d9
Pipeline #302926 failed with stages
in 15 minutes and 29 seconds
Subproject commit ef6aea48fa089ba4032df368a37931952b7d4461
Subproject commit 834fe71776b147181ccfb521adc7030dc8867654
......@@ -772,6 +772,59 @@ TEST_F(Raft_e2e, monitor) {
ASSERT_EQ(response, "+\"get\" \"abc\"\r\n");
}
class PingCallback : qclient::QCallback {
public:
PingCallback(qclient::QClient &q) : qcl(q) {
flag = prom.get_future();
qcl.execCB(this, "PING", SSTR(pingCounter));
}
void finalize(bool result) {
isOk = result;
prom.set_value();
}
virtual void handleResponse(redisReplyPtr &&reply) {
if(!reply) finalize(false);
if(reply->type != REDIS_REPLY_STRING) finalize(false);
if(std::string(reply->str, reply->len) != SSTR(pingCounter)) finalize(false);
qdb_info("Received successful ping response: " << pingCounter);
pingCounter++;
if(pingCounter == 5) return finalize(true);
qcl.execCB(this, "PING", SSTR(pingCounter));
}
bool ok() {
return isOk;
}
void wait() {
flag.get();
}
private:
size_t pingCounter = 0;
std::promise<void> prom;
std::future<void> flag;
size_t counter;
bool isOk = true;
qclient::QClient &qcl;
};
TEST_F(Raft_e2e, PingExtravaganza) {
// A most efficient and sophisticated ping machinery.
spinup(0); spinup(1); spinup(2);
RETRY_ASSERT_TRUE(checkStateConsensus(0, 1, 2));
int leaderID = getLeaderID();
PingCallback pinger(*tunnel(leaderID));
pinger.wait();
ASSERT_TRUE(pinger.ok());
}
TEST_F(Raft_e2e, hincrbymulti) {
spinup(0); spinup(1); spinup(2);
RETRY_ASSERT_TRUE(checkStateConsensus(0, 1, 2));
......
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