mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 21:45:37 +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();
|
||||
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.",
|
||||
arguments));
|
||||
}
|
||||
|
@@ -491,12 +491,13 @@ public:
|
||||
/// a restart.
|
||||
///
|
||||
/// 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
|
||||
/// {
|
||||
/// "arguments": {
|
||||
/// "date-time": "Thu, 01 Feb 2018 21:18:26 GMT",
|
||||
/// "scopes": [ "server1" ],
|
||||
/// "state": "waiting"
|
||||
/// },
|
||||
/// "result": 0,
|
||||
|
@@ -1618,7 +1618,8 @@ TEST_F(HAServiceTest, processHeartbeat) {
|
||||
HAConfigParser parser;
|
||||
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.
|
||||
ConstElementPtr rsp;
|
||||
@@ -1641,6 +1642,15 @@ TEST_F(HAServiceTest, processHeartbeat) {
|
||||
ASSERT_TRUE(date_time);
|
||||
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
|
||||
// in RFC1123. We use the HttpDateTime method to parse this timestamp.
|
||||
HttpDateTime t;
|
||||
|
Reference in New Issue
Block a user