-
Notifications
You must be signed in to change notification settings - Fork 369
Add cleanup_controller
lifecycle transition
#2414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
soham2560
wants to merge
37
commits into
ros-controls:master
Choose a base branch
from
soham2560:feat/issue-759-reup
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
ae8b359
Issue-759: Adding cleanup service
bailaC b204120
Revert "Issue-759: Adding cleanup service"
bailaC 85a8fe9
Issue-759: Adding cleanup service
bailaC bde0339
Optimize cleanup controllers method.
destogl 2607b38
Fixing format
bailaC fd1449b
fixing pre-commit changes
bailaC bcb013d
Adding tests for cleanup service.
bailaC 4d4ed45
Merge branch 'master' into issue-759
destogl 6a6fe91
Adding controller_manager tests for cleanup controller
bailaC 8dfefc9
Removed unwanted file.
bailaC 872c385
Merge branch 'master' into issue-759
bailaC 418e47a
Correcting clang format and test case
bailaC a65b869
Merge branch 'master' into feat/issue-759-reup
soham2560 7703a50
removed visibility control
soham2560 0345b89
fixed get_state call
soham2560 4840d76
updated cleanup_controller logic to match unload_controller
soham2560 1df34e6
changed get_state to get_lifecycle_state
soham2560 37d6074
added missing include
soham2560 76c62a6
remove unnecessary change
soham2560 9abb886
formatting changes
soham2560 0e86448
change cleanup to unconfigure for services and verbs
soham2560 bf7418c
add documentation
soham2560 3b5f695
added suggestions from #1236
soham2560 437b3d6
fixed failing tests
soham2560 b0954f3
Merge branch 'master' into feat/issue-759-reup
soham2560 c5c3a13
Revert "change cleanup to unconfigure for services and verbs"
soham2560 40cf540
change documentation for unconfigure->cleanup
soham2560 178f423
Merge branch 'master' into feat/issue-759-reup
soham2560 3a8006d
Merge branch 'master' into feat/issue-759-reup
christophfroehlich 93e456b
Merge branch 'master' into feat/issue-759-reup
soham2560 fe73ee0
Merge branch 'master' into feat/issue-759-reup
soham2560 0506367
Merge branch 'master' into feat/issue-759-reup
soham2560 7d9d30e
Merge branch 'master' into feat/issue-759-reup
soham2560 5d603c5
Merge branch 'master' into feat/issue-759-reup
soham2560 5150733
Merge branch 'master' into feat/issue-759-reup
soham2560 e031536
Update controller_manager/src/controller_manager.cpp
soham2560 ec00352
Update controller_manager/src/controller_manager.cpp
soham2560 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
// Copyright 2024 Stogl Robotics Consulting UG (haftungsbeschränkt) | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <gmock/gmock.h> | ||
#include <gtest/gtest.h> | ||
#include <memory> | ||
#include <string> | ||
#include <tuple> | ||
#include <vector> | ||
|
||
#include "controller_interface/controller_interface.hpp" | ||
#include "controller_manager/controller_manager.hpp" | ||
#include "controller_manager_test_common.hpp" | ||
#include "lifecycle_msgs/msg/state.hpp" | ||
#include "test_controller/test_controller.hpp" | ||
#include "test_controller_failed_init/test_controller_failed_init.hpp" | ||
|
||
using test_controller::TEST_CONTROLLER_CLASS_NAME; | ||
using ::testing::_; | ||
using ::testing::Return; | ||
const auto CONTROLLER_NAME_1 = "test_controller1"; | ||
using strvec = std::vector<std::string>; | ||
|
||
class TestCleanupController : public ControllerManagerFixture<controller_manager::ControllerManager> | ||
{ | ||
}; | ||
|
||
TEST_F(TestCleanupController, cleanup_unknown_controller) | ||
{ | ||
ASSERT_EQ( | ||
cm_->cleanup_controller("unknown_controller_name"), controller_interface::return_type::ERROR); | ||
} | ||
|
||
TEST_F(TestCleanupController, cleanup_controller_failed_init) | ||
{ | ||
auto controller_if = cm_->load_controller( | ||
"test_controller_failed_init", | ||
test_controller_failed_init::TEST_CONTROLLER_FAILED_INIT_CLASS_NAME); | ||
|
||
ASSERT_EQ( | ||
cm_->cleanup_controller("test_controller_failed_init"), | ||
controller_interface::return_type::ERROR); | ||
} | ||
|
||
TEST_F(TestCleanupController, cleanup_non_loaded_controller_fails) | ||
{ | ||
// try cleanup non-loaded controller | ||
EXPECT_EQ(cm_->cleanup_controller(CONTROLLER_NAME_1), controller_interface::return_type::ERROR); | ||
} | ||
|
||
TEST_F(TestCleanupController, cleanup_unconfigured_controller) | ||
{ | ||
auto controller_if = | ||
cm_->load_controller(CONTROLLER_NAME_1, test_controller::TEST_CONTROLLER_CLASS_NAME); | ||
ASSERT_NE(controller_if, nullptr); | ||
|
||
ASSERT_EQ( | ||
lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED, | ||
controller_if->get_lifecycle_state().id()); | ||
ASSERT_EQ(cm_->cleanup_controller(CONTROLLER_NAME_1), controller_interface::return_type::OK); | ||
EXPECT_EQ( | ||
lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED, | ||
controller_if->get_lifecycle_state().id()); | ||
} | ||
|
||
TEST_F(TestCleanupController, cleanup_inactive_controller) | ||
{ | ||
auto controller_if = | ||
cm_->load_controller(CONTROLLER_NAME_1, test_controller::TEST_CONTROLLER_CLASS_NAME); | ||
ASSERT_NE(controller_if, nullptr); | ||
ASSERT_EQ( | ||
lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED, | ||
controller_if->get_lifecycle_state().id()); | ||
|
||
cm_->configure_controller(CONTROLLER_NAME_1); | ||
|
||
EXPECT_EQ( | ||
lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE, controller_if->get_lifecycle_state().id()); | ||
ASSERT_EQ(cm_->cleanup_controller(CONTROLLER_NAME_1), controller_interface::return_type::OK); | ||
EXPECT_EQ( | ||
lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED, | ||
controller_if->get_lifecycle_state().id()); | ||
} | ||
|
||
TEST_F(TestCleanupController, cleanup_active_controller) | ||
{ | ||
auto controller_if = | ||
cm_->load_controller(CONTROLLER_NAME_1, test_controller::TEST_CONTROLLER_CLASS_NAME); | ||
ASSERT_NE(controller_if, nullptr); | ||
ASSERT_EQ( | ||
lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED, | ||
controller_if->get_lifecycle_state().id()); | ||
|
||
cm_->configure_controller(CONTROLLER_NAME_1); | ||
|
||
EXPECT_EQ( | ||
lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE, controller_if->get_lifecycle_state().id()); | ||
|
||
switch_test_controllers(strvec{CONTROLLER_NAME_1}, strvec{}, STRICT); | ||
|
||
EXPECT_EQ( | ||
lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE, controller_if->get_lifecycle_state().id()); | ||
|
||
ASSERT_EQ(cm_->cleanup_controller(CONTROLLER_NAME_1), controller_interface::return_type::ERROR); | ||
EXPECT_EQ( | ||
lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE, controller_if->get_lifecycle_state().id()); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check if it is inactive before doing the cleanup? I mean it would also be in unconfigured state right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that you are also doing similar check in the cleanup_controller, if this is the case, I'm okay to remove here