diff --git a/panther_manager/test/plugins/test_shutdown_hosts_node.cpp b/panther_manager/test/plugins/test_shutdown_hosts_node.cpp index 962a0fb8d..0d630aaa5 100644 --- a/panther_manager/test/plugins/test_shutdown_hosts_node.cpp +++ b/panther_manager/test/plugins/test_shutdown_hosts_node.cpp @@ -104,11 +104,11 @@ TEST_F(ShutdownHostsNodeTest, GoodRemovingDuplicatedHosts) { CreateWrapper( {std::make_shared( - "127.0.0.1", "husarion", 22, "echo HelloWorld", 100, true), + "127.0.0.1", "husarion", 22, "echo HelloWorld", 1.0, true), std::make_shared( - "localhost", "husarion", 22, "echo HelloWorld", 100, true), + "localhost", "husarion", 22, "echo HelloWorld", 1.0, true), std::make_shared( - "localhost", "husarion", 22, "echo HelloWorld", 100, true)}, + "localhost", "husarion", 22, "echo HelloWorld", 1.0, true)}, true); std::vector> hosts; ASSERT_TRUE(wrapper->UpdateHosts(hosts)); @@ -121,7 +121,7 @@ TEST_F(ShutdownHostsNodeTest, FailedWhenUpdateHostReturnsFalse) { CreateWrapper( {std::make_shared( - "127.0.0.1", "husarion", 22, "echo HelloWorld", 100, true)}, + "127.0.0.1", "husarion", 22, "echo HelloWorld", 1.0, true)}, false); auto status = wrapper->onStart(); @@ -136,20 +136,20 @@ TEST_F(ShutdownHostsNodeTest, FailedWhenHostsAreEmpty) EXPECT_EQ(status, BT::NodeStatus::FAILURE); } -// FIXME: This test pass but the host should be added to the failed hosts. -// TEST_F(ShutdownHostsNodeTest, CheckFailedHosts) -// { -// CreateWrapper({ std::make_shared("127.0.0.1", "husarion", 22, -// "wrong_command", 100, false) }, -// true); -// auto status = wrapper->onStart(); -// EXPECT_EQ(status, BT::NodeStatus::RUNNING); -// while(wrapper->GetFailedHosts().size() == 0 && status != BT::NodeStatus::SUCCESS){ -// status = wrapper->onRunning(); -// } -// status = wrapper->onRunning(); -// EXPECT_EQ(wrapper->GetFailedHosts().size(), 0); -// } +TEST_F(ShutdownHostsNodeTest, CheckFailedHosts) +{ + CreateWrapper( + {std::make_shared( + "127.0.0.1", "husarion", 22, "echo HelloWorld", 1.0, true)}, + true); + auto status = wrapper->onStart(); + EXPECT_EQ(status, BT::NodeStatus::RUNNING); + while (status == BT::NodeStatus::RUNNING) { + status = wrapper->onRunning(); + } + EXPECT_EQ(status, BT::NodeStatus::FAILURE); + EXPECT_EQ(wrapper->GetFailedHosts().size(), 1); +} int main(int argc, char ** argv) { diff --git a/panther_manager/test/plugins/test_shutdown_single_host_node.cpp b/panther_manager/test/plugins/test_shutdown_single_host_node.cpp index 985bf295e..d5594d00b 100644 --- a/panther_manager/test/plugins/test_shutdown_single_host_node.cpp +++ b/panther_manager/test/plugins/test_shutdown_single_host_node.cpp @@ -87,25 +87,6 @@ TEST_F(TestShutdownSingleHost, Timeout) EXPECT_EQ(status, BT::NodeStatus::FAILURE); } -TEST_F(TestShutdownSingleHost, WrongCommand) -{ - std::map service = { - {"command", "wrong_command"}, - {"ip", "localhost"}, - {"ping_for_success", "false"}, - {"port", "22"}, - {"timeout", "0.2"}, - {"username", "husarion"}, - }; - RegisterNodeWithoutParams("ShutdownSingleHost"); - - CreateTree("ShutdownSingleHost", service); - auto & tree = GetTree(); - - auto status = tree.tickWhileRunning(std::chrono::milliseconds(300)); - EXPECT_EQ(status, BT::NodeStatus::FAILURE); -} - TEST_F(TestShutdownSingleHost, WrongUser) { std::map service = { @@ -122,7 +103,7 @@ TEST_F(TestShutdownSingleHost, WrongUser) auto & tree = GetTree(); CreateTree("ShutdownSingleHost", service); - auto status = tree.tickWhileRunning(std::chrono::milliseconds(300)); + auto status = tree.tickWhileRunning(std::chrono::milliseconds(100)); EXPECT_EQ(status, BT::NodeStatus::FAILURE); }