Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tapir
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ashlie Martinez
tapir
Commits
16ccc5b0
Commit
16ccc5b0
authored
9 years ago
by
Irene Y Zhang
Browse files
Options
Downloads
Patches
Plain Diff
fixing up some bugs in the testing framework, still bugs in IR
parent
9a791d12
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
replication/ir/client.h
+1
-1
1 addition, 1 deletion
replication/ir/client.h
replication/ir/tests/ir-test.cc
+48
-22
48 additions, 22 deletions
replication/ir/tests/ir-test.cc
with
49 additions
and
23 deletions
replication/ir/client.h
+
1
−
1
View file @
16ccc5b0
...
...
@@ -46,7 +46,7 @@ namespace ir {
class
IRClient
:
public
Client
{
public:
typedef
std
::
function
<
string
(
const
std
::
set
<
string
>
)
>
decide_t
;
typedef
std
::
function
<
string
(
const
std
::
set
<
string
>
&
)
>
decide_t
;
IRClient
(
const
transport
::
Configuration
&
config
,
Transport
*
transport
,
...
...
This diff is collapsed.
Click to expand it.
replication/ir/tests/ir-test.cc
+
48
−
22
View file @
16ccc5b0
...
...
@@ -43,6 +43,7 @@
#include
<stdio.h>
#include
<gtest/gtest.h>
#include
<vector>
#include
<set>
#include
<sstream>
static
string
replicaLastOp
;
...
...
@@ -78,7 +79,7 @@ public:
}
};
class
IRTest
:
public
::
testing
::
Test
WithParam
<
int
>
class
IRTest
:
public
::
testing
::
Test
{
protected:
std
::
vector
<
IRReplica
*>
replicas
;
...
...
@@ -161,29 +162,54 @@ protected:
}
};
// TEST_P(IRTest, OneOp)
// {
// auto upcall = [this](const string &req, const string &reply) {
// EXPECT_EQ(req, LastRequestOp());
// EXPECT_EQ(reply, "reply: "+LastRequestOp());
TEST_F
(
IRTest
,
OneInconsistentOp
)
{
auto
upcall
=
[
this
](
const
string
&
req
,
const
string
&
reply
)
{
EXPECT_EQ
(
req
,
LastRequestOp
());
//
//
Not guaranteed that any replicas except the leader hav
e
//
// executed this request.
//
EXPECT_EQ(ops[0].back(), req);
//
transport->CancelAllTimers();
//
};
//
Inconsistent ops do not return a valu
e
EXPECT_EQ
(
reply
,
""
);
transport
->
CancelAllTimers
();
};
//
ClientSendNext(upcall);
//
transport->Run();
ClientSendNext
Inconsistent
(
upcall
);
transport
->
Run
();
// // By now, they all should have executed the last request.
// for (int i = 0; i < config->n; i++) {
// EXPECT_EQ(ops[i].size(), 1);
// EXPECT_EQ(ops[i].back(), LastRequestOp());
// }
// }
// By now, they all should have executed the last request.
for
(
int
i
=
0
;
i
<
config
->
n
;
i
++
)
{
EXPECT_EQ
(
iOps
[
i
].
size
(),
1
);
EXPECT_EQ
(
iOps
[
i
].
back
(),
LastRequestOp
());
}
}
TEST_F
(
IRTest
,
OneConsensusOp
)
{
auto
upcall
=
[
this
](
const
string
&
req
,
const
string
&
reply
)
{
EXPECT_EQ
(
req
,
LastRequestOp
());
EXPECT_EQ
(
reply
,
"reply: "
+
LastRequestOp
());
transport
->
CancelAllTimers
();
};
auto
decide
=
[
this
](
const
std
::
set
<
string
>
&
results
)
{
// shouldn't ever get called
EXPECT_FALSE
(
true
);
return
""
;
};
ClientSendNextConsensus
(
upcall
,
decide
);
transport
->
Run
();
// By now, they all should have executed the last request.
for
(
int
i
=
0
;
i
<
config
->
n
;
i
++
)
{
EXPECT_EQ
(
cOps
[
i
].
size
(),
1
);
EXPECT_EQ
(
cOps
[
i
].
back
(),
LastRequestOp
());
}
}
TEST_
P
(
IRTest
,
Unlogged
)
TEST_
F
(
IRTest
,
Unlogged
)
{
auto
upcall
=
[
this
](
const
string
&
req
,
const
string
&
reply
)
{
EXPECT_EQ
(
req
,
LastRequestOp
());
...
...
@@ -207,7 +233,7 @@ TEST_P(IRTest, Unlogged)
EXPECT_EQ
(
0
,
timeouts
);
}
TEST_
P
(
IRTest
,
UnloggedTimeout
)
TEST_
F
(
IRTest
,
UnloggedTimeout
)
{
auto
upcall
=
[
this
](
const
string
&
req
,
const
string
&
reply
)
{
FAIL
();
...
...
@@ -244,7 +270,7 @@ TEST_P(IRTest, UnloggedTimeout)
}
// TEST_
P
(IRTest, ManyOps)
// TEST_
F
(IRTest, ManyOps)
// {
// Client::continuation_t upcall = [&](const string &req, const string &reply) {
// EXPECT_EQ(req, LastRequestOp());
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment