Skip to content

Commit

Permalink
RDKTV-31830 : split Cloud Store in a separate plugin
Browse files Browse the repository at this point in the history
Reason for change: Separate plugin for separate functionality.
Fixes the problem of FTA/IPC/Thunder thread pool.
Test Procedure: None
Risks: None
Signed-off-by: Nikita Poltorapavlo <npoltorapavlo@productengine.com>
  • Loading branch information
npoltorapavlo committed Jul 24, 2024
1 parent b8a7a53 commit 9de8e9f
Show file tree
Hide file tree
Showing 39 changed files with 1,101 additions and 303 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/BuildThunder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ cmake --build build/Thunder --target install
############################
# 4. Build ThunderInterfaces

git clone https://github.com/rdkcentral/ThunderInterfaces.git
git clone -b RDKTV-31830 https://github.com/npoltorapavlo/ThunderInterfaces.git

cmake -G Ninja -S ThunderInterfaces -B build/ThunderInterfaces \
-DCMAKE_INSTALL_PREFIX="install"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: L0-PersistentStore-grpc
name: L0-CloudStore-grpc

on:
push:
paths:
- PersistentStore/**
- .github/workflows/*PersistentStore*.yml
- CloudStore/**
- .github/workflows/*CloudStore*.yml
pull_request:
paths:
- PersistentStore/**
- .github/workflows/*PersistentStore*.yml
- CloudStore/**
- .github/workflows/*CloudStore*.yml

jobs:
build:
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Build
working-directory: ${{github.workspace}}
run: |
cmake -S ${GITHUB_REPOSITORY}/PersistentStore/grpc/l0test -B build/grpcl0test -DCMAKE_INSTALL_PREFIX="install" -DCMAKE_CXX_FLAGS="--coverage -Wall -Werror"
cmake -S ${GITHUB_REPOSITORY}/CloudStore/grpc/l0test -B build/grpcl0test -DCMAKE_INSTALL_PREFIX="install" -DCMAKE_CXX_FLAGS="--coverage -Wall -Werror"
cmake --build build/grpcl0test --target install
- name: Run
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/L0-CloudStore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: L0-CloudStore

on:
push:
paths:
- CloudStore/**
- .github/workflows/*CloudStore*.yml
pull_request:
paths:
- CloudStore/**
- .github/workflows/*CloudStore*.yml

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
path: ${{github.repository}}

- name: Install valgrind, coverage, cmake
run: |
sudo apt update
sudo apt install -y valgrind lcov cmake
- name: Build Thunder
working-directory: ${{github.workspace}}
run: sh +x ${GITHUB_REPOSITORY}/.github/workflows/BuildThunder.sh

- name: Build
working-directory: ${{github.workspace}}
run: |
cmake -S ${GITHUB_REPOSITORY}/CloudStore/l0test -B build/cloudstorel0test -DCMAKE_INSTALL_PREFIX="install" -DCMAKE_CXX_FLAGS="--coverage -Wall -Werror"
cmake --build build/cloudstorel0test --target install
- name: Run
working-directory: ${{github.workspace}}
run: PATH=${PWD}/install/bin:${PATH} LD_LIBRARY_PATH=${PWD}/install/lib:${LD_LIBRARY_PATH} valgrind --tool=memcheck --log-file=valgrind_log --leak-check=yes --show-reachable=yes --track-fds=yes --fair-sched=try cloudstorel0test

- name: Generate coverage
working-directory: ${{github.workspace}}
run: |
lcov -c -o coverage.info -d build/cloudstorel0test
genhtml -o coverage coverage.info
- name: Upload artifacts
if: ${{ !env.ACT }}
uses: actions/upload-artifact@v4
with:
name: artifacts
path: |
coverage/
valgrind_log
if-no-files-found: warn
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: L2-PersistentStore-grpc
name: L2-CloudStore-grpc

on:
push:
paths:
- PersistentStore/**
- .github/workflows/*PersistentStore*.yml
- CloudStore/**
- .github/workflows/*CloudStore*.yml
pull_request:
paths:
- PersistentStore/**
- .github/workflows/*PersistentStore*.yml
- CloudStore/**
- .github/workflows/*CloudStore*.yml

jobs:
build:
Expand All @@ -27,7 +27,7 @@ jobs:
- name: Build
working-directory: ${{github.workspace}}
run: |
cmake -S ${GITHUB_REPOSITORY}/PersistentStore/grpc/l2test -B build/grpcl2test -DCMAKE_INSTALL_PREFIX="install" -DCMAKE_CXX_FLAGS="-Wall -Werror"
cmake -S ${GITHUB_REPOSITORY}/CloudStore/grpc/l2test -B build/grpcl2test -DCMAKE_INSTALL_PREFIX="install" -DCMAKE_CXX_FLAGS="-Wall -Werror"
cmake --build build/grpcl2test --target install
# Usage:
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/L2-CloudStore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: L2-CloudStore

on:
push:
paths:
- CloudStore/**
- .github/workflows/*CloudStore*.yml
pull_request:
paths:
- CloudStore/**
- .github/workflows/*CloudStore*.yml

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
path: ${{github.repository}}

- name: Install cmake, protoc, grpc_cpp_plugin, grpc
run: |
sudo apt update
sudo apt install -y cmake protobuf-compiler protobuf-compiler-grpc libgrpc++-dev
- name: Build Thunder
working-directory: ${{github.workspace}}
run: sh +x ${GITHUB_REPOSITORY}/.github/workflows/BuildThunder.sh

- name: Build
working-directory: ${{github.workspace}}
run: |
cmake -S ${GITHUB_REPOSITORY}/CloudStore -B build/CloudStore -DCMAKE_INSTALL_PREFIX="install" -DCMAKE_CXX_FLAGS="-Wall -Werror" -DPLUGIN_CLOUDSTORE_MODE=Local -DPLUGIN_CLOUDSTORE_URI=ss.eu.prod.developer.comcast.com:443
cmake --build build/CloudStore --target install
# Usage:
# PATH=${PWD}/install/bin:${PATH} LD_LIBRARY_PATH=${PWD}/install/lib:${LD_LIBRARY_PATH} valgrind --tool=memcheck --log-file=valgrind_log --leak-check=yes --show-reachable=yes --track-fds=yes --fair-sched=try Thunder -f -c ${PWD}/install/etc/Thunder/config.json
# (to stop press q & enter)
# curl -d '{"jsonrpc":"2.0","id":0,"method":"org.rdk.CloudStore.setValue","params":{"namespace":"test","key":"key1","value":"1","ttl":100}}' http://localhost:55555/jsonrpc
6 changes: 3 additions & 3 deletions .github/workflows/L2-PersistentStore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
with:
path: ${{github.repository}}

- name: Install cmake, sqlite, protoc, grpc_cpp_plugin, grpc
- name: Install cmake, sqlite
run: |
sudo apt update
sudo apt install -y cmake libsqlite3-dev protobuf-compiler protobuf-compiler-grpc libgrpc++-dev
sudo apt install -y cmake libsqlite3-dev
- name: Build Thunder
working-directory: ${{github.workspace}}
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Build
working-directory: ${{github.workspace}}
run: |
cmake -S ${GITHUB_REPOSITORY}/PersistentStore -B build/PersistentStore -DCMAKE_INSTALL_PREFIX="install" -DCMAKE_CXX_FLAGS="-Wall -Werror" -DPLUGIN_PERSISTENTSTORE_PATH="/tmp/persistentstore/l2test/test" -DPLUGIN_PERSISTENTSTORE_WITH_ACCOUNT_SCOPE=true -DPLUGIN_PERSISTENTSTORE_MODE=Local -DPLUGIN_PERSISTENTSTORE_URI=ss.eu.prod.developer.comcast.com:443
cmake -S ${GITHUB_REPOSITORY}/PersistentStore -B build/PersistentStore -DCMAKE_INSTALL_PREFIX="install" -DCMAKE_CXX_FLAGS="-Wall -Werror" -DPLUGIN_PERSISTENTSTORE_PATH="/tmp/persistentstore/l2test/test" -DPLUGIN_PERSISTENTSTORE_MODE=Local
cmake --build build/PersistentStore --target install
# Usage:
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ if (PLUGIN_RESOURCEMANAGER)
add_subdirectory(ResourceManager)
endif()

if(PLUGIN_CLOUDSTORE)
add_subdirectory(CloudStore)
endif()

if(WPEFRAMEWORK_CREATE_IPKG_TARGETS)
set(CPACK_GENERATOR "DEB")
set(CPACK_DEB_COMPONENT_INSTALL ON)
Expand Down
25 changes: 25 additions & 0 deletions CloudStore/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Changelog

All notable changes to this RDK Service will be documented in this file.

* Each RDK Service has a CHANGELOG file that contains all changes done so far. When version is updated, add a entry in the CHANGELOG.md at the top with user friendly information on what was changed with the new version. Please don't mention JIRA tickets in CHANGELOG.

* Please Add entry in the CHANGELOG for each version change and indicate the type of change with these labels:
* **Added** for new features.
* **Changed** for changes in existing functionality.
* **Deprecated** for soon-to-be removed features.
* **Removed** for now removed features.
* **Fixed** for any bug fixes.
* **Security** in case of vulnerabilities.

* Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development.

* For more details, refer to [versioning](https://github.com/rdkcentral/rdkservices#versioning) section under Main README.

## [1.0.0] - 2024-07-15
### Added
- Add CHANGELOG

### Change
- Reset API version to 1.0.0
- Change README to inform how to update changelog and API version
97 changes: 97 additions & 0 deletions CloudStore/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# If not stated otherwise in this file or this component's LICENSE file the
# following copyright and licenses apply:
#
# Copyright 2022 RDK Management
#
# Licensed 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.

cmake_minimum_required(VERSION 3.14)

set(PLUGIN_NAME CloudStore)
find_package(WPEFramework NAMES WPEFramework Thunder)
set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME})

set(CMAKE_CXX_STANDARD 11)

set(PLUGIN_CLOUDSTORE_MODE "Off" CACHE STRING "Controls if the plugin should run in its own process, in process or remote")
set(PLUGIN_CLOUDSTORE_URI "" CACHE STRING "Endpoint")
set(PLUGIN_CLOUDSTORE_STARTUPORDER "" CACHE STRING "To configure startup order of the plugin")

add_library(${MODULE_NAME} SHARED
CloudStore.cpp
Module.cpp
)

find_package(${NAMESPACE}Plugins REQUIRED)
find_package(${NAMESPACE}Definitions REQUIRED)
target_link_libraries(${MODULE_NAME} PRIVATE
${NAMESPACE}Plugins::${NAMESPACE}Plugins
${NAMESPACE}Definitions::${NAMESPACE}Definitions
)

find_library(RFC_LIBRARIES NAMES rfcapi)
if (RFC_LIBRARIES)
find_path(RFC_INCLUDE_DIRS NAMES rfcapi.h REQUIRED)
target_include_directories(${MODULE_NAME} PRIVATE ${RFC_INCLUDE_DIRS})
target_link_libraries(${MODULE_NAME} PRIVATE ${RFC_LIBRARIES})
target_compile_definitions(${MODULE_NAME} PRIVATE WITH_RFC)
endif ()

install(TARGETS ${MODULE_NAME}
DESTINATION lib/${STORAGE_DIRECTORY}/plugins)

set(PLUGIN_IMPLEMENTATION ${MODULE_NAME}Implementation)
add_library(${PLUGIN_IMPLEMENTATION} SHARED
Module.cpp
CloudStoreImplementation.cpp
)

target_link_libraries(${PLUGIN_IMPLEMENTATION} PRIVATE
${NAMESPACE}Plugins::${NAMESPACE}Plugins
${NAMESPACE}Definitions::${NAMESPACE}Definitions
)

find_library(IARMBUS_LIBRARIES NAMES IARMBus)
if (IARMBUS_LIBRARIES)
find_path(IARMBUS_INCLUDE_DIRS NAMES libIBus.h PATH_SUFFIXES rdk/iarmbus REQUIRED)
find_path(IARMSYS_INCLUDE_DIRS NAMES sysMgr.h PATH_SUFFIXES rdk/iarmmgrs/sysmgr REQUIRED)
target_include_directories(${PLUGIN_IMPLEMENTATION} PRIVATE ${IARMBUS_INCLUDE_DIRS} ${IARMSYS_INCLUDE_DIRS})
target_link_libraries(${PLUGIN_IMPLEMENTATION} PRIVATE ${IARMBUS_LIBRARIES})
target_compile_definitions(${PLUGIN_IMPLEMENTATION} PRIVATE WITH_SYSMGR)
endif ()

find_package(Protobuf REQUIRED)
target_link_libraries(${PLUGIN_IMPLEMENTATION} PRIVATE ${Protobuf_LIBRARIES})

add_custom_target(protoc
${Protobuf_PROTOC_EXECUTABLE} --cpp_out ${CMAKE_CURRENT_BINARY_DIR} -I ${CMAKE_CURRENT_SOURCE_DIR}/grpc/secure_storage ${CMAKE_CURRENT_SOURCE_DIR}/grpc/secure_storage/secure_storage.proto
)
add_dependencies(${PLUGIN_IMPLEMENTATION} protoc)

target_link_libraries(${PLUGIN_IMPLEMENTATION} PRIVATE grpc++)
find_program(GRPC_CPP_PLUGIN grpc_cpp_plugin REQUIRED)

add_custom_target(protoc-gen-grpc
${Protobuf_PROTOC_EXECUTABLE} --grpc_out ${CMAKE_CURRENT_BINARY_DIR} --plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN} -I ${CMAKE_CURRENT_SOURCE_DIR}/grpc/secure_storage ${CMAKE_CURRENT_SOURCE_DIR}/grpc/secure_storage/secure_storage.proto
)
add_dependencies(${PLUGIN_IMPLEMENTATION} protoc-gen-grpc)

set(PROTO_SRCS secure_storage.pb.cc secure_storage.grpc.pb.cc)
target_sources(${PLUGIN_IMPLEMENTATION} PRIVATE ${PROTO_SRCS})
set_property(SOURCE ${PROTO_SRCS} PROPERTY GENERATED 1)
target_include_directories(${PLUGIN_IMPLEMENTATION} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})

install(TARGETS ${PLUGIN_IMPLEMENTATION}
DESTINATION lib/${STORAGE_DIRECTORY}/plugins)

write_config(${PLUGIN_NAME})
12 changes: 12 additions & 0 deletions CloudStore/CloudStore.conf.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
precondition = ["Platform"]
callsign = "org.rdk.CloudStore"
startuporder = "@PLUGIN_CLOUDSTORE_STARTUPORDER@"

configuration = JSON()

rootobject = JSON()
rootobject.add("mode", "@PLUGIN_CLOUDSTORE_MODE@")
rootobject.add("locator", "lib@PLUGIN_IMPLEMENTATION@.so")
configuration.add("root", rootobject)

configuration.add("uri", "@PLUGIN_CLOUDSTORE_URI@")
17 changes: 17 additions & 0 deletions CloudStore/CloudStore.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set(autostart true)
set(preconditions Platform)
set(callsign "org.rdk.CloudStore")

if(PLUGIN_CLOUDSTORE_STARTUPORDER)
set (startuporder ${PLUGIN_CLOUDSTORE_STARTUPORDER})
endif()

map()
key(root)
map()
kv(mode ${PLUGIN_CLOUDSTORE_MODE})
kv(locator lib${PLUGIN_IMPLEMENTATION}.so)
end()
kv(uri ${PLUGIN_CLOUDSTORE_URI})
end()
ans(configuration)
Loading

0 comments on commit 9de8e9f

Please sign in to comment.