Skip to content

Commit

Permalink
Adding zenoh transport
Browse files Browse the repository at this point in the history
  • Loading branch information
agosh01 committed Aug 2, 2024
1 parent baef58e commit 2f32798
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 6 deletions.
14 changes: 11 additions & 3 deletions test_agent/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ find_package(RapidJSON CONFIG REQUIRED)
find_package(up-transport-socket-cpp REQUIRED)
find_package(OpenSSL REQUIRED)
# TODO: Update when zenoh transport is ready
# find_package(up-client-zenoh-cpp REQUIRED)
find_package(up-transport-zenoh-cpp REQUIRED)
find_package(zenohcpp REQUIRED)

get_filename_component(ZENOH_CONF "./DEFAULT_CONFIG.json5" REALPATH)

# This is the root CMakeLists.txt file; We can set project wide settings here
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
Expand All @@ -43,20 +46,25 @@ target_include_directories(${PROJECT_NAME}
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
${up-transport-socket-cpp_INCLUDE_DIR}
# ${up-client-zenoh-cpp_INCLUDE_DIR}
${up-transport-zenoh-cpp_INCLUDE_DIR}
${zenohcpp_INCLUDE_DIR}
${up-cpp_INCLUDE_DIR}
${up-core-api_INCLUDE_DIR}
${protobuf_INCLUDE_DIR}
${spdlog_INCLUDE_DIR})

set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)

target_compile_definitions(${PROJECT_NAME} PRIVATE BUILD_REALPATH_ZENOH_CONF=\"${ZENOH_CONF}\")


target_link_libraries(${PROJECT_NAME}
PRIVATE
up-transport-socket-cpp::up-transport-socket-cpp
# up-client-zenoh-cpp::up-client-zenoh-cpp
up-transport-zenoh-cpp::up-transport-zenoh-cpp
up-core-api::up-core-api
up-cpp::up-cpp
zenohcpp::lib
protobuf::libprotobuf
pthread
rt
Expand Down
19 changes: 19 additions & 0 deletions test_agent/cpp/DEFAULT_CONFIG.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/// This file attempts to list and document available configuration elements.
/// For a more complete view of the configuration's structure, check out `zenoh/src/config.rs`'s `Config` structure.
/// Note that the values here are correctly typed, but may not be sensible, so copying this file to change only the parts that matter to you is not good practice.
{
/// The identifier (as unsigned 128bit integer in hexadecimal lowercase - leading zeros are not accepted)
/// that zenoh runtime will use.
/// If not set, a random unsigned 128bit integer will be used.
/// WARNING: this id must be unique in your zenoh network.
// id: "1234567890abcdef",

/// The node's mode (router, peer or client)
mode: "peer",

connect: {
endpoints: [
// "<proto>/<address>"
],
},
}
2 changes: 2 additions & 0 deletions test_agent/cpp/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ protobuf/[>=3.21.12]
up-core-api/1.6.0
up-cpp/1.0.1-rc1
up-transport-socket-cpp/1.0.0-dev
up-transport-zenoh-cpp/1.0.0-dev
zenohcpp/1.0.0-rc5
rapidjson/cci.20230929
spdlog/[>=1.13.0]
fmt/10.2.1
Expand Down
1 change: 1 addition & 0 deletions test_agent/cpp/include/APIWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define _API_WRAPPER_H_

#include <SocketUTransport.h>
#include <up-transport-zenoh-cpp/ZenohUTransport.h>

#include "ProtoConverter.h"
#include "utils.h"
Expand Down
2 changes: 2 additions & 0 deletions test_agent/cpp/include/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ constexpr static const char* PAYLOAD = "payload";
constexpr static const char* ATTRIBUTES = "attributes";
constexpr static const char* MESSAGE = "message";
constexpr static const char* DETAILS = "details";
constexpr std::string_view ZENOH_CONFIG_FILE = BUILD_REALPATH_ZENOH_CONF;

}; // namespace Constants

#endif // _CONSTANTS_H_
4 changes: 4 additions & 0 deletions test_agent/cpp/src/APIWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ std::shared_ptr<uprotocol::transport::UTransport> APIWrapper::createTransport(
// If the transport type is "socket", create a new SocketUTransport.
if (transportType_ == "socket") {
return std::make_shared<SocketUTransport>(uri);
} else if (transportType_ == "zenoh")
{
return std::make_shared<uprotocol::transport::ZenohUTransport>(uri,
Constants::ZENOH_CONFIG_FILE);
} else {
// If the transport type is neither "socket" nor "zenoh", log an error
// and return null.
Expand Down
6 changes: 3 additions & 3 deletions test_manager/reports/summary/summary.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[
{"keyword": "Feature", "name": "Testing Publish and Subscribe Functionality", "tags": [], "location": "features/tests/L2_APIs/notification_sink_and_source.feature:25", "status": "passed", "elements": [{"type": "scenario", "keyword": "Scenario Outline", "name": "To test the rpc server and client apis -- @1.1 ", "tags": [], "location": "features/tests/L2_APIs/notification_sink_and_source.feature:52", "steps": [{"keyword": "Given", "step_type": "given", "name": "\"uE1\" creates data for \"notificationsink\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:28", "match": {"location": "features/steps/tck_step_implementations.py:131", "arguments": [{"value": "uE1", "name": "sdk_name"}, {"value": "notificationsink", "name": "command"}]}, "result": {"status": "passed", "duration": 1.1332948207855225}}, {"keyword": "And", "step_type": "given", "name": "sets \"authority_name\" to \"me_authority\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:29", "match": {"location": "features/steps/tck_step_implementations.py:327", "arguments": [{"value": "authority_name", "name": "key"}, {"value": "me_authority", "name": "value"}]}, "result": {"status": "passed", "duration": 0.0003452301025390625}}, {"keyword": "And", "step_type": "given", "name": "sets \"ue_id\" to \"65538\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:30", "match": {"location": "features/steps/tck_step_implementations.py:327", "arguments": [{"value": "ue_id", "name": "key"}, {"value": "65538", "name": "value"}]}, "result": {"status": "passed", "duration": 0.0006031990051269531}}, {"keyword": "And", "step_type": "given", "name": "sets \"ue_version_major\" to \"1\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:31", "match": {"location": "features/steps/tck_step_implementations.py:327", "arguments": [{"value": "ue_version_major", "name": "key"}, {"value": "1", "name": "value"}]}, "result": {"status": "passed", "duration": 0.00022983551025390625}}, {"keyword": "And", "step_type": "given", "name": "sets \"resource_id\" to \"32770\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:32", "match": {"location": "features/steps/tck_step_implementations.py:327", "arguments": [{"value": "resource_id", "name": "key"}, {"value": "32770", "name": "value"}]}, "result": {"status": "passed", "duration": 0.00032448768615722656}}, {"keyword": "And", "step_type": "given", "name": "sends \"notificationsink\" request", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:34", "match": {"location": "features/steps/tck_step_implementations.py:354", "arguments": [{"value": "notificationsink", "name": "command"}]}, "result": {"status": "passed", "duration": 0.03483271598815918}}, {"keyword": "Then", "step_type": "then", "name": "the status received with \"code\" is \"OK\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:35", "match": {"location": "features/steps/tck_step_implementations.py:365", "arguments": [{"value": "code", "name": "field_name"}, {"value": "OK", "name": "expected_value"}]}, "result": {"status": "passed", "duration": 0.0002498626708984375}}, {"keyword": "When", "step_type": "when", "name": "\"uE2\" creates data for \"notificationsource\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:37", "match": {"location": "features/steps/tck_step_implementations.py:131", "arguments": [{"value": "uE2", "name": "sdk_name"}, {"value": "notificationsource", "name": "command"}]}, "result": {"status": "passed", "duration": 1.0709242820739746}}, {"keyword": "And", "step_type": "when", "name": "sets \"attributes.source.authority_name\" to \"me_authority\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:38", "match": {"location": "features/steps/tck_step_implementations.py:327", "arguments": [{"value": "attributes.source.authority_name", "name": "key"}, {"value": "me_authority", "name": "value"}]}, "result": {"status": "passed", "duration": 0.0001609325408935547}}, {"keyword": "And", "step_type": "when", "name": "sets \"attributes.source.ue_id\" to \"65538\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:39", "match": {"location": "features/steps/tck_step_implementations.py:327", "arguments": [{"value": "attributes.source.ue_id", "name": "key"}, {"value": "65538", "name": "value"}]}, "result": {"status": "passed", "duration": 0.0001678466796875}}, {"keyword": "And", "step_type": "when", "name": "sets \"attributes.source.ue_version_major\" to \"1\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:40", "match": {"location": "features/steps/tck_step_implementations.py:327", "arguments": [{"value": "attributes.source.ue_version_major", "name": "key"}, {"value": "1", "name": "value"}]}, "result": {"status": "passed", "duration": 0.0003590583801269531}}, {"keyword": "And", "step_type": "when", "name": "sets \"attributes.source.resource_id\" to \"32770\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:41", "match": {"location": "features/steps/tck_step_implementations.py:327", "arguments": [{"value": "attributes.source.resource_id", "name": "key"}, {"value": "32770", "name": "value"}]}, "result": {"status": "passed", "duration": 0.00016736984252929688}}, {"keyword": "And", "step_type": "when", "name": "sets \"attributes.sink\" to entity URI of \"uE1\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:42", "match": {"location": "features/steps/tck_step_implementations.py:346", "arguments": [{"value": "attributes.sink", "name": "key"}, {"value": "uE1", "name": "ue"}]}, "result": {"status": "passed", "duration": 0.00013971328735351562}}, {"keyword": "And", "step_type": "when", "name": "sets \"attributes.payload_format\" to \"UPAYLOAD_FORMAT_PROTOBUF_WRAPPED_IN_ANY\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:43", "match": {"location": "features/steps/tck_step_implementations.py:327", "arguments": [{"value": "attributes.payload_format", "name": "key"}, {"value": "UPAYLOAD_FORMAT_PROTOBUF_WRAPPED_IN_ANY", "name": "value"}]}, "result": {"status": "passed", "duration": 0.00013303756713867188}}, {"keyword": "And", "step_type": "when", "name": "sets \"payload\" to b\".type.googleapis.com/google.protobuf.Int32Value\\x12\\x02\\x08\\x03\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:44", "match": {"location": "features/steps/tck_step_implementations.py:339", "arguments": [{"value": "payload", "name": "key"}, {"value": ".type.googleapis.com/google.protobuf.Int32Value\\x12\\x02\\x08\\x03", "name": "value"}]}, "result": {"status": "passed", "duration": 0.00015974044799804688}}, {"keyword": "And", "step_type": "when", "name": "sends \"notificationsource\" request", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:45", "match": {"location": "features/steps/tck_step_implementations.py:354", "arguments": [{"value": "notificationsource", "name": "command"}]}, "result": {"status": "passed", "duration": 0.03207826614379883}}, {"keyword": "Then", "step_type": "then", "name": "the status received with \"code\" is \"OK\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:47", "match": {"location": "features/steps/tck_step_implementations.py:365", "arguments": [{"value": "code", "name": "field_name"}, {"value": "OK", "name": "expected_value"}]}, "result": {"status": "passed", "duration": 0.00019741058349609375}}, {"keyword": "And", "step_type": "then", "name": "\"uE1\" sends onreceive message with field \"payload\" as b\"type.googleapis.com/google.protobuf.Int32Value\\x12\\x02\\x08\\x03\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:48", "match": {"location": "features/steps/tck_step_implementations.py:379", "arguments": [{"value": "uE1", "name": "sender_sdk_name"}, {"value": "payload", "name": "field_name"}, {"value": "type.googleapis.com/google.protobuf.Int32Value\\x12\\x02\\x08\\x03", "name": "expected_value"}]}, "result": {"status": "passed", "duration": 0.009927749633789062}}], "status": "passed"}]}
]
[
{"keyword": "Feature", "name": "Testing Publish and Subscribe Functionality", "tags": [], "location": "features/tests/L2_APIs/notification_sink_and_source.feature:25", "status": "passed", "elements": [{"type": "scenario", "keyword": "Scenario Outline", "name": "To test the rpc server and client apis -- @1.1 ", "tags": [], "location": "features/tests/L2_APIs/notification_sink_and_source.feature:52", "steps": [{"keyword": "Given", "step_type": "given", "name": "\"uE1\" creates data for \"notificationsink\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:28", "match": {"location": "features/steps/tck_step_implementations.py:131", "arguments": [{"value": "uE1", "name": "sdk_name"}, {"value": "notificationsink", "name": "command"}]}, "result": {"status": "passed", "duration": 1.1332948207855225}}, {"keyword": "And", "step_type": "given", "name": "sets \"authority_name\" to \"me_authority\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:29", "match": {"location": "features/steps/tck_step_implementations.py:327", "arguments": [{"value": "authority_name", "name": "key"}, {"value": "me_authority", "name": "value"}]}, "result": {"status": "passed", "duration": 0.0003452301025390625}}, {"keyword": "And", "step_type": "given", "name": "sets \"ue_id\" to \"65538\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:30", "match": {"location": "features/steps/tck_step_implementations.py:327", "arguments": [{"value": "ue_id", "name": "key"}, {"value": "65538", "name": "value"}]}, "result": {"status": "passed", "duration": 0.0006031990051269531}}, {"keyword": "And", "step_type": "given", "name": "sets \"ue_version_major\" to \"1\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:31", "match": {"location": "features/steps/tck_step_implementations.py:327", "arguments": [{"value": "ue_version_major", "name": "key"}, {"value": "1", "name": "value"}]}, "result": {"status": "passed", "duration": 0.00022983551025390625}}, {"keyword": "And", "step_type": "given", "name": "sets \"resource_id\" to \"32770\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:32", "match": {"location": "features/steps/tck_step_implementations.py:327", "arguments": [{"value": "resource_id", "name": "key"}, {"value": "32770", "name": "value"}]}, "result": {"status": "passed", "duration": 0.00032448768615722656}}, {"keyword": "And", "step_type": "given", "name": "sends \"notificationsink\" request", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:34", "match": {"location": "features/steps/tck_step_implementations.py:354", "arguments": [{"value": "notificationsink", "name": "command"}]}, "result": {"status": "passed", "duration": 0.03483271598815918}}, {"keyword": "Then", "step_type": "then", "name": "the status received with \"code\" is \"OK\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:35", "match": {"location": "features/steps/tck_step_implementations.py:365", "arguments": [{"value": "code", "name": "field_name"}, {"value": "OK", "name": "expected_value"}]}, "result": {"status": "passed", "duration": 0.0002498626708984375}}, {"keyword": "When", "step_type": "when", "name": "\"uE2\" creates data for \"notificationsource\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:37", "match": {"location": "features/steps/tck_step_implementations.py:131", "arguments": [{"value": "uE2", "name": "sdk_name"}, {"value": "notificationsource", "name": "command"}]}, "result": {"status": "passed", "duration": 1.0709242820739746}}, {"keyword": "And", "step_type": "when", "name": "sets \"attributes.source.authority_name\" to \"me_authority\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:38", "match": {"location": "features/steps/tck_step_implementations.py:327", "arguments": [{"value": "attributes.source.authority_name", "name": "key"}, {"value": "me_authority", "name": "value"}]}, "result": {"status": "passed", "duration": 0.0001609325408935547}}, {"keyword": "And", "step_type": "when", "name": "sets \"attributes.source.ue_id\" to \"65538\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:39", "match": {"location": "features/steps/tck_step_implementations.py:327", "arguments": [{"value": "attributes.source.ue_id", "name": "key"}, {"value": "65538", "name": "value"}]}, "result": {"status": "passed", "duration": 0.0001678466796875}}, {"keyword": "And", "step_type": "when", "name": "sets \"attributes.source.ue_version_major\" to \"1\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:40", "match": {"location": "features/steps/tck_step_implementations.py:327", "arguments": [{"value": "attributes.source.ue_version_major", "name": "key"}, {"value": "1", "name": "value"}]}, "result": {"status": "passed", "duration": 0.0003590583801269531}}, {"keyword": "And", "step_type": "when", "name": "sets \"attributes.source.resource_id\" to \"32770\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:41", "match": {"location": "features/steps/tck_step_implementations.py:327", "arguments": [{"value": "attributes.source.resource_id", "name": "key"}, {"value": "32770", "name": "value"}]}, "result": {"status": "passed", "duration": 0.00016736984252929688}}, {"keyword": "And", "step_type": "when", "name": "sets \"attributes.sink\" to entity URI of \"uE1\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:42", "match": {"location": "features/steps/tck_step_implementations.py:346", "arguments": [{"value": "attributes.sink", "name": "key"}, {"value": "uE1", "name": "ue"}]}, "result": {"status": "passed", "duration": 0.00013971328735351562}}, {"keyword": "And", "step_type": "when", "name": "sets \"attributes.payload_format\" to \"UPAYLOAD_FORMAT_PROTOBUF_WRAPPED_IN_ANY\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:43", "match": {"location": "features/steps/tck_step_implementations.py:327", "arguments": [{"value": "attributes.payload_format", "name": "key"}, {"value": "UPAYLOAD_FORMAT_PROTOBUF_WRAPPED_IN_ANY", "name": "value"}]}, "result": {"status": "passed", "duration": 0.00013303756713867188}}, {"keyword": "And", "step_type": "when", "name": "sets \"payload\" to b\".type.googleapis.com/google.protobuf.Int32Value\\x12\\x02\\x08\\x03\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:44", "match": {"location": "features/steps/tck_step_implementations.py:339", "arguments": [{"value": "payload", "name": "key"}, {"value": ".type.googleapis.com/google.protobuf.Int32Value\\x12\\x02\\x08\\x03", "name": "value"}]}, "result": {"status": "passed", "duration": 0.00015974044799804688}}, {"keyword": "And", "step_type": "when", "name": "sends \"notificationsource\" request", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:45", "match": {"location": "features/steps/tck_step_implementations.py:354", "arguments": [{"value": "notificationsource", "name": "command"}]}, "result": {"status": "passed", "duration": 0.03207826614379883}}, {"keyword": "Then", "step_type": "then", "name": "the status received with \"code\" is \"OK\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:47", "match": {"location": "features/steps/tck_step_implementations.py:365", "arguments": [{"value": "code", "name": "field_name"}, {"value": "OK", "name": "expected_value"}]}, "result": {"status": "passed", "duration": 0.00019741058349609375}}, {"keyword": "And", "step_type": "then", "name": "\"uE1\" sends onreceive message with field \"payload\" as b\"type.googleapis.com/google.protobuf.Int32Value\\x12\\x02\\x08\\x03\"", "location": "features/tests/L2_APIs/notification_sink_and_source.feature:48", "match": {"location": "features/steps/tck_step_implementations.py:379", "arguments": [{"value": "uE1", "name": "sender_sdk_name"}, {"value": "payload", "name": "field_name"}, {"value": "type.googleapis.com/google.protobuf.Int32Value\\x12\\x02\\x08\\x03", "name": "expected_value"}]}, "result": {"status": "passed", "duration": 0.009927749633789062}}], "status": "passed"}]}
]

0 comments on commit 2f32798

Please sign in to comment.