-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #589 from RI-SE/feature_integration-testing
Integration testing
- Loading branch information
Showing
33 changed files
with
707 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# ATOSBase | ||
|
||
## About the module | ||
`ATOSBase` is a node for ATOS and is responsible for suppling the object ID for the objects that are used in the test. | ||
`ATOSBase` is a node for ATOS and is responsible for supplying the object ID for the objects that are used in the test. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# IntegrationTesting | ||
|
||
## About the module | ||
`IntegrationTesting` is used for integration tests. The module launches an integration testing handler, which reads from `params.yaml` which integration tests we want to execute. A node for each integration | ||
test is then launched, and the node performs the specified integration tests. An integration tests can for instance be if an object reports all states correctly during a run, or if it follows a trajectory | ||
correctly. This module can be run both offline and through GitHub Actions. | ||
|
||
!!! note | ||
|
||
You can read more about integration testing in the section [Testing](../../Contributing/Testing/testing.md). | ||
|
||
## ROS parameters | ||
The integration tests are specified in `params.yaml`, and can be set to true of false depending on if we want to run them or not. The following ROS parameters can be set for `IntegrationTesting`: | ||
|
||
```yaml | ||
integration_testing_handler: | ||
ros__parameters: | ||
scenario_execution: true # set to true or false depending if you want to run this integration test | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import sys | ||
import os | ||
from ament_index_python.packages import get_package_prefix | ||
sys.path.insert(0, os.path.join( # Need to modify the sys.path since we launch from the ros2 installed path | ||
get_package_prefix('atos'), | ||
'share', 'atos', 'launch')) | ||
from launch_ros.actions import Node | ||
from launch import LaunchDescription | ||
import launch_utils.launch_base as launch_base | ||
|
||
|
||
def get_integration_test_nodes(): | ||
files = launch_base.get_files() | ||
return [ | ||
Node( | ||
package='atos', | ||
namespace='atos', | ||
executable='integration_testing_handler', | ||
parameters=[files["params"]] | ||
) | ||
] | ||
|
||
def generate_launch_description(): | ||
base_nodes = launch_base.get_base_nodes() | ||
|
||
integration_test_nodes = get_integration_test_nodes() | ||
|
||
for node in integration_test_nodes: | ||
base_nodes.append(node) | ||
|
||
return LaunchDescription(base_nodes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
cmake_minimum_required(VERSION 3.1) | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_C_STANDARD 11) | ||
set(CMAKE_C_STANDARD_REQUIRED ON) | ||
|
||
project(integration_testing_handler) | ||
|
||
find_package(rclcpp REQUIRED) | ||
find_package(std_msgs REQUIRED) | ||
find_package(sensor_msgs REQUIRED) | ||
find_package(atos_interfaces REQUIRED) | ||
|
||
# Define target names | ||
set(INTEGRATION_TESTING_TARGET ${PROJECT_NAME}) | ||
|
||
set(ATOS_COMMON_LIBRARY ATOSCommon) | ||
get_target_property(COMMON_HEADERS ${ATOS_COMMON_LIBRARY} INCLUDE_DIRECTORIES) | ||
|
||
include(GNUInstallDirs) | ||
|
||
# Create project main executable target | ||
add_executable(${INTEGRATION_TESTING_TARGET} | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/integrationtestinghandler.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/integrationtestingfactory.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/integrationtesting.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/scenarioexecution.cpp | ||
) | ||
# Link project executable to util libraries | ||
target_link_libraries(${INTEGRATION_TESTING_TARGET} | ||
${ATOS_COMMON_LIBRARY} | ||
) | ||
|
||
# ROS specific settings | ||
ament_target_dependencies(${INTEGRATION_TESTING_TARGET} | ||
rclcpp | ||
std_msgs | ||
sensor_msgs | ||
atos_interfaces | ||
) | ||
|
||
target_include_directories(${INTEGRATION_TESTING_TARGET} PUBLIC | ||
${CMAKE_CURRENT_SOURCE_DIR}/inc | ||
${COMMON_HEADERS} | ||
) | ||
|
||
# Installation rules | ||
install(CODE "MESSAGE(STATUS \"Installing target ${OSI_ADAPTER_TARGET}\")") | ||
install(TARGETS ${INTEGRATION_TESTING_TARGET} | ||
RUNTIME DESTINATION "${CMAKE_INSTALL_LIBDIR}/atos" | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
#pragma once | ||
|
||
#include "module.hpp" | ||
#include "roschannels/commandchannels.hpp" | ||
#include "atos_interfaces/srv/get_object_control_state.hpp" | ||
|
||
|
||
class IntegrationTesting : public Module { | ||
|
||
public: | ||
IntegrationTesting(const std::string& moduleName); | ||
~IntegrationTesting(); | ||
|
||
static inline std::string const testName = "scenario_execution"; | ||
virtual void runIntegrationTest() = 0; | ||
|
||
protected: | ||
const std::string atosNamespace = "/atos/"; | ||
const std::string initTopic = atosNamespace + ROSChannels::Init::topicName; | ||
const std::string connectTopic = atosNamespace + ROSChannels::Connect::topicName; | ||
const std::string armTopic = atosNamespace + ROSChannels::Arm::topicName; | ||
const std::string startTopic = atosNamespace + ROSChannels::Start::topicName; | ||
std::shared_ptr<rclcpp::Publisher<std_msgs::msg::Empty>> initPub; | ||
std::shared_ptr<rclcpp::Publisher<std_msgs::msg::Empty>> connectPub; | ||
std::shared_ptr<rclcpp::Publisher<std_msgs::msg::Empty>> armPub; | ||
std::shared_ptr<rclcpp::Publisher<std_msgs::msg::Empty>> startPub; | ||
std::shared_ptr<rclcpp::Client<atos_interfaces::srv::GetObjectControlState>> getObjectControlStateClient; | ||
std::vector<std::pair<int, int>> stateResult; | ||
|
||
virtual void printResult() = 0; | ||
int getObjectControlState(); | ||
void checkState(const std::string& command); | ||
}; |
Oops, something went wrong.