Skip to content

Adding aggregator tests again #467

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

Draft
wants to merge 7 commits into
base: ros2
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 41 additions & 41 deletions diagnostic_aggregator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,81 +84,81 @@ 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"
"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/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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import launch_testing_ros

test_listener = ExecuteProcess(
cmd=[
"@PYTHON_EXECUTABLE@",
"/usr/bin/python3",
"@TEST_LISTENER@"
],
name='test_listener',
Expand Down
13 changes: 7 additions & 6 deletions diagnostic_common_diagnostics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
]
Expand Down Expand Up @@ -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')

Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion diagnostic_remote_logging/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set(dependencies

foreach(dep ${dependencies})
find_package(${dep} REQUIRED)
endforeach(dep)
endforeach()

include_directories(
src/
Expand Down
Loading