Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KmakD committed Mar 26, 2024
1 parent e4f9522 commit 115ddb7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 38 deletions.
36 changes: 18 additions & 18 deletions panther_manager/test/plugins/test_shutdown_hosts_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ TEST_F(ShutdownHostsNodeTest, GoodRemovingDuplicatedHosts)
{
CreateWrapper(
{std::make_shared<panther_manager::ShutdownHost>(
"127.0.0.1", "husarion", 22, "echo HelloWorld", 100, true),
"127.0.0.1", "husarion", 22, "echo HelloWorld", 1.0, true),
std::make_shared<panther_manager::ShutdownHost>(
"localhost", "husarion", 22, "echo HelloWorld", 100, true),
"localhost", "husarion", 22, "echo HelloWorld", 1.0, true),
std::make_shared<panther_manager::ShutdownHost>(
"localhost", "husarion", 22, "echo HelloWorld", 100, true)},
"localhost", "husarion", 22, "echo HelloWorld", 1.0, true)},
true);
std::vector<std::shared_ptr<panther_manager::ShutdownHost>> hosts;
ASSERT_TRUE(wrapper->UpdateHosts(hosts));
Expand All @@ -121,7 +121,7 @@ TEST_F(ShutdownHostsNodeTest, FailedWhenUpdateHostReturnsFalse)
{
CreateWrapper(
{std::make_shared<panther_manager::ShutdownHost>(
"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();
Expand All @@ -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<panther_manager::ShutdownHost>("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<panther_manager::ShutdownHost>(
"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)
{
Expand Down
21 changes: 1 addition & 20 deletions panther_manager/test/plugins/test_shutdown_single_host_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,6 @@ TEST_F(TestShutdownSingleHost, Timeout)
EXPECT_EQ(status, BT::NodeStatus::FAILURE);
}

TEST_F(TestShutdownSingleHost, WrongCommand)
{
std::map<std::string, std::string> service = {
{"command", "wrong_command"},
{"ip", "localhost"},
{"ping_for_success", "false"},
{"port", "22"},
{"timeout", "0.2"},
{"username", "husarion"},
};
RegisterNodeWithoutParams<panther_manager::ShutdownSingleHost>("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<std::string, std::string> service = {
Expand All @@ -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);
}

Expand Down

0 comments on commit 115ddb7

Please sign in to comment.