mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 22:45:18 +00:00
[#1041] HA heartbeat response includes scopes
This commit is contained in:
@@ -1008,6 +1008,13 @@ HAService::processHeartbeat() {
|
|||||||
std::string date_time = HttpDateTime().rfc1123Format();
|
std::string date_time = HttpDateTime().rfc1123Format();
|
||||||
arguments->set("date-time", Element::create(date_time));
|
arguments->set("date-time", Element::create(date_time));
|
||||||
|
|
||||||
|
auto scopes = query_filter_.getServedScopes();
|
||||||
|
ElementPtr scopes_list = Element::createList();
|
||||||
|
for (auto scope : scopes) {
|
||||||
|
scopes_list->add(Element::create(scope));
|
||||||
|
}
|
||||||
|
arguments->set("scopes", scopes_list);
|
||||||
|
|
||||||
return (createAnswer(CONTROL_RESULT_SUCCESS, "HA peer status returned.",
|
return (createAnswer(CONTROL_RESULT_SUCCESS, "HA peer status returned.",
|
||||||
arguments));
|
arguments));
|
||||||
}
|
}
|
||||||
|
@@ -491,12 +491,13 @@ public:
|
|||||||
/// a restart.
|
/// a restart.
|
||||||
///
|
///
|
||||||
/// The ha-heartbeat command takes no arguments. The response contains
|
/// The ha-heartbeat command takes no arguments. The response contains
|
||||||
/// a server state and timestamp in the following format:
|
/// a server state, served scopes and timestamp in the following format:
|
||||||
///
|
///
|
||||||
/// @code
|
/// @code
|
||||||
/// {
|
/// {
|
||||||
/// "arguments": {
|
/// "arguments": {
|
||||||
/// "date-time": "Thu, 01 Feb 2018 21:18:26 GMT",
|
/// "date-time": "Thu, 01 Feb 2018 21:18:26 GMT",
|
||||||
|
/// "scopes": [ "server1" ],
|
||||||
/// "state": "waiting"
|
/// "state": "waiting"
|
||||||
/// },
|
/// },
|
||||||
/// "result": 0,
|
/// "result": 0,
|
||||||
|
@@ -1618,7 +1618,8 @@ TEST_F(HAServiceTest, processHeartbeat) {
|
|||||||
HAConfigParser parser;
|
HAConfigParser parser;
|
||||||
ASSERT_NO_THROW(parser.parse(config_storage, Element::fromJSON(config_text)));
|
ASSERT_NO_THROW(parser.parse(config_storage, Element::fromJSON(config_text)));
|
||||||
|
|
||||||
HAService service(io_service_, network_state_, config_storage);
|
TestHAService service(io_service_, network_state_, config_storage);
|
||||||
|
service.query_filter_.serveDefaultScopes();
|
||||||
|
|
||||||
// Process heartbeat command.
|
// Process heartbeat command.
|
||||||
ConstElementPtr rsp;
|
ConstElementPtr rsp;
|
||||||
@@ -1641,6 +1642,15 @@ TEST_F(HAServiceTest, processHeartbeat) {
|
|||||||
ASSERT_TRUE(date_time);
|
ASSERT_TRUE(date_time);
|
||||||
EXPECT_EQ(Element::string, date_time->getType());
|
EXPECT_EQ(Element::string, date_time->getType());
|
||||||
|
|
||||||
|
auto scopes_list = args->get("scopes");
|
||||||
|
ASSERT_TRUE(scopes_list);
|
||||||
|
EXPECT_EQ(Element::list, scopes_list->getType());
|
||||||
|
ASSERT_EQ(1, scopes_list->size());
|
||||||
|
auto scope = scopes_list->get(0);
|
||||||
|
ASSERT_TRUE(scope);
|
||||||
|
EXPECT_EQ(Element::string, scope->getType());
|
||||||
|
EXPECT_EQ("server1", scope->stringValue());
|
||||||
|
|
||||||
// The response should contain the timestamp in the format specified
|
// The response should contain the timestamp in the format specified
|
||||||
// in RFC1123. We use the HttpDateTime method to parse this timestamp.
|
// in RFC1123. We use the HttpDateTime method to parse this timestamp.
|
||||||
HttpDateTime t;
|
HttpDateTime t;
|
||||||
|
Reference in New Issue
Block a user