diff --git a/diagnostic_aggregator/CMakeLists.txt b/diagnostic_aggregator/CMakeLists.txt index 59c8de22e..8ce0b4629 100644 --- a/diagnostic_aggregator/CMakeLists.txt +++ b/diagnostic_aggregator/CMakeLists.txt @@ -84,31 +84,8 @@ if(BUILD_TESTING) file(TO_CMAKE_PATH "${CMAKE_INSTALL_PREFIX}/lib/${PROJECT_NAME}/aggregator_node" AGGREGATOR_NODE) file(TO_CMAKE_PATH "${CMAKE_INSTALL_PREFIX}/lib/${PROJECT_NAME}/add_analyzer" ADD_ANALYZER) file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/test_listener.py" TEST_LISTENER) - # SKIPPING FLAKY TEST - # set(create_analyzers_tests - # "primitive_analyzers" - # "all_analyzers" - # "analyzer_group" - # "empty_root_path") - # foreach(test_name ${create_analyzers_tests}) - # file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/${test_name}.yaml" PARAMETER_FILE) - # file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/expected_output/create_${test_name}" EXPECTED_OUTPUT) - - # configure_file( - # "test/create_analyzers.launch.py.in" - # "test_create_${test_name}.launch.py" - # @ONLY - # ) - # add_launch_test( - # "${CMAKE_CURRENT_BINARY_DIR}/test_create_${test_name}.launch.py" - # TARGET "test_create_${test_name}" - # TIMEOUT 30 - # ENV - # ) - # endforeach() - - set(analyzers_output_tests + set(create_analyzers_tests "primitive_analyzers" "all_analyzers" "analyzer_group" @@ -116,49 +93,72 @@ if(BUILD_TESTING) foreach(test_name ${create_analyzers_tests}) file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/${test_name}.yaml" PARAMETER_FILE) - file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/expected_output/output_${test_name}" EXPECTED_OUTPUT) + file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/expected_output/create_${test_name}" EXPECTED_OUTPUT) configure_file( - "test/test_analyzers_output.launch.py.in" - "test_output_${test_name}.launch.py" + "test/test_create_analyzers.launch.py.in" + "test_create_${test_name}.launch.py" @ONLY ) add_launch_test( - "${CMAKE_CURRENT_BINARY_DIR}/test_output_${test_name}.launch.py" - TARGET "test_output_${test_name}" + "${CMAKE_CURRENT_BINARY_DIR}/test_create_${test_name}.launch.py" + TARGET "test_create_${test_name}" TIMEOUT 30 ENV ) endforeach() - set(add_analyzers_tests - "all_analyzers") + set(analyzers_output_tests + "primitive_analyzers" + "all_analyzers" + "analyzer_group" + "empty_root_path") - foreach(test_name ${add_analyzers_tests}) - file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/default.yaml" PARAMETER_FILE) - file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/${test_name}.yaml" ADD_PARAMETER_FILE) - file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/expected_output/add_${test_name}" EXPECTED_OUTPUT) + foreach(test_name ${analyzers_output_tests}) + file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/${test_name}.yaml" PARAMETER_FILE) + file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/expected_output/output_${test_name}" EXPECTED_OUTPUT) configure_file( - "test/add_analyzers.launch.py.in" - "test_add_${test_name}.launch.py" + "test/test_analyzers_output.launch.py.in" + "test_output_${test_name}.launch.py" @ONLY ) add_launch_test( - "${CMAKE_CURRENT_BINARY_DIR}/test_add_${test_name}.launch.py" - TARGET "test_add_${test_name}" + "${CMAKE_CURRENT_BINARY_DIR}/test_output_${test_name}.launch.py" + TARGET "test_output_${test_name}" TIMEOUT 30 ENV ) endforeach() - # SKIPPING FLAKY TEST + # TODO ... + + # set(add_analyzers_tests + # "all_analyzers") + + # foreach(test_name ${add_analyzers_tests}) + # file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/default.yaml" PARAMETER_FILE) + # file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/${test_name}.yaml" ADD_PARAMETER_FILE) + # file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/expected_output/add_${test_name}" EXPECTED_OUTPUT) + + # configure_file( + # "test/test_add_analyzers.launch.py.in" + # "test_add_${test_name}.launch.py" + # @ONLY + # ) + # add_launch_test( + # "${CMAKE_CURRENT_BINARY_DIR}/test_add_${test_name}.launch.py" + # TARGET "test_add_${test_name}" + # TIMEOUT 30 + # ENV + # ) + # endforeach() + # add_launch_test( # test/test_critical_pub.py # TIMEOUT 30 # ) - # SKIPPING FLAKY TEST # ament_add_pytest_test(test_discard_behavior # "${CMAKE_CURRENT_SOURCE_DIR}/test/test_discard_behavior.py" # TIMEOUT 60 diff --git a/diagnostic_aggregator/test/add_analyzers.launch.py.in b/diagnostic_aggregator/test/test_add_analyzers.launch.py.in similarity index 100% rename from diagnostic_aggregator/test/add_analyzers.launch.py.in rename to diagnostic_aggregator/test/test_add_analyzers.launch.py.in diff --git a/diagnostic_aggregator/test/test_analyzers_output.launch.py.in b/diagnostic_aggregator/test/test_analyzers_output.launch.py.in index 5e6fcfd04..117be0a3d 100644 --- a/diagnostic_aggregator/test/test_analyzers_output.launch.py.in +++ b/diagnostic_aggregator/test/test_analyzers_output.launch.py.in @@ -16,7 +16,7 @@ import launch_testing_ros test_listener = ExecuteProcess( cmd=[ - "@PYTHON_EXECUTABLE@", + "/usr/bin/python3", "@TEST_LISTENER@" ], name='test_listener', diff --git a/diagnostic_aggregator/test/create_analyzers.launch.py.in b/diagnostic_aggregator/test/test_create_analyzers.launch.py.in similarity index 100% rename from diagnostic_aggregator/test/create_analyzers.launch.py.in rename to diagnostic_aggregator/test/test_create_analyzers.launch.py.in diff --git a/diagnostic_common_diagnostics/CMakeLists.txt b/diagnostic_common_diagnostics/CMakeLists.txt index 136e4bd8f..bb5d4ba9f 100644 --- a/diagnostic_common_diagnostics/CMakeLists.txt +++ b/diagnostic_common_diagnostics/CMakeLists.txt @@ -19,18 +19,19 @@ install(PROGRAMS if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) find_package(launch_testing_ament_cmake REQUIRED) + find_package(ament_cmake_pytest REQUIRED) ament_lint_auto_find_test_dependencies() - find_package(ament_cmake_pytest REQUIRED) ament_add_pytest_test( test_cpu_monitor test/systemtest/test_cpu_monitor.py TIMEOUT 10) - # SKIPPING FLAKY TEST - # add_launch_test( - # test/systemtest/test_ntp_monitor_launchtest.py - # TARGET ntp_monitor_launchtest - # TIMEOUT 20) + + add_launch_test( + test/systemtest/test_ntp_monitor_launchtest.py + TARGET ntp_monitor_launchtest + TIMEOUT 20) + add_launch_test( test/systemtest/test_hd_monitor_launchtest.py TARGET hd_monitor_launchtest diff --git a/diagnostic_common_diagnostics/test/systemtest/test_hd_monitor_launchtest.py b/diagnostic_common_diagnostics/test/systemtest/test_hd_monitor_launchtest.py index 792301985..0f34c4467 100644 --- a/diagnostic_common_diagnostics/test/systemtest/test_hd_monitor_launchtest.py +++ b/diagnostic_common_diagnostics/test/systemtest/test_hd_monitor_launchtest.py @@ -59,7 +59,7 @@ def generate_test_description(): executable='hd_monitor.py', name='hd_monitor', output='screen', - parameters=[{'free_percent_low': 10, 'free_percent_crit': 5}], + parameters=[{'free_percent_low': 1, 'free_percent_crit': 1}], ), launch_testing.actions.ReadyToTest(), ] @@ -88,6 +88,7 @@ def _get_min_level(self): def test_topic_published(self): """Test if the hd_monitor node is publishing diagnostics.""" + min_level = 100 with WaitForTopics([('/diagnostics', DiagnosticArray)], timeout=5): print('Topic found') @@ -99,7 +100,8 @@ def test_topic_published(self): while len(self.received_messages) < 10: rclpy.spin_once(test_node, timeout_sec=1) - if (min_level := self._get_min_level()) == 0: + min_level = min(min_level, self._get_min_level()) + if min_level == 0: break test_node.destroy_node() diff --git a/diagnostic_remote_logging/CMakeLists.txt b/diagnostic_remote_logging/CMakeLists.txt index 70a500486..5705e1c31 100644 --- a/diagnostic_remote_logging/CMakeLists.txt +++ b/diagnostic_remote_logging/CMakeLists.txt @@ -15,7 +15,7 @@ set(dependencies foreach(dep ${dependencies}) find_package(${dep} REQUIRED) -endforeach(dep) +endforeach() include_directories( src/