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

Feature/685 update container config properties usage #751

Merged
merged 23 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2c28348
gh-685: Remove of old properties load and store
pnoltes May 24, 2024
74f4257
gh-685: Refactor config prop cmake gen and test config props
pnoltes May 30, 2024
0a0709a
gh-685: Improve error handling for properties save/load
pnoltes May 30, 2024
0566315
gh-685: Rename properties load2/loadFromString2 to load/loadFromString
pnoltes May 30, 2024
b8c6ab5
gh-685: Change space sep in auto start bundle to comma seperator
pnoltes May 30, 2024
55b3ae8
gh-685: Fix properties encoding usage in rsa shm
pnoltes May 30, 2024
7405378
gh-685: Fix macos specific file utils tests
pnoltes May 30, 2024
68098de
gh-685: Fix macos specific file utils tests
pnoltes May 30, 2024
64e3647
gh-685: Fix memleak in bundle archive
pnoltes May 30, 2024
0c859f0
gh-685: Fix memleak in bundle archive
pnoltes May 30, 2024
ddf0a77
gh-685: Refactor celix launcher
pnoltes Jun 1, 2024
87ab2b3
Merge branch 'refs/heads/master' into feature/685-update-container-co…
pnoltes Jun 2, 2024
5b4cd3a
gh-685: Replace sigabbrev_np usage with strsignal
pnoltes Jun 2, 2024
fe5aa59
gh-685: Replace constexpr with define
pnoltes Jun 2, 2024
25df868
gh-685: Add celix launcher test suite with error injection
pnoltes Jun 2, 2024
e06e2ad
gh-685: Fix tms_tests and improve several error handling issues
pnoltes Jun 3, 2024
bf0011a
gh-685: Improve celix_launcher coverage and fix memleaks
pnoltes Jun 4, 2024
a014956
Make various lock guard deinit explicitly callable so that locks can …
PengZheng Jun 7, 2024
8b0e0e0
gh-685: Add bundle entry guard
pnoltes Jun 9, 2024
f237f4b
gh-685: Add rsa shm test case
pnoltes Jun 9, 2024
17a5ada
Cleanup bundle cache on installation failure and fix use-after-free.
PengZheng Jun 10, 2024
ad9e542
gh-685: Refactor launcher global framework handling
pnoltes Jun 10, 2024
621c2be
gh-685: Improve error handling of launcher.
PengZheng Jun 11, 2024
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
6 changes: 5 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ limitations under the License.
- pubsub_serializer.h is removed and no longer supported. Use pubsub_message_serialization_service.h instead.
- C++11 support for dm is removed. C++14 is now the minimum required version.
- C++17 string_view support is removed from the utils and framework lib.
- Apache Celix CMake bundle functions without a celix_ prefix or infix are removed.
- Apache Celix CMake container & bundle functions without a celix_ prefix or infix are removed.
- Apache Celix CMake support for creating docker images and creating runtimes dirs is removed.
- Support and usage of "service.lang" service property is removed.
- Rename of `CELIX_FRAMEWORK_FRAMEWORK_CACHE_DIR` config property to `CELIX_FRAMEWORK_CACHE_DIR`.
Expand Down Expand Up @@ -73,6 +73,10 @@ limitations under the License.
to add service properties with the correct type.
- Celix C++ Exception are now defined in the `celix/exceptions.h` header file. The `celix/Exception.h`
and `celix/IOException.h` are removed.
- The seperator for `CELIX_AUTO_START_0` .. `CELIX_AUTO_START_6` and `CELIX_AUTO_INSTALL` is now a comma instead of a
space.
- The launcher now only has 2 public functions: `celix_launcher_launchAndWait` and `celix_launcher_triggerStop`. The
other functions are removed.

## New Features

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
CELIX_AUTO_START_1=@rsa_bundle_file@ @discovery_bundle_file@ @topology_manager_bundle_file@ @tst_bundle_file@
LOGHELPER_ENABLE_STDOUT_FALLBACK=true
CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE=true
CELIX_FRAMEWORK_CACHE_DIR=.cacheClient

DISCOVERY_CFG_POLL_INTERVAL=1
DISCOVERY_CFG_POLL_TIMEOUT=5
RSA_PORT=50881
DISCOVERY_CFG_SERVER_PORT=50991
DISCOVERY_CFG_POLL_ENDPOINTS=http://localhost:50992/org.apache.celix.discovery.configured
{
"CELIX_AUTO_START_1":"@rsa_bundle_file@,@discovery_bundle_file@,@topology_manager_bundle_file@,@tst_bundle_file@",
"LOGHELPER_ENABLE_STDOUT_FALLBACK":true,
"CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE":true,
"CELIX_FRAMEWORK_CACHE_DIR":".cacheClient",
"DISCOVERY_CFG_POLL_INTERVAL":1,
"DISCOVERY_CFG_POLL_TIMEOUT":5,
"RSA_PORT":50881,
"DISCOVERY_CFG_SERVER_PORT":50991,
"DISCOVERY_CFG_POLL_ENDPOINTS":"http://localhost:50992/org.apache.celix.discovery.configured"
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
# 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.

CELIX_AUTO_START_1=@rsa_bundle_file@ @calc_bundle_file@
LOGHELPER_ENABLE_STDOUT_FALLBACK=true
CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE=true
{
"CELIX_AUTO_START_1":"@rsa_bundle_file@,@calc_bundle_file@",
"LOGHELPER_ENABLE_STDOUT_FALLBACK":true,
"CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE":true
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
# 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.
CELIX_AUTO_START_1=@rsa_bundle_file@ @calc_bundle_file@ @remote_example_bundle_file@ @discovery_bundle_file@ @topology_manager_bundle_file@
LOGHELPER_ENABLE_STDOUT_FALLBACK=true
CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE=true
CELIX_FRAMEWORK_CACHE_DIR=.cacheServer

DISCOVERY_CFG_POLL_INTERVAL=1
DISCOVERY_CFG_POLL_TIMEOUT=5
RSA_PORT=50882
DISCOVERY_CFG_SERVER_PORT=50992
DISCOVERY_CFG_POLL_ENDPOINTS=http://localhost:50991/org.apache.celix.discovery.configured
{
"CELIX_AUTO_START_1":"@rsa_bundle_file@,@calc_bundle_file@,@remote_example_bundle_file@,@discovery_bundle_file@,@topology_manager_bundle_file@",
"LOGHELPER_ENABLE_STDOUT_FALLBACK":true,
"CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE":true,
"CELIX_FRAMEWORK_CACHE_DIR":".cacheServer",
"DISCOVERY_CFG_POLL_INTERVAL":1,
"DISCOVERY_CFG_POLL_TIMEOUT":5,
"RSA_PORT":50882,
"DISCOVERY_CFG_SERVER_PORT":50992,
"DISCOVERY_CFG_POLL_ENDPOINTS":"http://localhost:50991/org.apache.celix.discovery.configured"
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,38 +44,40 @@ typedef struct rsa_dfi_exception_test_service {
int (*func1)(void *handle);
}rsa_dfi_exception_test_service_t;

static celix_framework_t *serverFramework = NULL;
static celix_bundle_context_t *serverContext = NULL;
static celix_framework_t *serverFramework = nullptr;
static celix_bundle_context_t *serverContext = nullptr;

static celix_framework_t *clientFramework = NULL;
static celix_bundle_context_t *clientContext = NULL;
static celix_framework_t *clientFramework = nullptr;
static celix_bundle_context_t *clientContext = nullptr;

static rsa_dfi_exception_test_service_t *exceptionTestService = NULL;
static rsa_dfi_exception_test_service_t *exceptionTestService = nullptr;
static long exceptionTestSvcId = -1L;
static remote_interceptor_t *serverSvcInterceptor=NULL;
static remote_interceptor_t *clientSvcInterceptor=NULL;
static remote_interceptor_t *serverSvcInterceptor=nullptr;
static remote_interceptor_t *clientSvcInterceptor=nullptr;
static long serverSvcInterceptorSvcId = -1L;
static long clientSvcInterceptorSvcId = -1L;
static bool clientInterceptorPreProxyCallRetval=true;
static bool svcInterceptorPreExportCallRetval=true;

static void setupFm(bool useCurlShare) {
//server
celix_properties_t *serverProps = celix_properties_load("server.properties");
ASSERT_TRUE(serverProps != NULL);
celix_properties_t *serverProps = nullptr;
ASSERT_EQ(CELIX_SUCCESS, celix_properties_load("server.properties", 0, &serverProps));
ASSERT_TRUE(serverProps != nullptr);
serverFramework = celix_frameworkFactory_createFramework(serverProps);
ASSERT_TRUE(serverFramework != NULL);
ASSERT_TRUE(serverFramework != nullptr);
serverContext = celix_framework_getFrameworkContext(serverFramework);
ASSERT_TRUE(serverContext != NULL);
ASSERT_TRUE(serverContext != nullptr);

//client
celix_properties_t *clientProperties = celix_properties_load("client.properties");
celix_properties_t *clientProperties = nullptr;
ASSERT_EQ(CELIX_SUCCESS, celix_properties_load("client.properties", 0, &clientProperties));
celix_properties_setBool(clientProperties, "RSA_DFI_USE_CURL_SHARE_HANDLE", useCurlShare);
ASSERT_TRUE(clientProperties != NULL);
ASSERT_TRUE(clientProperties != nullptr);
clientFramework = celix_frameworkFactory_createFramework(clientProperties);
ASSERT_TRUE(clientFramework != NULL);
ASSERT_TRUE(clientFramework != nullptr);
clientContext = celix_framework_getFrameworkContext(clientFramework);
ASSERT_TRUE(clientContext != NULL);
ASSERT_TRUE(clientContext != nullptr);
}

static void teardownFm(void) {
Expand All @@ -92,7 +94,7 @@ typedef struct rsa_dfi_exception_test_service {
celix_properties_set(properties, CELIX_RSA_SERVICE_EXPORTED_INTERFACES, RSA_DIF_EXCEPTION_TEST_SERVICE);
celix_properties_set(properties, CELIX_RSA_SERVICE_EXPORTED_CONFIGS, "org.amdatu.remote.admin.http");
exceptionTestService = (rsa_dfi_exception_test_service_t *)calloc(1,sizeof(*exceptionTestService));
exceptionTestService->handle = NULL;
exceptionTestService->handle = nullptr;
exceptionTestService->func1 = rsaDfi_excepTestFunc1;
exceptionTestSvcId = celix_bundleContext_registerService(serverContext, exceptionTestService, RSA_DIF_EXCEPTION_TEST_SERVICE, properties);
}
Expand Down Expand Up @@ -137,7 +139,7 @@ typedef struct rsa_dfi_exception_test_service {
static void registerInterceptorService(void) {
svcInterceptorPreExportCallRetval = true;
serverSvcInterceptor = (remote_interceptor_t *)calloc(1,sizeof(*serverSvcInterceptor));
serverSvcInterceptor->handle = NULL;
serverSvcInterceptor->handle = nullptr;
serverSvcInterceptor->preProxyCall = serverServiceInterceptor_preProxyCall;
serverSvcInterceptor->postProxyCall = serverServiceInterceptor_postProxyCall;
serverSvcInterceptor->preExportCall = serverServiceInterceptor_preExportCall;
Expand All @@ -153,7 +155,7 @@ typedef struct rsa_dfi_exception_test_service {

clientInterceptorPreProxyCallRetval = true;
clientSvcInterceptor = (remote_interceptor_t *)calloc(1,sizeof(*clientSvcInterceptor));
clientSvcInterceptor->handle = NULL;
clientSvcInterceptor->handle = nullptr;
clientSvcInterceptor->preProxyCall = clientServiceInterceptor_preProxyCall;
clientSvcInterceptor->postProxyCall = clientServiceInterceptor_postProxyCall;
clientSvcInterceptor->preExportCall = clientServiceInterceptor_preExportCall;
Expand Down Expand Up @@ -472,8 +474,8 @@ class RsaDfiDynamicIpServerTestSuite : public ::testing::Test {

char calcIdStr[32] = {0};
snprintf(calcIdStr, 32, "%li", calcId);
celix_array_list_t *svcRegistrations = NULL;
auto status = serverRsaSvc->exportService(serverRsaSvc->admin, calcIdStr, NULL, &svcRegistrations);
celix_array_list_t *svcRegistrations = nullptr;
auto status = serverRsaSvc->exportService(serverRsaSvc->admin, calcIdStr, nullptr, &svcRegistrations);
ASSERT_EQ(CELIX_SUCCESS, status);
ASSERT_EQ(1, celix_arrayList_size(svcRegistrations));
export_registration_t *exportedReg = static_cast<export_registration_t*>(celix_arrayList_get(svcRegistrations, 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,19 @@ extern "C" {

#define TST_CONFIGURATION_TYPE "org.amdatu.remote.admin.http"

static celix_framework_t *framework = NULL;
static celix_bundle_context_t *context = NULL;
static celix_framework_t *framework = nullptr;
static celix_bundle_context_t *context = nullptr;

long calcSvcId = -1L;

static void setupFm(void) {
celix_properties_t *fwProperties = celix_properties_load("config.properties");
ASSERT_TRUE(fwProperties != NULL);
celix_properties_t *fwProperties = nullptr;
EXPECT_EQ(CELIX_SUCCESS, celix_properties_load("config.properties", 0, &fwProperties));
ASSERT_TRUE(fwProperties != nullptr);
framework = celix_frameworkFactory_createFramework(fwProperties);
ASSERT_TRUE(framework != NULL);
ASSERT_TRUE(framework != nullptr);
context = celix_framework_getFrameworkContext(framework);
ASSERT_TRUE(context != NULL);
ASSERT_TRUE(context != nullptr);


calcSvcId = celix_bundleContext_findService(context, CALCULATOR_SERVICE);
Expand Down Expand Up @@ -87,8 +88,8 @@ extern "C" {
char strSvcId[64];
snprintf(strSvcId, 64, "%li", calcSvcId);

celix_array_list_t *svcRegistration = NULL;
int rc = rsa->exportService(rsa->admin, strSvcId, NULL, &svcRegistration);
celix_array_list_t *svcRegistration = nullptr;
int rc = rsa->exportService(rsa->admin, strSvcId, nullptr, &svcRegistration);
ASSERT_EQ(CELIX_SUCCESS, rc);

ASSERT_EQ(1, celix_arrayList_size(svcRegistration));
Expand Down Expand Up @@ -155,7 +156,7 @@ extern "C" {
}

static void testBundles(void) {
celix_array_list_t* bundles = NULL;
celix_array_list_t* bundles = nullptr;

int rc = bundleContext_getBundles(context, &bundles);
ASSERT_EQ(0, rc);
Expand All @@ -165,9 +166,9 @@ extern "C" {
int size = arrayList_size(bundles);
int i;
for (i = 0; i < size; i += 1) {
celix_bundle_t *bundle = NULL;
module_pt module = NULL;
char *name = NULL;
celix_bundle_t *bundle = nullptr;
module_pt module = nullptr;
char *name = nullptr;

bundle = (celix_bundle_t *) arrayList_get(bundles, i);
bundle_getCurrentModule(bundle, &module);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,12 @@ celix_status_t rsaShmClientManager_sendMsgTo(rsa_shm_client_manager_t *clientMan
return CELIX_ERROR_MAKE(CELIX_FACILITY_CERRNO, errno);
}
if (metadata != NULL) {
CELIX_PROPERTIES_ITERATE(metadata, iter) {
fprintf(fp,"%s=%s\n", iter.key, iter.entry.value);
status = celix_properties_saveToStream(metadata, fp, 0);
if (status != CELIX_SUCCESS) {
celix_logHelper_error(
clientManager->logHelper, "RsaShmClient: Error encoding metadata to memory stream. %d.", status);
celix_logHelper_logTssErrors(clientManager->logHelper, CELIX_LOG_LEVEL_ERROR);
PengZheng marked this conversation as resolved.
Show resolved Hide resolved
return status;
}
}
fclose(fp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static void rsaShmServer_terminateMsgHandling(rsa_shm_msg_control_t *ctrl) {

static void rsaShmServer_msgHandlingWork(void *data) {
assert(data != NULL);
int status = CELIX_SUCCESS;
int status = CELIX_SUCCESS;
struct rsa_shm_server_thpool_work_data *workData = data;
rsa_shm_server_t *server = workData->server;
assert(server != NULL);
Expand All @@ -179,9 +179,9 @@ static void rsaShmServer_msgHandlingWork(void *data) {

celix_properties_t *metadataProps = NULL;
if (workData->metadataSize != 0) {
metadataProps = celix_properties_loadFromString(metaDataString);
if (metadataProps == NULL) {
if (celix_properties_loadFromString(metaDataString, 0, &metadataProps) != CELIX_SUCCESS) {
celix_logHelper_warning(server->loghelper, "RsaShmServer: Parse metadata failed.");
celix_logHelper_logTssErrors(server->loghelper, CELIX_LOG_LEVEL_WARNING);
}
}

Expand Down
22 changes: 12 additions & 10 deletions bundles/remote_services/topology_manager/tms_tst/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,21 @@ add_celix_bundle_dependencies(test_tm_scoped Celix::rsa_dfi Celix::rsa_topology_

file(GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/config.properties"
CONTENT "
CELIX_AUTO_START_1=$<TARGET_PROPERTY:Celix::rsa_dfi,BUNDLE_FILE> $<TARGET_PROPERTY:calculator,BUNDLE_FILE> $<TARGET_PROPERTY:Celix::rsa_topology_manager,BUNDLE_FILE> $<TARGET_PROPERTY:topology_manager_disc_mock_bundle,BUNDLE_FILE>
LOGHELPER_ENABLE_STDOUT_FALLBACK=true
CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE=true
")
CONTENT "{
\"CELIX_AUTO_START_1\":\"$<TARGET_PROPERTY:Celix::rsa_dfi,BUNDLE_FILE>,$<TARGET_PROPERTY:calculator,BUNDLE_FILE>,$<TARGET_PROPERTY:Celix::rsa_topology_manager,BUNDLE_FILE>,$<TARGET_PROPERTY:topology_manager_disc_mock_bundle,BUNDLE_FILE>\",
\"LOGHELPER_ENABLE_STDOUT_FALLBACK\":true,
\"CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE\":true,
\"CELIX_FRAMEWORK_CACHE_DIR\":\".rstm_cache\"
}")

file(GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/config_import.properties"
CONTENT "
CELIX_AUTO_START_1=$<TARGET_PROPERTY:Celix::rsa_dfi,BUNDLE_FILE> $<TARGET_PROPERTY:calculator,BUNDLE_FILE> $<TARGET_PROPERTY:Celix::rsa_topology_manager,BUNDLE_FILE> $<TARGET_PROPERTY:topology_manager_test_bundle,BUNDLE_FILE>
LOGHELPER_ENABLE_STDOUT_FALLBACK=true
CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE=true
")
CONTENT "{
\"CELIX_AUTO_START_1\":\"$<TARGET_PROPERTY:Celix::rsa_dfi,BUNDLE_FILE>,$<TARGET_PROPERTY:calculator,BUNDLE_FILE>,$<TARGET_PROPERTY:Celix::rsa_topology_manager,BUNDLE_FILE>,$<TARGET_PROPERTY:topology_manager_test_bundle,BUNDLE_FILE>\",
\"LOGHELPER_ENABLE_STDOUT_FALLBACK\":true,
\"CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE\":true,
\"CELIX_FRAMEWORK_CACHE_DIR\":\".rstm_import_cache\"
}")

configure_file("scope.json" "scope.json")
configure_file("scope2.json" "scope2.json")
Expand Down
Loading
Loading