Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
eos
QuarkDB
Commits
d01be9d9
Commit
d01be9d9
authored
Feb 12, 2018
by
Georgios Bitzes
Browse files
Add tests for qclient callbacks
parent
95afc854
Pipeline
#302694
passed with stages
in 22 minutes and 33 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
qclient
@
ef6aea48
Compare
f931e875
...
ef6aea48
Subproject commit
f931e87570d1add6e2a8f4f6a3c05ace86a42e8f
Subproject commit
ef6aea48fa089ba4032df368a37931952b7d4461
src/RedisRequest.hh
View file @
d01be9d9
...
...
@@ -36,6 +36,7 @@ public:
using
container
=
std
::
vector
<
std
::
string
>
;
using
iterator
=
container
::
iterator
;
using
const_iterator
=
container
::
const_iterator
;
using
size_type
=
container
::
size_type
;
RedisRequest
(
std
::
initializer_list
<
std
::
string
>
list
)
{
for
(
auto
it
=
list
.
begin
();
it
!=
list
.
end
();
it
++
)
{
...
...
test/CMakeLists.txt
View file @
d01be9d9
...
...
@@ -38,6 +38,7 @@ add_executable(quarkdb-tests
link.cc
main.cc
poller.cc
qclient.cc
raft-journal.cc
raft-lease.cc
raft-parser.cc
...
...
@@ -48,7 +49,6 @@ add_executable(quarkdb-tests
redis-parser.cc
state-machine.cc
${
COMMON_TEST_SOURCES
}
tunnel.cc
utils.cc
)
...
...
test/e2e.cc
View file @
d01be9d9
...
...
@@ -501,6 +501,39 @@ TEST_F(Raft_e2e, test_many_redis_commands) {
ASSERT_REPLY
(
futures
[
i
++
],
"i6"
);
ASSERT_REPLY
(
futures
[
i
++
],
"OK"
);
ASSERT_REPLY
(
futures
[
i
++
],
"ERR Invalid argument: WRONGTYPE Operation against a key holding the wrong kind of value"
);
// Now test qclient callbacks, ensure things stay reasonable when we mix them
// with futures.
TrivialQCallback
c1
;
tunnel
(
leaderID
)
->
execCB
(
&
c1
,
"set"
,
"qcl-counter"
,
"1"
);
TrivialQCallback
c2
;
tunnel
(
leaderID
)
->
execCB
(
&
c2
,
"get"
,
"qcl-counter"
);
std
::
future
<
redisReplyPtr
>
fut1
=
tunnel
(
leaderID
)
->
exec
(
"get"
,
"qcl-counter"
);
std
::
future
<
redisReplyPtr
>
fut2
=
tunnel
(
leaderID
)
->
exec
(
"set"
,
"qcl-counter"
,
"2"
);
std
::
future
<
redisReplyPtr
>
fut3
=
tunnel
(
leaderID
)
->
exec
(
"get"
,
"qcl-counter"
);
TrivialQCallback
c3
;
tunnel
(
leaderID
)
->
execCB
(
&
c3
,
"get"
,
"qcl-counter"
);
TrivialQCallback
c4
;
tunnel
(
leaderID
)
->
execCB
(
&
c4
,
"set"
,
"qcl-counter"
,
"3"
);
TrivialQCallback
c5
;
tunnel
(
leaderID
)
->
execCB
(
&
c5
,
"get"
,
"qcl-counter"
);
std
::
future
<
redisReplyPtr
>
fut4
=
tunnel
(
leaderID
)
->
exec
(
"get"
,
"qcl-counter"
);
ASSERT_REPLY
(
c1
.
getFuture
(),
"OK"
);
ASSERT_REPLY
(
c2
.
getFuture
(),
"1"
);
ASSERT_REPLY
(
fut1
,
"1"
);
ASSERT_REPLY
(
fut2
,
"OK"
);
ASSERT_REPLY
(
fut3
,
"2"
);
ASSERT_REPLY
(
c3
.
getFuture
(),
"2"
);
ASSERT_REPLY
(
c4
.
getFuture
(),
"OK"
);
ASSERT_REPLY
(
c5
.
getFuture
(),
"3"
);
ASSERT_REPLY
(
fut4
,
"3"
);
}
TEST_F
(
Raft_e2e
,
replication_with_trimmed_journal
)
{
...
...
test/
tunnel
.cc
→
test/
qclient
.cc
View file @
d01be9d9
// ----------------------------------------------------------------------
// File:
tunnel
.cc
// File:
qclient
.cc
// Author: Georgios Bitzes - CERN
// ----------------------------------------------------------------------
...
...
test/test-utils.hh
View file @
d01be9d9
...
...
@@ -89,6 +89,26 @@ std::vector<std::string> make_vec(Args... args) {
return
std
::
vector
<
std
::
string
>
{
args
...
};
}
// Yes, passing a callback to QClient to convert it into a future is really
// stupid, since QClient supports futures natively. This is used to test that
// qclient callbacks work as they should..
class
TrivialQCallback
:
public
qclient
::
QCallback
{
public:
TrivialQCallback
()
{}
virtual
~
TrivialQCallback
()
{}
virtual
void
handleResponse
(
qclient
::
redisReplyPtr
&&
reply
)
override
{
promise
.
set_value
(
std
::
move
(
reply
));
}
std
::
future
<
qclient
::
redisReplyPtr
>
getFuture
()
{
return
promise
.
get_future
();
}
private:
std
::
promise
<
qclient
::
redisReplyPtr
>
promise
;
};
class
GlobalEnv
:
public
testing
::
Environment
{
public:
virtual
void
SetUp
()
override
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment