Skip to content

Commit

Permalink
Adjust option order of test_package to be consistent with that of Cel…
Browse files Browse the repository at this point in the history
…ix, add test_package for RSA.
  • Loading branch information
PengZheng committed Mar 21, 2022
1 parent bd1fdee commit 36bc83f
Show file tree
Hide file tree
Showing 5 changed files with 258 additions and 74 deletions.
2 changes: 1 addition & 1 deletion bundles/remote_services/rsa_common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ set_target_properties(rsa_common PROPERTIES OUTPUT_NAME "celix_rsa_common")
target_include_directories(rsa_common PRIVATE src)
target_link_libraries(rsa_common PUBLIC Celix::framework Celix::deprecated_rsa_spi Celix::log_helper)

#install(TARGETS rsa_common EXPORT celix COMPONENT rsa DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS rsa_common EXPORT celix COMPONENT rsa DESTINATION ${CMAKE_INSTALL_LIBDIR})

#Setup target aliases to match external usage
add_library(Celix::rsa_common ALIAS rsa_common)
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def _configure_cmake(self):
self._cmake.definitions[opt.upper()] = self.options.get_safe(opt, False)
self._cmake.definitions["CMAKE_PROJECT_Celix_INCLUDE"] = os.path.join(self.build_folder, "conan_paths.cmake")
# the following is workaround for https://github.com/conan-io/conan/issues/7192
self._cmake.definitions["CMAKE_EXE_LINKER_FLAGS"] = "-Wl,--unresolved-symbols=ignore-in-shared-libs"
# self._cmake.definitions["CMAKE_EXE_LINKER_FLAGS"] = "-Wl,--unresolved-symbols=ignore-in-shared-libs"
self.output.info(self._cmake.definitions)
v = tools.Version(self.version)
self._cmake.configure(defs={'CELIX_MAJOR': v.major, 'CELIX_MINOR': v.minor, 'CELIX_MICRO': v.patch})
Expand Down
165 changes: 111 additions & 54 deletions test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,60 +68,6 @@ if (TEST_SYSLOG_WRITER)
celix_container_bundles(use_syslog_writer LEVEL 2 hello)
endif ()

option(TEST_SHELL "Test shell" OFF)
if (TEST_SHELL)
add_executable(use_shell test_shell.c )
target_link_libraries(use_shell PRIVATE Celix::framework Celix::shell_api)
celix_get_bundle_file(Celix::shell SHELL_BUNDLE)
target_compile_definitions(use_shell PRIVATE SHELL_BUNDLE_LOCATION="${SHELL_BUNDLE}")
option(TEST_CXX_SHELL "Test CXX shell" OFF)
if (TEST_CXX_SHELL)
add_executable(use_cxx_shell test_cxx_shell.cpp)
target_link_libraries(use_cxx_shell PRIVATE Celix::framework Celix::shell_api)
celix_get_bundle_file(Celix::ShellCxx CXX_SHELL_BUNDLE)
target_compile_definitions(use_cxx_shell PRIVATE CXX_SHELL_BUNDLE_LOCATION="${CXX_SHELL_BUNDLE}")
endif ()
endif ()

option(TEST_REMOTE_SHELL "Test remote shell" OFF)
if(TEST_REMOTE_SHELL)
add_celix_container("use_remote_shell" BUNDLES Celix::shell Celix::remote_shell hello)
endif ()

option(TEST_SHELL_TUI "Test shell TUI" OFF)
if(TEST_SHELL_TUI)
add_celix_container("use_shell_tui" BUNDLES Celix::shell Celix::shell_tui hello)
endif ()

option(TEST_SHELL_WUI "Test shell WUI" OFF)
if(TEST_SHELL_WUI)
add_celix_container("use_shell_wui" BUNDLES Celix::shell Celix::shell_wui hello)
endif ()

option(TEST_ETCD_LIB "Test ETCD lib" OFF)
if (TEST_ETCD_LIB)
add_executable(use_etcd_lib test_etcd_lib.c)
target_link_libraries(use_etcd_lib PRIVATE Celix::etcdlib)
endif ()

option(TEST_LAUNCHER "Test launcher" OFF)
if (TEST_LAUNCHER)
get_target_property(LAUNCHER_LOCATION Celix::launcher LOCATION)
add_celix_container("use_launcher" LAUNCHER ${LAUNCHER_LOCATION} USE_CONFIG BUNDLES hello)
endif ()

option(TEST_PROMISES "Test promises" OFF)
if (TEST_PROMISES)
add_executable(use_promises test_promises.cpp)
target_link_libraries(use_promises PRIVATE Celix::Promises)
endif ()

option(TEST_PUSHSTREAMS "Test pushstreams" OFF)
if (TEST_PUSHSTREAMS)
add_executable(use_pushstreams test_pushstreams.cpp)
target_link_libraries(use_pushstreams PRIVATE Celix::PushStreams)
endif ()

option(TEST_PUBSUB "Test PubSub" OFF)
if (TEST_PUBSUB)
add_celix_bundle(my_pubsub_admin
Expand Down Expand Up @@ -211,3 +157,114 @@ if (TEST_PSA_DISCOVERY_ETCD)
PUBSUB_TOPOLOGY_MANAGER_VERBOSE=true
)
endif ()

option(TEST_RSA "Test Remote Service Admin" OFF)
if (TEST_RSA)
add_celix_bundle(my_rsa
SOURCES
my_rsa_activator.c
)
target_link_libraries(my_rsa PRIVATE
Celix::log_helper
Celix::deprecated_rsa_spi
Celix::rsa_common
Celix::framework
)
add_celix_container(use_my_rsa
BUNDLES
Celix::rsa_topology_manager
my_rsa
hello
PROPERTIES
)
endif ()

option(TEST_RSA_DFI "Test the Remote Service Admin Service DFI" OFF)
if (TEST_RSA_DFI)
add_celix_container(use_rsa_dfi
BUNDLES
Celix::rsa_topology_manager
Celix::rsa_dfi
hello
PROPERTIES
)
endif ()

option(TEST_RSA_DISCOVERY_CONFIGURED "Test the Discovery (Configured) bundle" OFF)
if (TEST_RSA_DISCOVERY_CONFIGURED)
add_celix_container(use_rsa_configured
BUNDLES
Celix::rsa_discovery
Celix::rsa_topology_manager
my_rsa
hello
PROPERTIES
)
endif ()

option(TEST_RSA_DISCOVERY_ETCD "Test the Discovery (ETCD) bundle" OFF)
if (TEST_RSA_DISCOVERY_ETCD)
add_celix_container(use_rsa_etcd
BUNDLES
Celix::rsa_discovery_etcd
Celix::rsa_topology_manager
my_rsa
hello
PROPERTIES
)
endif ()

option(TEST_SHELL "Test shell" OFF)
if (TEST_SHELL)
add_executable(use_shell test_shell.c )
target_link_libraries(use_shell PRIVATE Celix::framework Celix::shell_api)
celix_get_bundle_file(Celix::shell SHELL_BUNDLE)
target_compile_definitions(use_shell PRIVATE SHELL_BUNDLE_LOCATION="${SHELL_BUNDLE}")
option(TEST_CXX_SHELL "Test CXX shell" OFF)
if (TEST_CXX_SHELL)
add_executable(use_cxx_shell test_cxx_shell.cpp)
target_link_libraries(use_cxx_shell PRIVATE Celix::framework Celix::shell_api)
celix_get_bundle_file(Celix::ShellCxx CXX_SHELL_BUNDLE)
target_compile_definitions(use_cxx_shell PRIVATE CXX_SHELL_BUNDLE_LOCATION="${CXX_SHELL_BUNDLE}")
endif ()
endif ()

option(TEST_REMOTE_SHELL "Test remote shell" OFF)
if(TEST_REMOTE_SHELL)
add_celix_container("use_remote_shell" BUNDLES Celix::shell Celix::remote_shell hello)
endif ()

option(TEST_SHELL_TUI "Test shell TUI" OFF)
if(TEST_SHELL_TUI)
add_celix_container("use_shell_tui" BUNDLES Celix::shell Celix::shell_tui hello)
endif ()

option(TEST_SHELL_WUI "Test shell WUI" OFF)
if(TEST_SHELL_WUI)
add_celix_container("use_shell_wui" BUNDLES Celix::shell Celix::shell_wui hello)
endif ()

option(TEST_ETCD_LIB "Test ETCD lib" OFF)
if (TEST_ETCD_LIB)
add_executable(use_etcd_lib test_etcd_lib.c)
target_link_libraries(use_etcd_lib PRIVATE Celix::etcdlib)
endif ()

option(TEST_LAUNCHER "Test launcher" OFF)
if (TEST_LAUNCHER)
get_target_property(LAUNCHER_LOCATION Celix::launcher LOCATION)
add_celix_container("use_launcher" LAUNCHER ${LAUNCHER_LOCATION} USE_CONFIG BUNDLES hello)
endif ()

option(TEST_PROMISES "Test promises" OFF)
if (TEST_PROMISES)
add_executable(use_promises test_promises.cpp)
target_link_libraries(use_promises PRIVATE Celix::Promises)
endif ()

option(TEST_PUSHSTREAMS "Test pushstreams" OFF)
if (TEST_PUSHSTREAMS)
add_executable(use_pushstreams test_pushstreams.cpp)
target_link_libraries(use_pushstreams PRIVATE Celix::PushStreams)
endif ()

48 changes: 30 additions & 18 deletions test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ def build(self):
cmake.definitions["TEST_HTTP_ADMIN"] = self.options["celix"].build_http_admin
cmake.definitions["TEST_LOG_SERVICE"] = self.options["celix"].build_log_service
cmake.definitions["TEST_SYSLOG_WRITER"] = self.options["celix"].build_syslog_writer
cmake.definitions["TEST_PUBSUB"] = self.options["celix"].build_pubsub
cmake.definitions["TEST_PSA_ZMQ"] = self.options["celix"].build_pubsub_psa_zmq
cmake.definitions["TEST_PSA_TCP"] = self.options["celix"].build_pubsub_psa_tcp
cmake.definitions["TEST_PSA_UDP_MC"] = self.options["celix"].build_pubsub_psa_udp_mc
cmake.definitions["TEST_PSA_WS"] = self.options["celix"].build_pubsub_psa_ws
cmake.definitions["TEST_PSA_DISCOVERY_ETCD"] = self.options["celix"].build_pubsub_discovery_etcd
cmake.definitions["TEST_RSA"] = self.options["celix"].build_remote_service_admin
cmake.definitions["TEST_RSA_DFI"] = self.options["celix"].build_rsa_remote_service_admin_dfi
cmake.definitions["TEST_RSA_DISCOVERY_CONFIGURED"] = self.options["celix"].build_rsa_discovery_configured
cmake.definitions["TEST_RSA_DISCOVERY_ETCD"] = self.options["celix"].build_rsa_discovery_etcd
cmake.definitions["TEST_SHELL"] = self.options["celix"].build_shell
if self.options["celix"].build_shell:
cmake.definitions["TEST_CXX_SHELL"] = self.options["celix"].celix_cxx
Expand All @@ -44,12 +54,6 @@ def build(self):
cmake.definitions["TEST_LAUNCHER"] = self.options["celix"].build_launcher
cmake.definitions["TEST_PROMISES"] = self.options["celix"].build_promises
cmake.definitions["TEST_PUSHSTREAMS"] = self.options["celix"].build_pushstreams
cmake.definitions["TEST_PUBSUB"] = self.options["celix"].build_pubsub
cmake.definitions["TEST_PSA_ZMQ"] = self.options["celix"].build_pubsub_psa_zmq
cmake.definitions["TEST_PSA_TCP"] = self.options["celix"].build_pubsub_psa_tcp
cmake.definitions["TEST_PSA_UDP_MC"] = self.options["celix"].build_pubsub_psa_udp_mc
cmake.definitions["TEST_PSA_WS"] = self.options["celix"].build_pubsub_psa_ws
cmake.definitions["TEST_PSA_DISCOVERY_ETCD"] = self.options["celix"].build_pubsub_discovery_etcd
cmake.definitions["CMAKE_PROJECT_test_package_INCLUDE"] = os.path.join(self.build_folder, "conan_paths.cmake")
# the following is workaround https://github.com/conan-io/conan/issues/7192
cmake.definitions["CMAKE_EXE_LINKER_FLAGS"] = "-Wl,--unresolved-symbols=ignore-in-shared-libs"
Expand All @@ -65,6 +69,26 @@ def test(self):
self.run("./use_log_writer", cwd=os.path.join("deploy", "use_log_writer"), run_environment=True)
if self.options["celix"].build_syslog_writer:
self.run("./use_syslog_writer", cwd=os.path.join("deploy", "use_syslog_writer"), run_environment=True)
if self.options["celix"].build_pubsub:
self.run("./use_my_psa", cwd=os.path.join("deploy", "use_my_psa"), run_environment=True)
if self.options["celix"].build_pubsub_psa_zmq:
self.run("./use_psa_zmq", cwd=os.path.join("deploy", "use_psa_zmq"), run_environment=True)
if self.options["celix"].build_pubsub_psa_tcp:
self.run("./use_psa_tcp", cwd=os.path.join("deploy", "use_psa_tcp"), run_environment=True)
if self.options["celix"].build_pubsub_psa_udp_mc:
self.run("./use_psa_udp_mc", cwd=os.path.join("deploy", "use_psa_udp_mc"), run_environment=True)
if self.options["celix"].build_pubsub_psa_ws:
self.run("./use_psa_ws", cwd=os.path.join("deploy", "use_psa_ws"), run_environment=True)
if self.options["celix"].build_pubsub_discovery_etcd:
self.run("./use_psa_discovery_etcd", cwd=os.path.join("deploy", "use_psa_discovery_etcd"), run_environment=True)
if self.options["celix"].build_remote_service_admin:
self.run("./use_my_rsa", cwd=os.path.join("deploy", "use_my_rsa"), run_environment=True)
if self.options["celix"].build_rsa_remote_service_admin_dfi:
self.run("./use_rsa_dfi", cwd=os.path.join("deploy", "use_rsa_dfi"), run_environment=True)
if self.options["celix"].build_rsa_discovery_configured:
self.run("./use_rsa_configured", cwd=os.path.join("deploy", "use_rsa_configured"), run_environment=True)
if self.options["celix"].build_rsa_discovery_etcd:
self.run("./use_rsa_etcd", cwd=os.path.join("deploy", "use_rsa_etcd"), run_environment=True)
if self.options["celix"].build_shell:
self.run("./use_shell", run_environment=True)
if self.options["celix"].celix_cxx:
Expand All @@ -83,15 +107,3 @@ def test(self):
self.run("./use_promises", run_environment=True)
if self.options["celix"].build_pushstreams:
self.run("./use_pushstreams", run_environment=True)
if self.options["celix"].build_pubsub:
self.run("./use_my_psa", cwd=os.path.join("deploy", "use_my_psa"), run_environment=True)
if self.options["celix"].build_pubsub_psa_zmq:
self.run("./use_psa_zmq", cwd=os.path.join("deploy", "use_psa_zmq"), run_environment=True)
if self.options["celix"].build_pubsub_psa_tcp:
self.run("./use_psa_tcp", cwd=os.path.join("deploy", "use_psa_tcp"), run_environment=True)
if self.options["celix"].build_pubsub_psa_udp_mc:
self.run("./use_psa_udp_mc", cwd=os.path.join("deploy", "use_psa_udp_mc"), run_environment=True)
if self.options["celix"].build_pubsub_psa_ws:
self.run("./use_psa_ws", cwd=os.path.join("deploy", "use_psa_ws"), run_environment=True)
if self.options["celix"].build_pubsub_discovery_etcd:
self.run("./use_psa_discovery_etcd", cwd=os.path.join("deploy", "use_psa_discovery_etcd"), run_environment=True)
115 changes: 115 additions & 0 deletions test_package/my_rsa_activator.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
*/

#include <celix_api.h>
#include <remote_service_admin.h>
#include <remote_constants.h>
#include <celix_log_helper.h>


struct remote_service_admin {
celix_bundle_context_t *context;
celix_log_helper_t *loghelper;
};

typedef struct my_remote_service_admin_activator {
remote_service_admin_t admin;
remote_service_admin_service_t adminService;
long svcIdRsa;
} my_remote_service_admin_activator_t;

static celix_status_t remoteServiceAdmin_exportService(remote_service_admin_t *admin, char *serviceId, celix_properties_t *properties, array_list_pt *registrations) {
(void)properties;
(void)registrations;
celix_logHelper_info(admin->loghelper, "%s called: serviceId=%s\n", __FUNCTION__, serviceId);
}

static celix_status_t remoteServiceAdmin_getExportedServices(remote_service_admin_t *admin, array_list_pt *services) {
celix_status_t status = CELIX_SUCCESS;
(void)services;
celix_logHelper_info(admin->loghelper, "%s called\n", __FUNCTION__);
return status;
}

static celix_status_t remoteServiceAdmin_getImportedEndpoints(remote_service_admin_t *admin, array_list_pt *services) {
celix_status_t status = CELIX_SUCCESS;
(void)services;
celix_logHelper_info(admin->loghelper, "%s called\n", __FUNCTION__);
return status;
}

static celix_status_t remoteServiceAdmin_importService(remote_service_admin_t *admin, endpoint_description_t *endpointDescription, import_registration_t **out) {
const char *importConfigs = celix_properties_get(endpointDescription->properties, OSGI_RSA_SERVICE_IMPORTED_CONFIGS, NULL);
celix_logHelper_info(admin->loghelper, "%s called: %s\n", __FUNCTION__, importConfigs);
return CELIX_ILLEGAL_ARGUMENT;
}

static celix_status_t remoteServiceAdmin_removeExportedService(remote_service_admin_t *admin, export_registration_t *registration) {
(void)registration;
celix_logHelper_info(admin->loghelper, "%s called\n", __FUNCTION__);
return CELIX_SUCCESS;
}

static celix_status_t remoteServiceAdmin_removeImportedService(remote_service_admin_t *admin, import_registration_t *registration) {
(void)registration;
celix_logHelper_info(admin->loghelper, "%s called\n", __FUNCTION__);
return CELIX_SUCCESS;
}

static celix_status_t my_rsa_start(my_remote_service_admin_activator_t* activator, celix_bundle_context_t* ctx) {
celix_status_t status = CELIX_SUCCESS;
activator->admin.context = ctx;
activator->admin.loghelper = celix_logHelper_create(ctx, "my_rsa");
activator->svcIdRsa = -1;

if (status == CELIX_SUCCESS) {
activator->adminService.admin = &activator->admin;
activator->adminService.exportService = remoteServiceAdmin_exportService;

activator->adminService.getExportedServices = remoteServiceAdmin_getExportedServices;
activator->adminService.getImportedEndpoints = remoteServiceAdmin_getImportedEndpoints;
activator->adminService.importService = remoteServiceAdmin_importService;

activator->adminService.exportReference_getExportedEndpoint = exportReference_getExportedEndpoint;
activator->adminService.exportReference_getExportedService = exportReference_getExportedService;

activator->adminService.exportRegistration_close = remoteServiceAdmin_removeExportedService;
activator->adminService.exportRegistration_getException = exportRegistration_getException;
activator->adminService.exportRegistration_getExportReference = exportRegistration_getExportReference;

activator->adminService.importReference_getImportedEndpoint = importReference_getImportedEndpoint;
activator->adminService.importReference_getImportedService = importReference_getImportedService;

activator->adminService.importRegistration_close = remoteServiceAdmin_removeImportedService;
activator->adminService.importRegistration_getException = importRegistration_getException;
activator->adminService.importRegistration_getImportReference = importRegistration_getImportReference;

activator->svcIdRsa = celix_bundleContext_registerService(ctx, &activator->adminService, OSGI_RSA_REMOTE_SERVICE_ADMIN, NULL);
}

return status;
}

static celix_status_t my_rsa_stop(my_remote_service_admin_activator_t* activator, celix_bundle_context_t* ctx) {
celix_bundleContext_unregisterService(ctx, activator->svcIdRsa);
celix_logHelper_destroy(activator->admin.loghelper);
return CELIX_SUCCESS;
}

CELIX_GEN_BUNDLE_ACTIVATOR(my_remote_service_admin_activator_t, my_rsa_start, my_rsa_stop)

0 comments on commit 36bc83f

Please sign in to comment.