Skip to content

Commit 82b6680

Browse files
dkroenkeelBoberido
authored andcommitted
iox-#27 Integrationtest Request Response Example
Signed-off-by: Dietrich Krönke <[email protected]>
1 parent 05759e4 commit 82b6680

File tree

5 files changed

+298
-1
lines changed

5 files changed

+298
-1
lines changed

iceoryx_integrationtest/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ if(BUILD_TESTING)
3434
add_ros_test(iceoryx_integrationtest/test_iceoptions_example.py)
3535
add_ros_test(iceoryx_integrationtest/test_complexdata_example.py)
3636
add_ros_test(iceoryx_integrationtest/test_user_header_example.py)
37+
add_ros_test(iceoryx_integrationtest/test_request_response_basic.py)
38+
add_ros_test(iceoryx_integrationtest/test_request_response_event.py)
39+
add_ros_test(iceoryx_integrationtest/test_request_response_untyped.py)
3740

3841
endif()
3942

iceoryx_integrationtest/iceoryx_integrationtest/test_complexdata_example.py

100644100755
+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def test_publisher_subscriber_data_exchange(self, proc_output):
8686

8787
def test_publisher_subscriber_untyped_data_exchange(self, proc_output):
8888
proc_output.assertWaitFor(
89-
'iox-cpp-subscriber-complexdata got values:\nstringForwardList: hello, world\nintegerList: 15, 22, 11\noptionalList: optional is empty, 42\nfloatStack: 44, 33, 22, 11, 0\nsomeString: hello iceoryx\ndoubleVector: 11, 12, 13, 14, 15\nvariantVector: seven, 8, nine',
89+
'iox-cpp-subscriber-complexdata got values:\nstringForwardList: hello, world\nintegerList: 15, 22, 11\noptionalList: optional is empty, 42\nfloatStack: 44, 33, 22, 11, 0\nsomeString: hello iceoryx\ndoubleVector: 11, 12, 13, 14, 15\nvariantVector: seven, 8, nine',
9090
timeout=45, stream='stdout')
9191

9292
# These tests run after shutdown and examine the stdout log
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Copyright (c) 2022 by Apex.AI Inc. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
import os
18+
19+
import unittest
20+
21+
import launch
22+
from launch_ros.substitutions import ExecutableInPackage
23+
import launch_testing
24+
import launch_testing.actions
25+
from launch_testing.asserts import assertSequentialStdout
26+
27+
import pytest
28+
29+
# @brief Test goal: "Integrationtest for the request response basic example of iceoryx"
30+
# @pre setup ROS2 launch executables for RouDi (debug mode) and the example processes
31+
# @post check if all applications return exitcode 0 (success) after test run
32+
@pytest.mark.launch_test
33+
def generate_test_description():
34+
35+
proc_env = os.environ.copy()
36+
colcon_prefix_path = os.environ.get('COLCON_PREFIX_PATH', '')
37+
executable_list = ['iox-cpp-request-response-basic-client', 'iox-cpp-request-response-basic-server']
38+
process_list = []
39+
40+
for exec in executable_list:
41+
tmp_exec = os.path.join(
42+
colcon_prefix_path,
43+
'example_request_response_basic/bin/',
44+
exec)
45+
tmp_process = launch.actions.ExecuteProcess(
46+
cmd=[tmp_exec],
47+
env=proc_env, output='screen')
48+
process_list.append(tmp_process)
49+
50+
print("Process list:", process_list)
51+
52+
roudi_executable = os.path.join(
53+
colcon_prefix_path,
54+
'iceoryx_posh/bin/',
55+
'iox-roudi'
56+
)
57+
roudi_process = launch.actions.ExecuteProcess(
58+
cmd=[roudi_executable, '-l', 'debug'],
59+
env=proc_env, output='screen',
60+
sigterm_timeout='20')
61+
62+
return launch.LaunchDescription([
63+
process_list[0],
64+
process_list[1],
65+
roudi_process,
66+
launch_testing.actions.ReadyToTest()
67+
]), {'iox-cpp-request-response-basic-client': process_list[0], 'iox-cpp-request-response-basic-server': process_list[1],
68+
'roudi_process': roudi_process}
69+
70+
# These tests will run concurrently with the dut process. After this test is done,
71+
# the launch system will shut down RouDi
72+
73+
74+
class TestRequestResponseBasicExample(unittest.TestCase):
75+
def test_roudi_ready(self, proc_output):
76+
proc_output.assertWaitFor(
77+
'RouDi is ready for clients', timeout=45, stream='stdout')
78+
79+
def test_basic_server_client_data_exchange(self, proc_output):
80+
proc_output.assertWaitFor(
81+
'iox-cpp-request-response-client-basic Send Request: 55 + 89', timeout=45, stream='stdout')
82+
proc_output.assertWaitFor(
83+
'iox-cpp-request-response-server-basic Got Request: 55 + 89', timeout=45, stream='stdout')
84+
85+
proc_output.assertWaitFor(
86+
'iox-cpp-request-response-server-basic Send Response: 144', timeout=45, stream='stdout')
87+
proc_output.assertWaitFor(
88+
'iox-cpp-request-response-client-basic Got Response : 144', timeout=45, stream='stdout')
89+
90+
91+
# These tests run after shutdown and examine the stdout log
92+
93+
94+
@launch_testing.post_shutdown_test()
95+
class TestRequestResponseBasicExampleExitCodes(unittest.TestCase):
96+
def test_exit_code(self, proc_info):
97+
launch_testing.asserts.assertExitCodes(proc_info)
98+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Copyright (c) 2022 by Apex.AI Inc. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
import os
18+
19+
import unittest
20+
21+
import launch
22+
from launch_ros.substitutions import ExecutableInPackage
23+
import launch_testing
24+
import launch_testing.actions
25+
from launch_testing.asserts import assertSequentialStdout
26+
27+
import pytest
28+
29+
# @brief Test goal: "Integrationtest for the request response basic example of iceoryx"
30+
# @pre setup ROS2 launch executables for RouDi (debug mode) and the example processes
31+
# @post check if all applications return exitcode 0 (success) after test run
32+
@pytest.mark.launch_test
33+
def generate_test_description():
34+
35+
proc_env = os.environ.copy()
36+
colcon_prefix_path = os.environ.get('COLCON_PREFIX_PATH', '')
37+
executable_list = ['iox-cpp-request-response-event-client', 'iox-cpp-request-response-event-server']
38+
process_list = []
39+
40+
for exec in executable_list:
41+
tmp_exec = os.path.join(
42+
colcon_prefix_path,
43+
'example_request_response_basic/bin/',
44+
exec)
45+
tmp_process = launch.actions.ExecuteProcess(
46+
cmd=[tmp_exec],
47+
env=proc_env, output='screen')
48+
process_list.append(tmp_process)
49+
50+
print("Process list:", process_list)
51+
52+
roudi_executable = os.path.join(
53+
colcon_prefix_path,
54+
'iceoryx_posh/bin/',
55+
'iox-roudi'
56+
)
57+
roudi_process = launch.actions.ExecuteProcess(
58+
cmd=[roudi_executable, '-l', 'debug'],
59+
env=proc_env, output='screen',
60+
sigterm_timeout='20')
61+
62+
return launch.LaunchDescription([
63+
process_list[0],
64+
process_list[1],
65+
roudi_process,
66+
launch_testing.actions.ReadyToTest()
67+
]), {'iox-cpp-request-response-event-client': process_list[0], 'iox-cpp-request-response-event-server': process_list[1],
68+
'roudi_process': roudi_process}
69+
70+
# These tests will run concurrently with the dut process. After this test is done,
71+
# the launch system will shut down RouDi
72+
73+
74+
class TestRequestResponseEventExample(unittest.TestCase):
75+
def test_roudi_ready(self, proc_output):
76+
proc_output.assertWaitFor(
77+
'RouDi is ready for clients', timeout=45, stream='stdout')
78+
79+
def test_event_server_client_data_exchange(self, proc_output):
80+
proc_output.assertWaitFor(
81+
'iox-cpp-request-response-client-event Send Request: 55 + 89', timeout=45, stream='stdout')
82+
proc_output.assertWaitFor(
83+
'iox-cpp-request-response-server-event Got Request: 55 + 89', timeout=45, stream='stdout')
84+
85+
proc_output.assertWaitFor(
86+
'iox-cpp-request-response-server-event Send Response: 144', timeout=45, stream='stdout')
87+
proc_output.assertWaitFor(
88+
'iox-cpp-request-response-client-event Got Response : 144', timeout=45, stream='stdout')
89+
90+
91+
# These tests run after shutdown and examine the stdout log
92+
93+
94+
@launch_testing.post_shutdown_test()
95+
class TestRequestResponseEventExampleExitCodes(unittest.TestCase):
96+
def test_exit_code(self, proc_info):
97+
launch_testing.asserts.assertExitCodes(proc_info)
98+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Copyright (c) 2022 by Apex.AI Inc. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
import os
18+
19+
import unittest
20+
21+
import launch
22+
from launch_ros.substitutions import ExecutableInPackage
23+
import launch_testing
24+
import launch_testing.actions
25+
from launch_testing.asserts import assertSequentialStdout
26+
27+
import pytest
28+
29+
# @brief Test goal: "Integrationtest for the request response basic example of iceoryx"
30+
# @pre setup ROS2 launch executables for RouDi (debug mode) and the example processes
31+
# @post check if all applications return exitcode 0 (success) after test run
32+
@pytest.mark.launch_test
33+
def generate_test_description():
34+
35+
proc_env = os.environ.copy()
36+
colcon_prefix_path = os.environ.get('COLCON_PREFIX_PATH', '')
37+
executable_list = ['iox-cpp-request-response-untyped-client', 'iox-cpp-request-response-untyped-server']
38+
process_list = []
39+
40+
for exec in executable_list:
41+
tmp_exec = os.path.join(
42+
colcon_prefix_path,
43+
'example_request_response_basic/bin/',
44+
exec)
45+
tmp_process = launch.actions.ExecuteProcess(
46+
cmd=[tmp_exec],
47+
env=proc_env, output='screen')
48+
process_list.append(tmp_process)
49+
50+
print("Process list:", process_list)
51+
52+
roudi_executable = os.path.join(
53+
colcon_prefix_path,
54+
'iceoryx_posh/bin/',
55+
'iox-roudi'
56+
)
57+
roudi_process = launch.actions.ExecuteProcess(
58+
cmd=[roudi_executable, '-l', 'debug'],
59+
env=proc_env, output='screen',
60+
sigterm_timeout='20')
61+
62+
return launch.LaunchDescription([
63+
process_list[0],
64+
process_list[1],
65+
roudi_process,
66+
launch_testing.actions.ReadyToTest()
67+
]), {'iox-cpp-request-response-untyped-client': process_list[0], 'iox-cpp-request-response-untyped-server': process_list[1],
68+
'roudi_process': roudi_process}
69+
70+
# These tests will run concurrently with the dut process. After this test is done,
71+
# the launch system will shut down RouDi
72+
73+
74+
class TestRequestResponseUntypedExample(unittest.TestCase):
75+
def test_roudi_ready(self, proc_output):
76+
proc_output.assertWaitFor(
77+
'RouDi is ready for clients', timeout=45, stream='stdout')
78+
79+
def test_untyped_server_client_data_exchange(self, proc_output):
80+
proc_output.assertWaitFor(
81+
'iox-cpp-request-response-client-untyped Send Request: 55 + 89', timeout=45, stream='stdout')
82+
proc_output.assertWaitFor(
83+
'iox-cpp-request-response-server-untyped Got Request: 55 + 89', timeout=45, stream='stdout')
84+
85+
proc_output.assertWaitFor(
86+
'iox-cpp-request-response-server-untyped Send Response: 144', timeout=45, stream='stdout')
87+
proc_output.assertWaitFor(
88+
'iox-cpp-request-response-client-untyped Got Response : 144', timeout=45, stream='stdout')
89+
90+
91+
# These tests run after shutdown and examine the stdout log
92+
93+
94+
@launch_testing.post_shutdown_test()
95+
class TestRequestResponseUntypedExampleExitCodes(unittest.TestCase):
96+
def test_exit_code(self, proc_info):
97+
launch_testing.asserts.assertExitCodes(proc_info)
98+

0 commit comments

Comments
 (0)