Skip to content
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

test(static_centerline_generator): add test for launch.xml #9425

Closed
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
4 changes: 4 additions & 0 deletions planning/autoware_static_centerline_generator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ if(BUILD_TESTING)
test/test_static_centerline_generator.test.py
TIMEOUT "30"
)
add_launch_test(
test/test_static_centerline_generator_launch.test.py
TIMEOUT "30"
)
install(DIRECTORY
test/data/
DESTINATION share/${PROJECT_NAME}/test/data/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<launch>
<!-- mandatory arguments for planning-->
<arg name="vehicle_model"/>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: The bus should not be used here.

<arg name="vehicle_model" default="bus"/>

<!-- flag -->
<arg name="mode" default="AUTO" description="select from AUTO, GUI, and VMB"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,20 @@

@pytest.mark.launch_test
def generate_test_description():
lanelet2_map_path = os.path.join(
get_package_share_directory("autoware_static_centerline_generator"),
"test/data/lanelet2_map.osm",
)

static_centerline_generator_node = Node(
package="autoware_static_centerline_generator",
executable="main",
output="screen",
parameters=[
{"lanelet2_map_path": lanelet2_map_path},
{"mode": "AUTO"},
{"rviz": False},
{"centerline_source": "optimization_trajectory_base"},
{"lanelet2_input_file_path": lanelet2_map_path},
{
"lanelet2_input_file_path": os.path.join(
get_package_share_directory("autoware_static_centerline_generator"),
"test/data/lanelet2_map.osm",
)
},
{"lanelet2_output_file_path": "/tmp/lanelet2_map.osm"},
{"start_lanelet_id": 215},
{"end_lanelet_id": 216},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env python3

# Copyright 2024 TIER IV, Inc.
#
# 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.

import os
import unittest

from ament_index_python import get_package_share_directory
import launch
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import AnyLaunchDescriptionSource
import launch_testing
import pytest


@pytest.mark.launch_test
def generate_test_description():
test_static_centerline_generator_launch_file = os.path.join(
get_package_share_directory("autoware_static_centerline_generator"),
"launch",
"static_centerline_generator.launch.xml",
)

static_centerline_generator = IncludeLaunchDescription(
AnyLaunchDescriptionSource(test_static_centerline_generator_launch_file),
)

return LaunchDescription(
[
DeclareLaunchArgument(
"lanelet2_input_file_path",
default_value=os.path.join(
get_package_share_directory("autoware_static_centerline_generator"),
"test/data/lanelet2_map.osm",
),
),
DeclareLaunchArgument(
"lanelet2_output_file_path", default_value="/tmp/lanelet2_map.osm"
),
DeclareLaunchArgument("rviz", default_value="false"),
DeclareLaunchArgument("start_lanelet_id", default_value="215"),
DeclareLaunchArgument("end_lanelet_id", default_value="216"),
DeclareLaunchArgument(
"centerline_source", default_value="optimization_trajectory_base"
),
static_centerline_generator,
# Start test after 1s - gives time for the autoware_static_centerline_generator to finish initialization
launch.actions.TimerAction(period=1.0, actions=[launch_testing.actions.ReadyToTest()]),
]
)


@launch_testing.post_shutdown_test()
class TestProcessOutput(unittest.TestCase):
def test_exit_code(self, proc_info):
# Check that process exits with code 0: no error
launch_testing.asserts.assertExitCodes(proc_info)
Loading