Skip to content

Commit a5d411a

Browse files
Yadunundluca-della-vedovamxgrey
authored
Fix race condition for ingesting/dispensing and disable uncrustify tests by default (#362)
* Disable uncrustify tests by default Signed-off-by: Yadunund <[email protected]> * Try to increase timeout Signed-off-by: Luca Della Vedova <[email protected]> * Revert "Try to increase timeout" This reverts commit 9104594. Signed-off-by: Luca Della Vedova <[email protected]> * Fix failing test in rolling Signed-off-by: Luca Della Vedova <[email protected]> * Fix race condition for ingesting and dispensing Signed-off-by: Michael X. Grey <[email protected]> --------- Signed-off-by: Yadunund <[email protected]> Signed-off-by: Luca Della Vedova <[email protected]> Signed-off-by: Michael X. Grey <[email protected]> Co-authored-by: Luca Della Vedova <[email protected]> Co-authored-by: Michael X. Grey <[email protected]>
1 parent df95bc5 commit a5d411a

File tree

8 files changed

+66
-50
lines changed

8 files changed

+66
-50
lines changed

rmf_fleet_adapter/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ foreach(pkg ${dep_pkgs})
4949
find_package(${pkg} REQUIRED)
5050
endforeach()
5151

52-
if(BUILD_TESTING)
52+
# Disable uncrustify tests by default.
53+
set(TEST_UNCRUSTIFY "Off")
54+
if(BUILD_TESTING AND TEST_UNCRUSTIFY)
5355
find_package(ament_cmake_uncrustify REQUIRED)
5456
find_file(uncrustify_config_file
5557
NAMES "rmf_code_style.cfg"

rmf_fleet_adapter/src/rmf_fleet_adapter/phases/DispenseItem.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,13 @@ LegacyTask::StatusMsg DispenseItem::ActivePhase::_get_status(
160160
status.state = LegacyTask::StatusMsg::STATE_ACTIVE;
161161

162162
using rmf_dispenser_msgs::msg::DispenserResult;
163-
if (dispenser_result
164-
&& dispenser_result->request_guid == _request_guid
165-
&& is_newer(dispenser_result->time, _last_msg))
163+
if (dispenser_result && dispenser_result->request_guid == _request_guid)
166164
{
167-
_last_msg = dispenser_result->time;
165+
if (is_newer(dispenser_result->time, _last_msg))
166+
{
167+
_last_msg = dispenser_result->time;
168+
}
169+
168170
switch (dispenser_result->status)
169171
{
170172
case DispenserResult::ACKNOWLEDGED:

rmf_fleet_adapter/src/rmf_fleet_adapter/phases/IngestItem.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,13 @@ LegacyTask::StatusMsg IngestItem::ActivePhase::_get_status(
159159
status.state = LegacyTask::StatusMsg::STATE_ACTIVE;
160160

161161
using rmf_ingestor_msgs::msg::IngestorResult;
162-
if (ingestor_result
163-
&& ingestor_result->request_guid == _request_guid
164-
&& is_newer(ingestor_result->time, _last_msg))
162+
if (ingestor_result && ingestor_result->request_guid == _request_guid)
165163
{
166-
_last_msg = ingestor_result->time;
164+
if (is_newer(ingestor_result->time, _last_msg))
165+
{
166+
_last_msg = ingestor_result->time;
167+
}
168+
167169
switch (ingestor_result->status)
168170
{
169171
case IngestorResult::ACKNOWLEDGED:

rmf_fleet_adapter/src/rmf_fleet_adapter/phases/Utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace phases {
2323
bool is_newer(const builtin_interfaces::msg::Time& a,
2424
const builtin_interfaces::msg::Time& b)
2525
{
26-
return a.sec > b.sec || (a.sec == b.sec && a.nanosec > b.nanosec);
26+
return a.sec > b.sec || (a.sec == b.sec && a.nanosec >= b.nanosec);
2727
}
2828

2929
} // namespace phases

rmf_task_ros2/CMakeLists.txt

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,22 @@ ament_export_targets(rmf_task_ros2 HAS_LIBRARY_TARGET)
5555
ament_export_dependencies(rmf_traffic rmf_task_msgs rclcpp nlohmann_json)
5656

5757
#===============================================================================
58-
58+
set(TEST_UNCRUSTIFY "Off")
5959
if(BUILD_TESTING)
6060
find_package(ament_cmake_catch2 QUIET)
61-
find_package(ament_cmake_uncrustify REQUIRED)
62-
find_file(uncrustify_config_file
63-
NAMES "rmf_code_style.cfg"
64-
PATHS "${rmf_utils_DIR}/../../../share/rmf_utils/")
65-
66-
ament_uncrustify(
67-
ARGN include src test
68-
CONFIG_FILE ${uncrustify_config_file}
69-
LANGUAGE C++
70-
MAX_LINE_LENGTH 80
71-
)
61+
if (TEST_UNCRUSTIFY)
62+
find_package(ament_cmake_uncrustify REQUIRED)
63+
find_file(uncrustify_config_file
64+
NAMES "rmf_code_style.cfg"
65+
PATHS "${rmf_utils_DIR}/../../../share/rmf_utils/")
66+
67+
ament_uncrustify(
68+
ARGN include src test
69+
CONFIG_FILE ${uncrustify_config_file}
70+
LANGUAGE C++
71+
MAX_LINE_LENGTH 80
72+
)
73+
endif()
7274

7375
file(GLOB_RECURSE unit_test_srcs "test/*.cpp")
7476

rmf_task_ros2/test/bidding/test_SelfBid.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,24 @@ SCENARIO("Auction with 2 Bids", "[TwoBids]")
9090
exec_options.context = rcl_context;
9191
rclcpp::executors::SingleThreadedExecutor executor(exec_options);
9292
executor.add_node(node);
93+
const auto now = std::chrono::steady_clock::now();
9394

9495
auto bidder1 = AsyncBidder::make(
9596
node,
96-
[&test_notice_bidder1](const auto& notice, auto respond)
97+
[&test_notice_bidder1, &now](const auto& notice, auto respond)
9798
{
9899
Response::Proposal best_robot_estimate;
99100
test_notice_bidder1 = notice.request;
100101
best_robot_estimate.fleet_name = "bidder1";
101-
best_robot_estimate.finish_time =
102-
std::chrono::steady_clock::time_point::max();
102+
best_robot_estimate.finish_time = now + std::chrono::seconds(1000);
103103

104104
respond(Response{best_robot_estimate, {}});
105105
}
106106
);
107107

108108
auto bidder2 = AsyncBidder::make(
109109
node,
110-
[&test_notice_bidder2](const auto& notice, auto respond)
110+
[&test_notice_bidder2, &now](const auto& notice, auto respond)
111111
{
112112
auto request = nlohmann::json::parse(notice.request);
113113
if (request["category"] == "patrol")
@@ -117,8 +117,7 @@ SCENARIO("Auction with 2 Bids", "[TwoBids]")
117117
Response::Proposal best_robot_estimate;
118118
best_robot_estimate.new_cost = 2.3; // lower cost than bidder1
119119
best_robot_estimate.fleet_name = "bidder2";
120-
best_robot_estimate.finish_time =
121-
std::chrono::steady_clock::time_point::min();
120+
best_robot_estimate.finish_time = now + std::chrono::seconds(1);
122121
test_notice_bidder2 = notice.request;
123122

124123
respond(Response{best_robot_estimate, {}});

rmf_traffic_ros2/CMakeLists.txt

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,24 @@ if (rmf_traffic_FOUND)
4141
message(STATUS "rmf_traffic_INCLUDE_DIRS: ${rmf_traffic_INCLUDE_DIRS}")
4242
endif()
4343

44+
# Disable uncrustify tests by default.
45+
set(TEST_UNCRUSTIFY "Off")
4446
if(BUILD_TESTING)
4547
find_package(ament_cmake_catch2 QUIET)
46-
find_package(ament_cmake_uncrustify REQUIRED)
47-
find_file(uncrustify_config_file
48-
NAMES "rmf_code_style.cfg"
49-
PATHS "${rmf_utils_DIR}/../../../share/rmf_utils/")
50-
51-
ament_uncrustify(
52-
ARGN include src examples
53-
CONFIG_FILE ${uncrustify_config_file}
54-
LANGUAGE C++
55-
MAX_LINE_LENGTH 80
56-
)
48+
49+
if(TEST_UNCRUSTIFY)
50+
find_package(ament_cmake_uncrustify REQUIRED)
51+
find_file(uncrustify_config_file
52+
NAMES "rmf_code_style.cfg"
53+
PATHS "${rmf_utils_DIR}/../../../share/rmf_utils/")
54+
55+
ament_uncrustify(
56+
ARGN include src examples
57+
CONFIG_FILE ${uncrustify_config_file}
58+
LANGUAGE C++
59+
MAX_LINE_LENGTH 80
60+
)
61+
endif()
5762

5863
file(GLOB_RECURSE unit_test_srcs "test/unit/*.cpp")
5964

rmf_websocket/CMakeLists.txt

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,22 @@ install(
8888
ARCHIVE DESTINATION lib
8989
)
9090

91+
# Disable uncrustify tests by default.
92+
set(TEST_UNCRUSTIFY "Off")
9193
if(BUILD_TESTING)
92-
find_package(ament_cmake_uncrustify REQUIRED)
93-
find_file(uncrustify_config_file
94-
NAMES "rmf_code_style.cfg"
95-
PATHS "${rmf_utils_DIR}/../../../share/rmf_utils/")
96-
97-
ament_uncrustify(
98-
include src
99-
CONFIG_FILE ${uncrustify_config_file}
100-
LANGUAGE C++
101-
MAX_LINE_LENGTH 80
102-
)
94+
if(TEST_UNCRUSTIFY)
95+
find_package(ament_cmake_uncrustify REQUIRED)
96+
find_file(uncrustify_config_file
97+
NAMES "rmf_code_style.cfg"
98+
PATHS "${rmf_utils_DIR}/../../../share/rmf_utils/")
99+
100+
ament_uncrustify(
101+
include src
102+
CONFIG_FILE ${uncrustify_config_file}
103+
LANGUAGE C++
104+
MAX_LINE_LENGTH 80
105+
)
106+
endif()
103107

104108
# unit test
105109
find_package(ament_cmake_catch2 REQUIRED)

0 commit comments

Comments
 (0)