Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
ISC Open Source Projects
Kea
Commits
a7267264
Commit
a7267264
authored
Dec 13, 2019
by
Marcin Siodelski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[
#1041
] Added age into the status-get response
parent
3d76d8f1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
1 deletion
+26
-1
src/hooks/dhcp/high_availability/ha_service.cc
src/hooks/dhcp/high_availability/ha_service.cc
+6
-1
src/hooks/dhcp/high_availability/tests/ha_impl_unittest.cc
src/hooks/dhcp/high_availability/tests/ha_impl_unittest.cc
+1
-0
src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc
...hooks/dhcp/high_availability/tests/ha_service_unittest.cc
+19
-0
No files found.
src/hooks/dhcp/high_availability/ha_service.cc
View file @
a7267264
...
...
@@ -985,7 +985,12 @@ HAService::processStatusGet() const {
// communication between the HA peers. Based on that, the user
// may determine if the status returned for the peer is based on
// the heartbeat or is to be determined.
remote
->
set
(
"in-touch"
,
Element
::
create
(
communication_state_
->
getPartnerState
()
>
0
));
auto
in_touch
=
(
communication_state_
->
getPartnerState
()
>
0
);
remote
->
set
(
"in-touch"
,
Element
::
create
(
in_touch
));
auto
age
=
in_touch
?
static_cast
<
long
long
int
>
(
communication_state_
->
getDurationInMillisecs
()
/
1000
)
:
0
;
remote
->
set
(
"age"
,
Element
::
create
(
age
));
try
{
role
=
config_
->
getFailoverPeerConfig
()
->
getRole
();
...
...
src/hooks/dhcp/high_availability/tests/ha_impl_unittest.cc
View file @
a7267264
...
...
@@ -570,6 +570,7 @@ TEST_F(HAImplTest, statusGet) {
"
\"
state
\"
:
\"
waiting
\"
"
" },"
"
\"
remote
\"
: {"
"
\"
age
\"
: 0,"
"
\"
in-touch
\"
: false,"
"
\"
last-scopes
\"
: [ ],"
"
\"
last-state
\"
:
\"\"
,"
...
...
src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc
View file @
a7267264
...
...
@@ -1076,6 +1076,7 @@ TEST_F(HAServiceTest, hotStandbyScopeSelectionThisPrimary) {
"
\"
state
\"
:
\"
hot-standby
\"
"
" }, "
"
\"
remote
\"
: {"
"
\"
age
\"
: 0,"
"
\"
in-touch
\"
: false,"
"
\"
role
\"
:
\"
standby
\"
,"
"
\"
last-scopes
\"
: [ ],"
...
...
@@ -1123,6 +1124,7 @@ TEST_F(HAServiceTest, hotStandbyScopeSelectionThisStandby) {
"
\"
state
\"
:
\"
waiting
\"
"
" }, "
"
\"
remote
\"
: {"
"
\"
age
\"
: 0,"
"
\"
in-touch
\"
: false,"
"
\"
role
\"
:
\"
primary
\"
,"
"
\"
last-scopes
\"
: [ ],"
...
...
@@ -3095,6 +3097,22 @@ TEST_F(HAServiceStateMachineTest, waitingParterDownLoadBalancingPartnerDown) {
ConstElementPtr
ha_servers
=
service_
->
processStatusGet
();
ASSERT_TRUE
(
ha_servers
);
// Hard to know what is the age of the remote data. Therefore, let's simply
// grab it from the response.
ASSERT_EQ
(
Element
::
map
,
ha_servers
->
getType
());
auto
remote
=
ha_servers
->
get
(
"remote"
);
ASSERT_TRUE
(
remote
);
EXPECT_EQ
(
Element
::
map
,
remote
->
getType
());
auto
age
=
remote
->
get
(
"age"
);
ASSERT_TRUE
(
age
);
EXPECT_EQ
(
Element
::
integer
,
age
->
getType
());
auto
age_value
=
age
->
intValue
();
EXPECT_GE
(
age_value
,
0
);
// Now append it to the whole structure for comparison.
std
::
ostringstream
s
;
s
<<
age_value
;
std
::
string
expected
=
"{"
"
\"
local
\"
: {"
"
\"
role
\"
:
\"
primary
\"
,"
...
...
@@ -3102,6 +3120,7 @@ TEST_F(HAServiceStateMachineTest, waitingParterDownLoadBalancingPartnerDown) {
"
\"
state
\"
:
\"
load-balancing
\"
"
" }, "
"
\"
remote
\"
: {"
"
\"
age
\"
: "
+
s
.
str
()
+
","
"
\"
in-touch
\"
: true,"
"
\"
role
\"
:
\"
secondary
\"
,"
"
\"
last-scopes
\"
: [
\"
server1
\"
,
\"
server2
\"
],"
...
...
Write
Preview
Markdown
is supported
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