EXPECT_TRUE(isEquivalent(got, Element::fromJSON(expected)));
}
+// Tests status-get command processed handler for standby server in the
+// hub-and-spoke mode.
+TEST_F(HAImplTest, statusGetHubAndSpoke) {
+ TestHAImpl ha_impl;
+ ASSERT_NO_THROW(ha_impl.configure(createValidHubJsonConfiguration()));
+
+ // Starting the service is required prior to running any callouts.
+ NetworkStatePtr network_state(new NetworkState(NetworkState::DHCPv4));
+ ASSERT_NO_THROW(ha_impl.startServices(io_service_, network_state,
+ HAServerType::DHCPv4));
+
+ std::string name = "status-get";
+ ConstElementPtr response =
+ Element::fromJSON("{ \"arguments\": { \"pid\": 1 }, \"result\": 0 }");
+
+ CalloutHandlePtr callout_handle = HooksManager::createCalloutHandle();
+
+ callout_handle->setArgument("name", name);
+ callout_handle->setArgument("response", response);
+
+ ASSERT_NO_THROW(ha_impl.commandProcessed(*callout_handle));
+
+ ConstElementPtr got;
+ callout_handle->getArgument("response", got);
+ ASSERT_TRUE(got);
+
+ std::string expected =
+ "{"
+ " \"arguments\": {"
+ " \"high-availability\": ["
+ " {"
+ " \"ha-mode\": \"hot-standby\","
+ " \"ha-servers\": {"
+ " \"local\": {"
+ " \"role\": \"standby\","
+ " \"scopes\": [ ],"
+ " \"state\": \"waiting\""
+ " },"
+ " \"remote\": {"
+ " \"age\": 0,"
+ " \"analyzed-packets\": 0,"
+ " \"communication-interrupted\": false,"
+ " \"connecting-clients\": 0,"
+ " \"in-touch\": false,"
+ " \"last-scopes\": [ ],"
+ " \"last-state\": \"\","
+ " \"role\": \"primary\","
+ " \"unacked-clients\": 0,"
+ " \"unacked-clients-left\": 0"
+ " }"
+ " }"
+ " },"
+ " {"
+ " \"ha-mode\": \"hot-standby\","
+ " \"ha-servers\": {"
+ " \"local\": {"
+ " \"role\": \"standby\","
+ " \"scopes\": [ ],"
+ " \"state\": \"waiting\""
+ " },"
+ " \"remote\": {"
+ " \"age\": 0,"
+ " \"analyzed-packets\": 0,"
+ " \"communication-interrupted\": false,"
+ " \"connecting-clients\": 0,"
+ " \"in-touch\": false,"
+ " \"last-scopes\": [ ],"
+ " \"last-state\": \"\","
+ " \"role\": \"primary\","
+ " \"unacked-clients\": 0,"
+ " \"unacked-clients-left\": 0"
+ " }"
+ " }"
+ " }"
+ " ],"
+ " \"pid\": 1"
+ " },"
+ " \"result\": 0"
+ "}";
+ EXPECT_TRUE(isEquivalent(got, Element::fromJSON(expected)));
+}
+
// Test ha-maintenance-notify command handler with server name.
TEST_F(HAImplTest, maintenanceNotify) {
HAImpl ha_impl;