Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
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
savoirfairelinux
opendht
Commits
90c65fb0
Commit
90c65fb0
authored
3 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
tests/dhtrunner: increase put count
parent
c8eb704a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/dhtrunnertester.cpp
+10
-6
10 additions, 6 deletions
tests/dhtrunnertester.cpp
with
10 additions
and
6 deletions
tests/dhtrunnertester.cpp
+
10
−
6
View file @
90c65fb0
...
@@ -94,13 +94,15 @@ DhtRunnerTester::testListen() {
...
@@ -94,13 +94,15 @@ DhtRunnerTester::testListen() {
std
::
condition_variable
cv
;
std
::
condition_variable
cv
;
std
::
atomic_uint
valueCount
(
0
);
std
::
atomic_uint
valueCount
(
0
);
unsigned
putCount
(
0
);
unsigned
putCount
(
0
);
unsigned
putOkCount
(
0
);
unsigned
putOkCount1
(
0
);
unsigned
putOkCount2
(
0
);
unsigned
putOkCount3
(
0
);
auto
a
=
dht
::
InfoHash
::
get
(
"234"
);
auto
a
=
dht
::
InfoHash
::
get
(
"234"
);
auto
b
=
dht
::
InfoHash
::
get
(
"2345"
);
auto
b
=
dht
::
InfoHash
::
get
(
"2345"
);
auto
c
=
dht
::
InfoHash
::
get
(
"23456"
);
auto
c
=
dht
::
InfoHash
::
get
(
"23456"
);
auto
d
=
dht
::
InfoHash
::
get
(
"234567"
);
auto
d
=
dht
::
InfoHash
::
get
(
"234567"
);
constexpr
unsigned
N
=
2
56
;
constexpr
unsigned
N
=
2
048
;
constexpr
unsigned
SZ
=
56
*
1024
;
constexpr
unsigned
SZ
=
56
*
1024
;
auto
ftokena
=
node1
.
listen
(
a
,
[
&
](
const
std
::
shared_ptr
<
dht
::
Value
>&
)
{
auto
ftokena
=
node1
.
listen
(
a
,
[
&
](
const
std
::
shared_ptr
<
dht
::
Value
>&
)
{
...
@@ -132,13 +134,13 @@ DhtRunnerTester::testListen() {
...
@@ -132,13 +134,13 @@ DhtRunnerTester::testListen() {
node2
.
put
(
a
,
dht
::
Value
(
"v1"
),
[
&
](
bool
ok
)
{
node2
.
put
(
a
,
dht
::
Value
(
"v1"
),
[
&
](
bool
ok
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex
);
putCount
++
;
putCount
++
;
if
(
ok
)
putOkCount
++
;
if
(
ok
)
putOkCount
1
++
;
cv
.
notify_all
();
cv
.
notify_all
();
});
});
node2
.
put
(
b
,
dht
::
Value
(
"v2"
),
[
&
](
bool
ok
)
{
node2
.
put
(
b
,
dht
::
Value
(
"v2"
),
[
&
](
bool
ok
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex
);
putCount
++
;
putCount
++
;
if
(
ok
)
putOkCount
++
;
if
(
ok
)
putOkCount
2
++
;
cv
.
notify_all
();
cv
.
notify_all
();
});
});
auto
bigVal
=
std
::
make_shared
<
dht
::
Value
>
();
auto
bigVal
=
std
::
make_shared
<
dht
::
Value
>
();
...
@@ -146,7 +148,7 @@ DhtRunnerTester::testListen() {
...
@@ -146,7 +148,7 @@ DhtRunnerTester::testListen() {
node2
.
put
(
c
,
bigVal
,
[
&
](
bool
ok
)
{
node2
.
put
(
c
,
bigVal
,
[
&
](
bool
ok
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex
);
putCount
++
;
putCount
++
;
if
(
ok
)
putOkCount
++
;
if
(
ok
)
putOkCount
3
++
;
cv
.
notify_all
();
cv
.
notify_all
();
});
});
}
}
...
@@ -154,7 +156,9 @@ DhtRunnerTester::testListen() {
...
@@ -154,7 +156,9 @@ DhtRunnerTester::testListen() {
{
{
std
::
unique_lock
<
std
::
mutex
>
lk
(
mutex
);
std
::
unique_lock
<
std
::
mutex
>
lk
(
mutex
);
CPPUNIT_ASSERT
(
cv
.
wait_for
(
lk
,
30s
,
[
&
]{
return
putCount
==
N
*
3u
;
}));
CPPUNIT_ASSERT
(
cv
.
wait_for
(
lk
,
30s
,
[
&
]{
return
putCount
==
N
*
3u
;
}));
CPPUNIT_ASSERT_EQUAL
(
N
*
3u
,
putOkCount
);
CPPUNIT_ASSERT_EQUAL
(
N
,
putOkCount1
);
CPPUNIT_ASSERT_EQUAL
(
N
,
putOkCount2
);
CPPUNIT_ASSERT_EQUAL
(
N
,
putOkCount3
);
}
}
CPPUNIT_ASSERT
(
ftokena
.
valid
());
CPPUNIT_ASSERT
(
ftokena
.
valid
());
...
...
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